aboutsummaryrefslogtreecommitdiff
path: root/src/transport
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-06-05 13:07:13 +0000
committerChristian Grothoff <christian@grothoff.org>2011-06-05 13:07:13 +0000
commit187f3ee1b6edac986b7bc46c62c86a138290b147 (patch)
tree809c2751509e7111ad26e802e5df8d2332c24455 /src/transport
parent2850662595ec7d25aaaf9674e987449375960c23 (diff)
downloadgnunet-187f3ee1b6edac986b7bc46c62c86a138290b147.tar.gz
gnunet-187f3ee1b6edac986b7bc46c62c86a138290b147.zip
adapting testcases to use new API
Diffstat (limited to 'src/transport')
-rw-r--r--src/transport/Makefile.am58
-rw-r--r--src/transport/perf_transport_ats.c361
-rw-r--r--src/transport/test_plugin_transport_http.c598
-rw-r--r--src/transport/test_quota_compliance.c716
-rw-r--r--src/transport/test_transport_api_reliability.c343
-rw-r--r--src/transport/test_transport_api_unreliability.c192
-rw-r--r--src/transport/test_transport_ats.c955
7 files changed, 1746 insertions, 1477 deletions
diff --git a/src/transport/Makefile.am b/src/transport/Makefile.am
index 2d8e4a40a..71444c4fe 100644
--- a/src/transport/Makefile.am
+++ b/src/transport/Makefile.am
@@ -128,11 +128,11 @@ gnunet_nat_client_SOURCES = \
128gnunet_transport_SOURCES = \ 128gnunet_transport_SOURCES = \
129 gnunet-transport.c 129 gnunet-transport.c
130gnunet_transport_LDADD = \ 130gnunet_transport_LDADD = \
131 $(top_builddir)/src/transport/libgnunettransport.la \ 131 $(top_builddir)/src/transport/libgnunettransportnew.la \
132 $(top_builddir)/src/util/libgnunetutil.la \ 132 $(top_builddir)/src/util/libgnunetutil.la \
133 $(GN_LIBINTL) 133 $(GN_LIBINTL)
134gnunet_transport_DEPENDENCIES = \ 134gnunet_transport_DEPENDENCIES = \
135 libgnunettransport.la 135 libgnunettransportnew.la
136 136
137if HAVE_LIBGLPK 137if HAVE_LIBGLPK
138 GN_GLPK = -lglpk 138 GN_GLPK = -lglpk
@@ -147,8 +147,6 @@ gnunet_service_transport_LDADD = \
147 $(top_builddir)/src/util/libgnunetutil.la \ 147 $(top_builddir)/src/util/libgnunetutil.la \
148 $(GN_GLPK) \ 148 $(GN_GLPK) \
149 $(GN_LIBINTL) 149 $(GN_LIBINTL)
150gnunet_service_transport_DEPENDENCIES = \
151 libgnunettransport.la
152 150
153plugin_LTLIBRARIES = \ 151plugin_LTLIBRARIES = \
154 libgnunet_plugin_transport_tcp.la \ 152 libgnunet_plugin_transport_tcp.la \
@@ -301,7 +299,7 @@ endif
301test_transport_ats_SOURCES = \ 299test_transport_ats_SOURCES = \
302 test_transport_ats.c 300 test_transport_ats.c
303test_transport_ats_LDADD = -lm \ 301test_transport_ats_LDADD = -lm \
304 $(top_builddir)/src/transport/libgnunettransport.la \ 302 $(top_builddir)/src/transport/libgnunettransportnew.la \
305 $(top_builddir)/src/statistics/libgnunetstatistics.la \ 303 $(top_builddir)/src/statistics/libgnunetstatistics.la \
306 $(top_builddir)/src/testing/libgnunettesting.la \ 304 $(top_builddir)/src/testing/libgnunettesting.la \
307 $(top_builddir)/src/util/libgnunetutil.la 305 $(top_builddir)/src/util/libgnunetutil.la
@@ -309,9 +307,6 @@ test_transport_ats_LDADD = -lm \
309perf_transport_ats_SOURCES = \ 307perf_transport_ats_SOURCES = \
310 perf_transport_ats.c 308 perf_transport_ats.c
311perf_transport_ats_LDADD = \ 309perf_transport_ats_LDADD = \
312 $(top_builddir)/src/transport/libgnunettransport.la \
313 $(top_builddir)/src/statistics/libgnunetstatistics.la \
314 $(top_builddir)/src/testing/libgnunettesting.la \
315 $(GN_GLPK) \ 310 $(GN_GLPK) \
316 $(top_builddir)/src/util/libgnunetutil.la 311 $(top_builddir)/src/util/libgnunetutil.la
317 312
@@ -332,28 +327,28 @@ test_transport_api_tcp_nat_LDADD = \
332test_transport_api_reliability_tcp_SOURCES = \ 327test_transport_api_reliability_tcp_SOURCES = \
333 test_transport_api_reliability.c 328 test_transport_api_reliability.c
334test_transport_api_reliability_tcp_LDADD = \ 329test_transport_api_reliability_tcp_LDADD = \
335 $(top_builddir)/src/transport/libgnunettransport.la \ 330 $(top_builddir)/src/transport/libgnunettransportnew.la \
336 $(top_builddir)/src/hello/libgnunethello.la \ 331 $(top_builddir)/src/hello/libgnunethello.la \
337 $(top_builddir)/src/util/libgnunetutil.la 332 $(top_builddir)/src/util/libgnunetutil.la
338 333
339test_transport_api_reliability_tcp_nat_SOURCES = \ 334test_transport_api_reliability_tcp_nat_SOURCES = \
340 test_transport_api_reliability.c 335 test_transport_api_reliability.c
341test_transport_api_reliability_tcp_nat_LDADD = \ 336test_transport_api_reliability_tcp_nat_LDADD = \
342 $(top_builddir)/src/transport/libgnunettransport.la \ 337 $(top_builddir)/src/transport/libgnunettransportnew.la \
343 $(top_builddir)/src/hello/libgnunethello.la \ 338 $(top_builddir)/src/hello/libgnunethello.la \
344 $(top_builddir)/src/util/libgnunetutil.la 339 $(top_builddir)/src/util/libgnunetutil.la
345 340
346test_transport_api_reliability_wlan_SOURCES = \ 341test_transport_api_reliability_wlan_SOURCES = \
347 test_transport_api_reliability.c 342 test_transport_api_reliability.c
348test_transport_api_reliability_wlan_LDADD = \ 343test_transport_api_reliability_wlan_LDADD = \
349 $(top_builddir)/src/transport/libgnunettransport.la \ 344 $(top_builddir)/src/transport/libgnunettransportnew.la \
350 $(top_builddir)/src/hello/libgnunethello.la \ 345 $(top_builddir)/src/hello/libgnunethello.la \
351 $(top_builddir)/src/util/libgnunetutil.la 346 $(top_builddir)/src/util/libgnunetutil.la
352 347
353test_transport_api_unreliability_wlan_SOURCES = \ 348test_transport_api_unreliability_wlan_SOURCES = \
354 test_transport_api_unreliability.c 349 test_transport_api_unreliability.c
355test_transport_api_unreliability_wlan_LDADD = \ 350test_transport_api_unreliability_wlan_LDADD = \
356 $(top_builddir)/src/transport/libgnunettransport.la \ 351 $(top_builddir)/src/transport/libgnunettransportnew.la \
357 $(top_builddir)/src/hello/libgnunethello.la \ 352 $(top_builddir)/src/hello/libgnunethello.la \
358 $(top_builddir)/src/util/libgnunetutil.la 353 $(top_builddir)/src/util/libgnunetutil.la
359 354
@@ -381,7 +376,6 @@ test_transport_api_unix_LDADD = \
381test_plugin_transport_http_SOURCES = \ 376test_plugin_transport_http_SOURCES = \
382 test_plugin_transport_http.c 377 test_plugin_transport_http.c
383test_plugin_transport_http_LDADD = \ 378test_plugin_transport_http_LDADD = \
384 $(top_builddir)/src/transport/libgnunettransport.la \
385 $(top_builddir)/src/statistics/libgnunetstatistics.la \ 379 $(top_builddir)/src/statistics/libgnunetstatistics.la \
386 @LIBCURL@ \ 380 @LIBCURL@ \
387 $(top_builddir)/src/hello/libgnunethello.la \ 381 $(top_builddir)/src/hello/libgnunethello.la \
@@ -397,14 +391,13 @@ test_transport_api_http_LDADD = \
397test_transport_api_reliability_http_SOURCES = \ 391test_transport_api_reliability_http_SOURCES = \
398 test_transport_api_reliability.c 392 test_transport_api_reliability.c
399test_transport_api_reliability_http_LDADD = \ 393test_transport_api_reliability_http_LDADD = \
400 $(top_builddir)/src/transport/libgnunettransport.la \ 394 $(top_builddir)/src/transport/libgnunettransportnew.la \
401 $(top_builddir)/src/hello/libgnunethello.la \ 395 $(top_builddir)/src/hello/libgnunethello.la \
402 $(top_builddir)/src/util/libgnunetutil.la 396 $(top_builddir)/src/util/libgnunetutil.la
403 397
404test_plugin_transport_https_SOURCES = \ 398test_plugin_transport_https_SOURCES = \
405 test_plugin_transport_https.c 399 test_plugin_transport_https.c
406test_plugin_transport_https_LDADD = \ 400test_plugin_transport_https_LDADD = \
407 $(top_builddir)/src/transport/libgnunettransport.la \
408 $(top_builddir)/src/statistics/libgnunetstatistics.la \ 401 $(top_builddir)/src/statistics/libgnunetstatistics.la \
409 @LIBCURL@ \ 402 @LIBCURL@ \
410 $(top_builddir)/src/hello/libgnunethello.la \ 403 $(top_builddir)/src/hello/libgnunethello.la \
@@ -420,21 +413,21 @@ test_transport_api_https_LDADD = \
420test_transport_api_reliability_https_SOURCES = \ 413test_transport_api_reliability_https_SOURCES = \
421 test_transport_api_reliability.c 414 test_transport_api_reliability.c
422test_transport_api_reliability_https_LDADD = \ 415test_transport_api_reliability_https_LDADD = \
423 $(top_builddir)/src/transport/libgnunettransport.la \ 416 $(top_builddir)/src/transport/libgnunettransportnew.la \
424 $(top_builddir)/src/hello/libgnunethello.la \ 417 $(top_builddir)/src/hello/libgnunethello.la \
425 $(top_builddir)/src/util/libgnunetutil.la 418 $(top_builddir)/src/util/libgnunetutil.la
426 419
427test_transport_api_unreliability_unix_SOURCES = \ 420test_transport_api_unreliability_unix_SOURCES = \
428 test_transport_api_unreliability.c 421 test_transport_api_unreliability.c
429test_transport_api_unreliability_unix_LDADD = \ 422test_transport_api_unreliability_unix_LDADD = \
430 $(top_builddir)/src/transport/libgnunettransport.la \ 423 $(top_builddir)/src/transport/libgnunettransportnew.la \
431 $(top_builddir)/src/hello/libgnunethello.la \ 424 $(top_builddir)/src/hello/libgnunethello.la \
432 $(top_builddir)/src/util/libgnunetutil.la 425 $(top_builddir)/src/util/libgnunetutil.la
433 426
434test_transport_api_unreliability_udp_SOURCES = \ 427test_transport_api_unreliability_udp_SOURCES = \
435 test_transport_api_unreliability.c 428 test_transport_api_unreliability.c
436test_transport_api_unreliability_udp_LDADD = \ 429test_transport_api_unreliability_udp_LDADD = \
437 $(top_builddir)/src/transport/libgnunettransport.la \ 430 $(top_builddir)/src/transport/libgnunettransportnew.la \
438 $(top_builddir)/src/hello/libgnunethello.la \ 431 $(top_builddir)/src/hello/libgnunethello.la \
439 $(top_builddir)/src/util/libgnunetutil.la 432 $(top_builddir)/src/util/libgnunetutil.la
440 433
@@ -452,94 +445,94 @@ endif
452test_quota_compliance_tcp_SOURCES = \ 445test_quota_compliance_tcp_SOURCES = \
453 test_quota_compliance.c 446 test_quota_compliance.c
454test_quota_compliance_tcp_LDADD = \ 447test_quota_compliance_tcp_LDADD = \
455 $(top_builddir)/src/transport/libgnunettransport.la \ 448 $(top_builddir)/src/transport/libgnunettransportnew.la \
456 $(top_builddir)/src/hello/libgnunethello.la \ 449 $(top_builddir)/src/hello/libgnunethello.la \
457 $(top_builddir)/src/util/libgnunetutil.la 450 $(top_builddir)/src/util/libgnunetutil.la
458 451
459test_quota_compliance_tcp_asymmetric_recv_constant_SOURCES = \ 452test_quota_compliance_tcp_asymmetric_recv_constant_SOURCES = \
460 test_quota_compliance.c 453 test_quota_compliance.c
461test_quota_compliance_tcp_asymmetric_recv_constant_LDADD = \ 454test_quota_compliance_tcp_asymmetric_recv_constant_LDADD = \
462 $(top_builddir)/src/transport/libgnunettransport.la \ 455 $(top_builddir)/src/transport/libgnunettransportnew.la \
463 $(top_builddir)/src/hello/libgnunethello.la \ 456 $(top_builddir)/src/hello/libgnunethello.la \
464 $(top_builddir)/src/util/libgnunetutil.la 457 $(top_builddir)/src/util/libgnunetutil.la
465 458
466#test_quota_compliance_tcp_asymmetric_send_constant_SOURCES = \ 459#test_quota_compliance_tcp_asymmetric_send_constant_SOURCES = \
467# test_quota_compliance.c 460# test_quota_compliance.c
468#test_quota_compliance_tcp_asymmetric_send_constant_LDADD = \ 461#test_quota_compliance_tcp_asymmetric_send_constant_LDADD = \
469# $(top_builddir)/src/transport/libgnunettransport.la \ 462# $(top_builddir)/src/transport/libgnunettransportnew.la \
470# $(top_builddir)/src/util/libgnunetutil.la 463# $(top_builddir)/src/util/libgnunetutil.la
471 464
472test_quota_compliance_http_SOURCES = \ 465test_quota_compliance_http_SOURCES = \
473 test_quota_compliance.c 466 test_quota_compliance.c
474test_quota_compliance_http_LDADD = \ 467test_quota_compliance_http_LDADD = \
475 $(top_builddir)/src/transport/libgnunettransport.la \ 468 $(top_builddir)/src/transport/libgnunettransportnew.la \
476 $(top_builddir)/src/hello/libgnunethello.la \ 469 $(top_builddir)/src/hello/libgnunethello.la \
477 $(top_builddir)/src/util/libgnunetutil.la 470 $(top_builddir)/src/util/libgnunetutil.la
478 471
479 test_quota_compliance_http_asymmetric_recv_constant_SOURCES = \ 472 test_quota_compliance_http_asymmetric_recv_constant_SOURCES = \
480 test_quota_compliance.c 473 test_quota_compliance.c
481test_quota_compliance_http_asymmetric_recv_constant_LDADD = \ 474test_quota_compliance_http_asymmetric_recv_constant_LDADD = \
482 $(top_builddir)/src/transport/libgnunettransport.la \ 475 $(top_builddir)/src/transport/libgnunettransportnew.la \
483 $(top_builddir)/src/hello/libgnunethello.la \ 476 $(top_builddir)/src/hello/libgnunethello.la \
484 $(top_builddir)/src/util/libgnunetutil.la 477 $(top_builddir)/src/util/libgnunetutil.la
485 478
486#test_quota_compliance_http_asymmetric_send_constant_SOURCES = \ 479#test_quota_compliance_http_asymmetric_send_constant_SOURCES = \
487# test_quota_compliance.c 480# test_quota_compliance.c
488#test_quota_compliance_http_asymmetric_send_constant_LDADD = \ 481#test_quota_compliance_http_asymmetric_send_constant_LDADD = \
489# $(top_builddir)/src/transport/libgnunettransport.la \ 482# $(top_builddir)/src/transport/libgnunettransportnew.la \
490# $(top_builddir)/src/util/libgnunetutil.la 483# $(top_builddir)/src/util/libgnunetutil.la
491 484
492test_quota_compliance_https_SOURCES = \ 485test_quota_compliance_https_SOURCES = \
493 test_quota_compliance.c 486 test_quota_compliance.c
494test_quota_compliance_https_LDADD = \ 487test_quota_compliance_https_LDADD = \
495 $(top_builddir)/src/transport/libgnunettransport.la \ 488 $(top_builddir)/src/transport/libgnunettransportnew.la \
496 $(top_builddir)/src/hello/libgnunethello.la \ 489 $(top_builddir)/src/hello/libgnunethello.la \
497 $(top_builddir)/src/util/libgnunetutil.la 490 $(top_builddir)/src/util/libgnunetutil.la
498 491
499 test_quota_compliance_https_asymmetric_recv_constant_SOURCES = \ 492 test_quota_compliance_https_asymmetric_recv_constant_SOURCES = \
500 test_quota_compliance.c 493 test_quota_compliance.c
501test_quota_compliance_https_asymmetric_recv_constant_LDADD = \ 494test_quota_compliance_https_asymmetric_recv_constant_LDADD = \
502 $(top_builddir)/src/transport/libgnunettransport.la \ 495 $(top_builddir)/src/transport/libgnunettransportnew.la \
503 $(top_builddir)/src/hello/libgnunethello.la \ 496 $(top_builddir)/src/hello/libgnunethello.la \
504 $(top_builddir)/src/util/libgnunetutil.la 497 $(top_builddir)/src/util/libgnunetutil.la
505 498
506#test_quota_compliance_https_asymmetric_send_constant_SOURCES = \ 499#test_quota_compliance_https_asymmetric_send_constant_SOURCES = \
507# test_quota_compliance.c 500# test_quota_compliance.c
508#test_quota_compliance_https_asymmetric_send_constant_LDADD = \ 501#test_quota_compliance_https_asymmetric_send_constant_LDADD = \
509# $(top_builddir)/src/transport/libgnunettransport.la \ 502# $(top_builddir)/src/transport/libgnunettransportnew.la \
510# $(top_builddir)/src/util/libgnunetutil.la 503# $(top_builddir)/src/util/libgnunetutil.la
511 504
512test_quota_compliance_udp_SOURCES = \ 505test_quota_compliance_udp_SOURCES = \
513 test_quota_compliance.c 506 test_quota_compliance.c
514test_quota_compliance_udp_LDADD = \ 507test_quota_compliance_udp_LDADD = \
515 $(top_builddir)/src/transport/libgnunettransport.la \ 508 $(top_builddir)/src/transport/libgnunettransportnew.la \
516 $(top_builddir)/src/hello/libgnunethello.la \ 509 $(top_builddir)/src/hello/libgnunethello.la \
517 $(top_builddir)/src/util/libgnunetutil.la 510 $(top_builddir)/src/util/libgnunetutil.la
518 511
519test_quota_compliance_udp_asymmetric_recv_constant_SOURCES = \ 512test_quota_compliance_udp_asymmetric_recv_constant_SOURCES = \
520 test_quota_compliance.c 513 test_quota_compliance.c
521test_quota_compliance_udp_asymmetric_recv_constant_LDADD = \ 514test_quota_compliance_udp_asymmetric_recv_constant_LDADD = \
522 $(top_builddir)/src/transport/libgnunettransport.la \ 515 $(top_builddir)/src/transport/libgnunettransportnew.la \
523 $(top_builddir)/src/hello/libgnunethello.la \ 516 $(top_builddir)/src/hello/libgnunethello.la \
524 $(top_builddir)/src/util/libgnunetutil.la 517 $(top_builddir)/src/util/libgnunetutil.la
525 518
526#test_quota_compliance_udp_asymmetric_send_constant_SOURCES = \ 519#test_quota_compliance_udp_asymmetric_send_constant_SOURCES = \
527# test_quota_compliance.c 520# test_quota_compliance.c
528#test_quota_compliance_udp_asymmetric_send_constant_LDADD = \ 521#test_quota_compliance_udp_asymmetric_send_constant_LDADD = \
529# $(top_builddir)/src/transport/libgnunettransport.la \ 522# $(top_builddir)/src/transport/libgnunettransportnew.la \
530# $(top_builddir)/src/util/libgnunetutil.la 523# $(top_builddir)/src/util/libgnunetutil.la
531 524
532test_quota_compliance_unix_SOURCES = \ 525test_quota_compliance_unix_SOURCES = \
533 test_quota_compliance.c 526 test_quota_compliance.c
534test_quota_compliance_unix_LDADD = \ 527test_quota_compliance_unix_LDADD = \
535 $(top_builddir)/src/transport/libgnunettransport.la \ 528 $(top_builddir)/src/transport/libgnunettransportnew.la \
536 $(top_builddir)/src/hello/libgnunethello.la \ 529 $(top_builddir)/src/hello/libgnunethello.la \
537 $(top_builddir)/src/util/libgnunetutil.la 530 $(top_builddir)/src/util/libgnunetutil.la
538 531
539test_quota_compliance_unix_asymmetric_recv_constant_SOURCES = \ 532test_quota_compliance_unix_asymmetric_recv_constant_SOURCES = \
540 test_quota_compliance.c 533 test_quota_compliance.c
541test_quota_compliance_unix_asymmetric_recv_constant_LDADD = \ 534test_quota_compliance_unix_asymmetric_recv_constant_LDADD = \
542 $(top_builddir)/src/transport/libgnunettransport.la \ 535 $(top_builddir)/src/transport/libgnunettransportnew.la \
543 $(top_builddir)/src/hello/libgnunethello.la \ 536 $(top_builddir)/src/hello/libgnunethello.la \
544 $(top_builddir)/src/util/libgnunetutil.la 537 $(top_builddir)/src/util/libgnunetutil.la
545 538
@@ -552,6 +545,7 @@ test_transport_api_multi_LDADD = \
552 $(top_builddir)/src/util/libgnunetutil.la 545 $(top_builddir)/src/util/libgnunetutil.la
553EXTRA_DIST = \ 546EXTRA_DIST = \
554 gnunet-transport-certificate-creation \ 547 gnunet-transport-certificate-creation \
548 ats_mlp_p100_m400.problem \
555 test_transport_api_data.conf \ 549 test_transport_api_data.conf \
556 test_transport_api_tcp_peer1.conf \ 550 test_transport_api_tcp_peer1.conf \
557 test_transport_api_tcp_peer2.conf \ 551 test_transport_api_tcp_peer2.conf \
diff --git a/src/transport/perf_transport_ats.c b/src/transport/perf_transport_ats.c
index 1f168b661..d95e02d2b 100644
--- a/src/transport/perf_transport_ats.c
+++ b/src/transport/perf_transport_ats.c
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 (C) 2009 Christian Grothoff (and other contributing authors) 3 (C) 2010, 2011 Christian Grothoff (and other contributing authors)
4 4
5 GNUnet is free software; you can redistribute it and/or modify 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 6 it under the terms of the GNU General Public License as published
@@ -18,7 +18,7 @@
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20/** 20/**
21 * @file testing/per_transport_ats.c 21 * @file testing/perf_transport_ats.c
22 * @brief testcase for ats functionality 22 * @brief testcase for ats functionality
23 */ 23 */
24#include "platform.h" 24#include "platform.h"
@@ -48,217 +48,252 @@ static struct GNUNET_TIME_Absolute start;
48static struct GNUNET_TIME_Absolute end; 48static struct GNUNET_TIME_Absolute end;
49 49
50 50
51void solve_mlp(int presolve) 51static void
52solve_mlp(int presolve)
52{ 53{
53 int result, solution; 54 int result, solution;
54 55
55 glp_iocp opt_mlp; 56 glp_iocp opt_mlp;
56 glp_init_iocp(&opt_mlp); 57 glp_init_iocp(&opt_mlp);
57 opt_mlp.msg_lev = GLP_MSG_OFF; 58 opt_mlp.msg_lev = GLP_MSG_OFF;
58 opt_mlp.presolve = GLP_OFF; 59 opt_mlp.presolve = GLP_OFF;
59 60
60 result = glp_intopt (prob, &opt_mlp); 61 result = glp_intopt (prob, &opt_mlp);
61 solution = glp_mip_status (prob); 62 solution = glp_mip_status (prob);
62 GNUNET_assert ((solution == 5) && (result==0)); 63 GNUNET_assert ((solution == 5) && (result==0));
63} 64}
64 65
65void solve_lp(int presolve) 66static void
67solve_lp(int presolve)
66{ 68{
67 int result, solution; 69 int result, solution;
68 70
69 glp_smcp opt_lp; 71 glp_smcp opt_lp;
70 glp_init_smcp(&opt_lp); 72 glp_init_smcp(&opt_lp);
71 73
72 opt_lp.msg_lev = GLP_MSG_OFF; 74 opt_lp.msg_lev = GLP_MSG_OFF;
73 if (presolve==GNUNET_YES) opt_lp.presolve = GLP_ON; 75 if (presolve==GNUNET_YES) opt_lp.presolve = GLP_ON;
74 else opt_lp.presolve = GLP_OFF; 76 else opt_lp.presolve = GLP_OFF;
75 77
76 result = glp_simplex(prob, &opt_lp); 78 result = glp_simplex(prob, &opt_lp);
77 solution = glp_get_status (prob); 79 solution = glp_get_status (prob);
78 GNUNET_assert ((solution == 5) && (result==0)); 80 GNUNET_assert ((solution == 5) && (result==0));
79} 81}
80 82
83#if 0
81/* Modify quality constraint */ 84/* Modify quality constraint */
82void modify_qm(int start, int length, int values_to_change) 85static void
86modify_qm(int start, int length, int values_to_change)
83{ 87{
84 //int * ind = GNUNET_malloc (length * sizeof (int)); 88 //int * ind = GNUNET_malloc (length * sizeof (int));
85 //double *val = GNUNET_malloc (length * sizeof (double)); 89 //double *val = GNUNET_malloc (length * sizeof (double));
86 int ind[1000]; 90 int ind[1000];
87 double val[1000]; 91 double val[1000];
88 92
89 int res = 0; 93 int res = 0;
90 int c = start, c2=1; 94 int c = start, c2=1;
91 while (c<=(start+values_to_change)) 95 while (c<=(start+values_to_change))
96 {
97 res = glp_get_mat_row(prob, c, ind, val);
98
99 printf("%i %i \n", c, res);
100 for (c2=0; c2<res; c2++)
92 { 101 {
93 res = glp_get_mat_row(prob, c, ind, val); 102 printf("%i = %f \n", ind[c2], val[c2]);
94
95 printf("%i %i \n", c, res);
96 for (c2=0; c2<res; c2++)
97 {
98 printf("%i = %f \n", ind[c2], val[c2]);
99 }
100
101 c++;
102 } 103 }
103 //glp_set_mat_row(prob, start, length, ind, val); 104
105 c++;
106 }
107 //glp_set_mat_row(prob, start, length, ind, val);
104} 108}
109#endif
105 110
106 111
107 112static void
108void bench_simplex_optimization(char * file, int executions) 113bench_simplex_optimization(char * file, int executions)
109{ 114{
110 115
111 int c; 116 int c;
112 prob = glp_create_prob(); 117 prob = glp_create_prob();
113 glp_read_lp(prob, NULL, file); 118 glp_read_lp(prob, NULL, file);
114 119
115 solve_lp(GNUNET_YES); 120 solve_lp(GNUNET_YES);
116 121
117 for (c=0; c<executions;c++) 122 for (c=0; c<executions;c++)
118 { 123 {
119 start = GNUNET_TIME_absolute_get(); 124 start = GNUNET_TIME_absolute_get();
120 solve_lp(GNUNET_NO); 125 solve_lp(GNUNET_NO);
121 end = GNUNET_TIME_absolute_get(); 126 end = GNUNET_TIME_absolute_get();
122 127
123 exec_time[c] = GNUNET_TIME_absolute_get_difference(start, end).rel_value; 128 exec_time[c] = GNUNET_TIME_absolute_get_difference(start, end).rel_value;
124 129
125 sim_with_opt_avg += exec_time[c]; 130 sim_with_opt_avg += exec_time[c];
126 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Simplex /w optimization iterations %i: %llu \n", c, exec_time[c]); 131 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
127 } 132 "Simplex /w optimization iterations %i: %llu \n",
128 133 c, exec_time[c]);
129 glp_delete_prob(prob); 134 }
135
136 glp_delete_prob(prob);
130} 137}
131 138
132 139
133void bench_simplex_no_optimization(char * file, int executions) 140static void
141bench_simplex_no_optimization(char * file, int executions)
134{ 142{
135 143
136 int c; 144 int c;
137 prob = glp_create_prob(); 145 prob = glp_create_prob();
138 glp_read_lp(prob, NULL, file); 146 glp_read_lp(prob, NULL, file);
139 147
140 for (c=0; c<executions;c++) 148 for (c=0; c<executions;c++)
141 { 149 {
142 start = GNUNET_TIME_absolute_get(); 150 start = GNUNET_TIME_absolute_get();
143 solve_lp(GNUNET_YES); 151 solve_lp(GNUNET_YES);
144 end = GNUNET_TIME_absolute_get(); 152 end = GNUNET_TIME_absolute_get();
145 153
146 exec_time[c] = GNUNET_TIME_absolute_get_difference(start, end).rel_value; 154 exec_time[c] = GNUNET_TIME_absolute_get_difference(start, end).rel_value;
147 155
148 sim_no_opt_avg += exec_time[c]; 156 sim_no_opt_avg += exec_time[c];
149 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Simplex iterations %i: %llu \n", c, exec_time[c]); 157 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
150 } 158 "Simplex iterations %i: %llu \n",
151 159 c, exec_time[c]);
152 glp_delete_prob(prob); 160 }
161
162 glp_delete_prob(prob);
153} 163}
154 164
155void bench_mlp_no_optimization(char * file, int executions)
156{
157
158 int c;
159 prob = glp_create_prob();
160 glp_read_lp(prob, NULL, file);
161
162 for (c=0; c<executions;c++)
163 {
164 start = GNUNET_TIME_absolute_get();
165 solve_lp(GNUNET_YES);
166 solve_mlp (GNUNET_NO);
167 end = GNUNET_TIME_absolute_get();
168
169 exec_time[c] = GNUNET_TIME_absolute_get_difference(start, end).rel_value;
170
171 mlp_no_opt_avg += exec_time[c];
172 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MLP iterations no optimization %i: %llu \n", c, exec_time[c]);
173 }
174 165
175 glp_delete_prob(prob); 166static void
167bench_mlp_no_optimization(char * file, int executions)
168{
169
170 int c;
171 prob = glp_create_prob();
172 glp_read_lp(prob, NULL, file);
173
174 for (c=0; c<executions;c++)
175 {
176 start = GNUNET_TIME_absolute_get();
177 solve_lp(GNUNET_YES);
178 solve_mlp (GNUNET_NO);
179 end = GNUNET_TIME_absolute_get();
180
181 exec_time[c] = GNUNET_TIME_absolute_get_difference(start, end).rel_value;
182
183 mlp_no_opt_avg += exec_time[c];
184 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MLP iterations no optimization %i: %llu \n", c, exec_time[c]);
185 }
186
187 glp_delete_prob(prob);
176} 188}
177 189
178 190
179void bench_mlp_with_optimization(char * file, int executions, int changes) 191static void
192bench_mlp_with_optimization(char * file, int executions, int changes)
180{ 193{
181 int c; 194 int c;
182 prob = glp_create_prob(); 195 prob = glp_create_prob();
183 glp_read_lp(prob, NULL, file); 196 glp_read_lp(prob, NULL, file);
184 197
185 solve_lp(GNUNET_YES); 198 solve_lp(GNUNET_YES);
186 199
187 for (c=0; c<executions;c++) 200 for (c=0; c<executions;c++)
188 { 201 {
189 start = GNUNET_TIME_absolute_get(); 202 start = GNUNET_TIME_absolute_get();
190 //modify_qm(906, 0, 0); 203 // modify_qm(906, 0, 0);
191 solve_lp(GNUNET_NO); 204 solve_lp(GNUNET_NO);
192 solve_mlp (GNUNET_NO); 205 solve_mlp (GNUNET_NO);
193 end = GNUNET_TIME_absolute_get(); 206 end = GNUNET_TIME_absolute_get();
194 207
195 exec_time[c] = GNUNET_TIME_absolute_get_difference(start, end).rel_value; 208 exec_time[c] = GNUNET_TIME_absolute_get_difference(start, end).rel_value;
196 209
197 mlp_with_opt_avg += exec_time[c]; 210 mlp_with_opt_avg += exec_time[c];
198 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MLP /w optimization iterations %i: %llu \n", c, exec_time[c]); 211 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MLP /w optimization iterations %i: %llu \n", c, exec_time[c]);
199 } 212 }
200 213
201 glp_delete_prob(prob); 214 glp_delete_prob(prob);
202} 215}
203 216
204#if 0 217#if 0
205void modify_cr (int start, int length, int count) 218static void
219modify_cr (int start, int length, int count)
206{ 220{
207 //int * ind = GNUNET_malloc (length * sizeof (int)); 221 //int * ind = GNUNET_malloc (length * sizeof (int));
208 //double *val = GNUNET_malloc (length * sizeof (double)); 222 //double *val = GNUNET_malloc (length * sizeof (double));
209 int ind[500]; 223 int ind[500];
210 double val[500]; 224 double val[500];
211 int res = 0; 225 int res = 0;
212 int c = start, c2=1; 226 int c = start, c2=1;
213 while (c<=(start+count)) 227 while (c<=(start+count))
228 {
229 res = glp_get_mat_row(prob, c, ind, val);
230
231 printf("row index: %i non-zero elements: %i \n", c, res);
232 for (c2=1; c2<=res; c2++)
214 { 233 {
215 res = glp_get_mat_row(prob, c, ind, val); 234 printf("%i = %f ", ind[c2], val[c2]);
216
217 printf("row index: %i non-zero elements: %i \n", c, res);
218 for (c2=1; c2<=res; c2++)
219 {
220 printf("%i = %f ", ind[c2], val[c2]);
221 }
222 c++;
223 printf ("\n----\n");
224 } 235 }
225 //glp_set_mat_row(prob, start, length, ind, val); 236 c++;
237 printf ("\n----\n");
238 }
239 //glp_set_mat_row(prob, start, length, ind, val);
226} 240}
227#endif 241#endif
228#endif 242#endif
229 243
230int main (int argc, char *argv[]) 244
245int
246main (int argc, char *argv[])
231{ 247{
232 int ret = 0; 248 int ret = 0;
233 GNUNET_log_setup ("perf-transport-ats", 249 GNUNET_log_setup ("perf-transport-ats",
234#if VERBOSE 250#if VERBOSE
235 "DEBUG", 251 "DEBUG",
236#else 252#else
237 "INFO", 253 "INFO",
238#endif 254#endif
239 NULL); 255 NULL);
240 256
241#if !HAVE_LIBGLPK 257#if !HAVE_LIBGLPK
242 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "GLPK not installed, exiting testcase\n"); 258 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
243 return 0; 259 "GLPK not installed, exiting testcase\n");
260 return 0;
244#else 261#else
245 262
246 char * file = "ats_mlp_p100_m400.problem"; 263 char * file = "ats_mlp_p100_m400.problem";
247 // char * file = "mlps/ats_mlp_p500_m2000.problem"; 264 // char * file = "mlps/ats_mlp_p500_m2000.problem";
248 bench_simplex_no_optimization (file, executions); 265 bench_simplex_no_optimization (file, executions);
249 bench_simplex_optimization (file, executions); 266 bench_simplex_optimization (file, executions);
250 bench_mlp_no_optimization (file, executions); 267 bench_mlp_no_optimization (file, executions);
251 bench_mlp_with_optimization (file, executions, 0); 268 bench_mlp_with_optimization (file, executions, 0);
252 269
253 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Simplex no optimization average: %llu\n", sim_no_opt_avg / EXECS); 270 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
271 "Simplex no optimization average: %llu\n",
272 sim_no_opt_avg / EXECS);
254 // -> 400 addresses 273 // -> 400 addresses
255 GAUGER ("TRANSPORT","GLPK simplex no optimization", (sim_no_opt_avg / EXECS) / 400, "ms/address"); 274 GAUGER ("GLPK",
256 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Simplex, no optimization, average per peer: %llu\n", (sim_with_opt_avg / EXECS) / 400); 275 "GLPK simplex no optimization",
257 GAUGER ("TRANSPORT","GLPK simplex, 100 peers 400 addresses with optimization", (sim_with_opt_avg / EXECS) / 400, "ms/address"); 276 (sim_no_opt_avg / EXECS) / 400,
258 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MLP no optimization average: %llu\n", (mlp_no_opt_avg / EXECS) / 400); 277 "ms/address");
259 GAUGER ("TRANSPORT","GLPK MLP 100 peers 400 addresses no optimization", (mlp_no_opt_avg / EXECS) / 400, "ms/address"); 278 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
260 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MLP optimization average: %llu\n", (mlp_with_opt_avg/ EXECS) / 400); 279 "Simplex, no optimization, average per peer: %llu\n",
261 GAUGER ("TRANSPORT","GLPK MLP 100 peers 400 addresses with optimization", (mlp_with_opt_avg / EXECS) / 400, "ms/address"); 280 (sim_with_opt_avg / EXECS) / 400);
281 GAUGER ("GLPK",
282 "GLPK simplex with optimization",
283 (sim_with_opt_avg / EXECS) / 400,
284 "ms/address");
285 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
286 "MLP no optimization average: %llu\n",
287 (mlp_no_opt_avg / EXECS) / 400);
288 GAUGER ("GLPK",
289 "GLPK MLP no optimization",
290 (mlp_no_opt_avg / EXECS) / 400,
291 "ms/address");
292 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MLP optimization average: %llu\n",
293 (mlp_with_opt_avg/ EXECS) / 400);
294 GAUGER ("GLPK",
295 "GLPK MLP with optimization",
296 (mlp_with_opt_avg / EXECS) / 400, "ms/address");
262 297
263#endif 298#endif
264 return ret; 299 return ret;
diff --git a/src/transport/test_plugin_transport_http.c b/src/transport/test_plugin_transport_http.c
index 989e0d69a..73a9c950a 100644
--- a/src/transport/test_plugin_transport_http.c
+++ b/src/transport/test_plugin_transport_http.c
@@ -396,31 +396,46 @@ shutdown_clean ()
396 396
397 /* Evaluate results */ 397 /* Evaluate results */
398 fail = 0; 398 fail = 0;
399 if ((fail_notify_address == GNUNET_YES) || (fail_pretty_printer == GNUNET_YES) || (fail_addr_to_str == GNUNET_YES)) 399 if ( (fail_notify_address == GNUNET_YES) ||
400 { 400 (fail_pretty_printer == GNUNET_YES) ||
401 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Phase 0: Test plugin functions failed\n"); 401 (fail_addr_to_str == GNUNET_YES))
402 fail = 1; 402 {
403 } 403 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
404 if ((test_no_ident.test_failed == GNUNET_YES) || (test_too_short_ident.test_failed == GNUNET_YES) || (test_too_long_ident.test_failed == GNUNET_YES) || (test_valid_ident.test_failed == GNUNET_YES)) 404 "Phase 0: Test plugin functions failed\n");
405 { 405 fail = 1;
406 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Phase 1: Test connect with wrong data failed\n"); 406 }
407 fail = 1; 407 if ( (test_no_ident.test_failed == GNUNET_YES) ||
408 } 408 (test_too_short_ident.test_failed == GNUNET_YES) ||
409 if ((fail_session_selection_any != GNUNET_NO) || (fail_session_selection_reliable != GNUNET_NO) || (fail_session_selection_session != GNUNET_NO) || (fail_session_selection_session_big != GNUNET_NO)) 409 (test_too_long_ident.test_failed == GNUNET_YES) ||
410 { 410 (test_valid_ident.test_failed == GNUNET_YES) )
411 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Phase 2: Test session selection failed\n");
412 fail = 1;
413 }
414 if ((fail_msgs_transmited_to_local_addrs != count_str_addr) || (fail_multiple_msgs_in_transmission != 2) || (fail_msg_transmited_max_size == GNUNET_YES))
415 { 411 {
416 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Phase 3: Test sending with plugin failed\n"); 412 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
413 "Phase 1: Test connect with wrong data failed\n");
417 fail = 1; 414 fail = 1;
418 } 415 }
416 if ( (fail_session_selection_any != GNUNET_NO) ||
417 (fail_session_selection_reliable != GNUNET_NO) ||
418 (fail_session_selection_session != GNUNET_NO) ||
419 (fail_session_selection_session_big != GNUNET_NO) )
420 {
421 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
422 "Phase 2: Test session selection failed\n");
423 fail = 1;
424 }
425 if ( (fail_msgs_transmited_to_local_addrs != count_str_addr) ||
426 (fail_multiple_msgs_in_transmission != 2) ||
427 (fail_msg_transmited_max_size == GNUNET_YES) )
428 {
429 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
430 "Phase 3: Test sending with plugin failed\n");
431 fail = 1;
432 }
419 if (fail != 1) 433 if (fail != 1)
420 { 434 {
421 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "All tests successful\n"); 435 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
422 } 436 "All tests successful\n");
423 437 }
438
424 api->disconnect(api->cls,&my_identity); 439 api->disconnect(api->cls,&my_identity);
425 440
426 curl_multi_cleanup(multi_handle); 441 curl_multi_cleanup(multi_handle);
@@ -456,13 +471,15 @@ shutdown_clean ()
456 } 471 }
457 472
458 GNUNET_free(test_addr); 473 GNUNET_free(test_addr);
459 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Unloading http plugin\n"); 474 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
475 "Unloading http plugin\n");
460 GNUNET_assert (NULL == GNUNET_PLUGIN_unload ("libgnunet_gnunet_transport_plugin_http", api)); 476 GNUNET_assert (NULL == GNUNET_PLUGIN_unload ("libgnunet_gnunet_transport_plugin_http", api));
461 477
462 GNUNET_SCHEDULER_shutdown(); 478 GNUNET_SCHEDULER_shutdown();
463 GNUNET_DISK_directory_remove ("/tmp/test_gnunet_transport_plugin_http"); 479 GNUNET_DISK_directory_remove ("/tmp/test_gnunet_transport_plugin_http");
464 480
465 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Exiting testcase\n"); 481 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
482 "Exiting testcase\n");
466 exit(fail); 483 exit(fail);
467 return; 484 return;
468} 485}
@@ -475,22 +492,26 @@ shutdown_clean ()
475 * @result GNUNET_OK or GNUNET_SYSERR 492 * @result GNUNET_OK or GNUNET_SYSERR
476 */ 493 */
477 494
478static void task_send_cont (void *cls, 495static void
479 const struct GNUNET_PeerIdentity * target, 496task_send_cont (void *cls,
480 int result) 497 const struct GNUNET_PeerIdentity * target,
498 int result)
481{ 499{
482 if ((cls == &fail_msg_transmited_bigger_max_size) && (result == GNUNET_SYSERR)) 500 if ((cls == &fail_msg_transmited_bigger_max_size) && (result == GNUNET_SYSERR))
483 { 501 {
484 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Message bigger max msg size was not sent!\n"); 502 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
485 fail_msg_transmited_bigger_max_size = GNUNET_NO; 503 "Message bigger max msg size was not sent!\n");
486 return; 504 fail_msg_transmited_bigger_max_size = GNUNET_NO;
487 } 505 return;
506 }
488 507
489 if ((cls == &fail_msg_transmited_max_size) && (result == GNUNET_OK)) 508 if ((cls == &fail_msg_transmited_max_size) && (result == GNUNET_OK))
490 { 509 {
491 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Message with max msg size succesfully sent!\n",fail_msgs_transmited_to_local_addrs); 510 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
492 fail_msg_transmited_max_size = GNUNET_NO; 511 "Message with max msg size succesfully sent!\n",
493 } 512 fail_msgs_transmited_to_local_addrs);
513 fail_msg_transmited_max_size = GNUNET_NO;
514 }
494} 515}
495 516
496 517
@@ -508,51 +529,52 @@ receive (void *cls, const struct GNUNET_PeerIdentity *peer,
508 const char *sender_address, 529 const char *sender_address,
509 uint16_t sender_address_len) 530 uint16_t sender_address_len)
510{ 531{
511 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Testcase recieved new message from peer `%s' with type %u and length %u, session %X\n", GNUNET_i2s(peer), ntohs(message->type), ntohs(message->size),session); 532 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
512 533 "Testcase recieved new message from peer `%s' with type %u and length %u, session %X\n",
513 if ((ntohs(message->type)>=10) && (ntohs(message->type)<20)) 534 GNUNET_i2s(peer),
514 { 535 ntohs(message->type),
515 fail_msgs_transmited_to_local_addrs++; 536 ntohs(message->size),
516 if (fail_msgs_transmited_to_local_addrs == count_str_addr) 537 session);
517 run_connection_tests(2, session); 538
518 } 539 if ( (ntohs(message->type)>=10) &&
519 540 (ntohs(message->type)<20) )
520 541 {
542 fail_msgs_transmited_to_local_addrs++;
543 if (fail_msgs_transmited_to_local_addrs == count_str_addr)
544 run_connection_tests(2, session);
545 }
521 if ((ntohs(message->type)==20)) 546 if ((ntohs(message->type)==20))
522 { 547 {
523 fail_session_selection_reliable = GNUNET_NO; 548 fail_session_selection_reliable = GNUNET_NO;
524 } 549 }
525
526 if ((ntohs(message->type)==21)) 550 if ((ntohs(message->type)==21))
527 { 551 {
528 fail_session_selection_any = GNUNET_NO; 552 fail_session_selection_any = GNUNET_NO;
529 } 553 }
530 if ((ntohs(message->type)==22)) 554 if ((ntohs(message->type)==22))
531 { 555 {
532 fail_session_selection_session = GNUNET_NO; 556 fail_session_selection_session = GNUNET_NO;
533 } 557 }
534
535 if ((ntohs(message->type)==23)) 558 if ((ntohs(message->type)==23))
536 { 559 {
537 fail_session_selection_session_big = GNUNET_NO; 560 fail_session_selection_session_big = GNUNET_NO;
538 run_connection_tests(3, NULL); 561 run_connection_tests(3, NULL);
539 } 562 }
540
541 if ((ntohs(message->type)==30) || (ntohs(message->type)==31)) 563 if ((ntohs(message->type)==30) || (ntohs(message->type)==31))
542 { 564 {
543 fail_multiple_msgs_in_transmission ++; 565 fail_multiple_msgs_in_transmission ++;
544 } 566 }
545
546 if ((ntohs(message->type)==32) && (ntohs(message->size) == GNUNET_SERVER_MAX_MESSAGE_SIZE-1)) 567 if ((ntohs(message->type)==32) && (ntohs(message->size) == GNUNET_SERVER_MAX_MESSAGE_SIZE-1))
547 { 568 {
548 fail_msg_transmited_max_size = GNUNET_NO; 569 fail_msg_transmited_max_size = GNUNET_NO;
549 shutdown_clean(); 570 shutdown_clean();
550 } 571 }
551
552 return GNUNET_TIME_UNIT_ZERO; 572 return GNUNET_TIME_UNIT_ZERO;
553} 573}
554 574
555static size_t send_function (void *stream, size_t size, size_t nmemb, void *ptr) 575
576static size_t
577send_function (void *stream, size_t size, size_t nmemb, void *ptr)
556{ 578{
557 unsigned int len; 579 unsigned int len;
558 580
@@ -563,9 +585,11 @@ static size_t send_function (void *stream, size_t size, size_t nmemb, void *ptr)
563 memcpy(stream, buffer_out.buf, len); 585 memcpy(stream, buffer_out.buf, len);
564 buffer_out.pos = len; 586 buffer_out.pos = len;
565 return len; 587 return len;
588
566} 589}
567 590
568static size_t recv_function (void *ptr, size_t size, size_t nmemb, void *ctx) 591static size_t
592recv_function (void *ptr, size_t size, size_t nmemb, void *ctx)
569{ 593{
570 594
571 if (buffer_in.pos + size * nmemb > buffer_in.size) 595 if (buffer_in.pos + size * nmemb > buffer_in.size)
@@ -579,9 +603,10 @@ static size_t recv_function (void *ptr, size_t size, size_t nmemb, void *ctx)
579 return buffer_in.pos; 603 return buffer_in.pos;
580} 604}
581 605
582static size_t header_function( void *ptr, size_t size, size_t nmemb, void *stream) 606static size_t
607header_function( void *ptr, size_t size, size_t nmemb, void *stream)
583{ 608{
584 struct HTTP_Transfer * res = (struct HTTP_Transfer *) stream; 609 struct HTTP_Transfer * res = stream;
585 char * tmp; 610 char * tmp;
586 unsigned int len = size * nmemb; 611 unsigned int len = size * nmemb;
587 612
@@ -590,39 +615,43 @@ static size_t header_function( void *ptr, size_t size, size_t nmemb, void *strea
590 if (tmp[len-2] == 13) 615 if (tmp[len-2] == 13)
591 tmp[len-2]= '\0'; 616 tmp[len-2]= '\0';
592#if DEBUG_CURL 617#if DEBUG_CURL
593 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Header: `%s'\n",tmp); 618 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
619 "Header: `%s'\n",
620 tmp);
594#endif 621#endif
595 if (0==strcmp (tmp,"HTTP/1.1 100 Continue")) 622 if (0==strcmp (tmp,"HTTP/1.1 100 Continue"))
596 { 623 {
597 res->http_result_code=100; 624 res->http_result_code=100;
598 } 625 }
599 if (0==strcmp (tmp,"HTTP/1.1 200 OK")) 626 if (0==strcmp (tmp,"HTTP/1.1 200 OK"))
600 { 627 {
601 res->http_result_code=200; 628 res->http_result_code=200;
602 } 629 }
603 if (0==strcmp (tmp,"HTTP/1.1 400 Bad Request")) 630 if (0==strcmp (tmp,"HTTP/1.1 400 Bad Request"))
604 { 631 {
605 res->http_result_code=400; 632 res->http_result_code=400;
606 } 633 }
607 if (0==strcmp (tmp,"HTTP/1.1 404 Not Found")) 634 if (0==strcmp (tmp,"HTTP/1.1 404 Not Found"))
608 { 635 {
609 res->http_result_code=404; 636 res->http_result_code=404;
610 } 637 }
611 if (0==strcmp (tmp,"HTTP/1.1 413 Request entity too large")) 638 if (0==strcmp (tmp,"HTTP/1.1 413 Request entity too large"))
612 { 639 {
613 res->http_result_code=413; 640 res->http_result_code=413;
614 } 641 }
615 642
616 GNUNET_free (tmp); 643 GNUNET_free (tmp);
617 return size * nmemb; 644 return size * nmemb;
618} 645}
619 646
620static size_t send_prepare( struct HTTP_Transfer * result);
621 647
648static size_t
649send_prepare( struct HTTP_Transfer * result);
622 650
623 651
624static void send_execute (void *cls, 652static void
625 const struct GNUNET_SCHEDULER_TaskContext *tc) 653send_execute (void *cls,
654 const struct GNUNET_SCHEDULER_TaskContext *tc)
626{ 655{
627 struct HTTP_Transfer *res; 656 struct HTTP_Transfer *res;
628 657
@@ -673,42 +702,50 @@ static void send_execute (void *cls,
673 if (res == &test_no_ident) 702 if (res == &test_no_ident)
674 { 703 {
675 if ((res->http_result_code==404) && (buffer_in.len==208)) 704 if ((res->http_result_code==404) && (buffer_in.len==208))
676 { 705 {
677 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connecting to peer without any peer identification: test passed\n"); 706 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
707 "Connecting to peer without any peer identification: test passed\n");
678 res->test_failed = GNUNET_NO; 708 res->test_failed = GNUNET_NO;
679 } 709 }
680 else 710 else
681 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Connecting to peer without any peer identification: test failed\n")); 711 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
712 _("Connecting to peer without any peer identification: test failed\n"));
682 } 713 }
683 if (res == &test_too_short_ident) 714 if (res == &test_too_short_ident)
684 { 715 {
685 if ((res->http_result_code==404) && (buffer_in.len==208)) 716 if ((res->http_result_code==404) && (buffer_in.len==208))
686 { 717 {
687 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connecting to peer with too short peer identification: test passed\n"); 718 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
719 "Connecting to peer with too short peer identification: test passed\n");
688 res->test_failed = GNUNET_NO; 720 res->test_failed = GNUNET_NO;
689 } 721 }
690 else 722 else
691 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Connecting to peer with too short peer identification: test failed\n")); 723 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
724 _("Connecting to peer with too short peer identification: test failed\n"));
692 } 725 }
693 if (res == &test_too_long_ident) 726 if (res == &test_too_long_ident)
694 { 727 {
695 if ((res->http_result_code==404) && (buffer_in.len==208)) 728 if ((res->http_result_code==404) && (buffer_in.len==208))
696 { 729 {
697 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connecting to peer with too long peer identification: test passed\n"); 730 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
731 "Connecting to peer with too long peer identification: test passed\n");
698 res->test_failed = GNUNET_NO; 732 res->test_failed = GNUNET_NO;
699 } 733 }
700 else 734 else
701 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Connecting to peer with too long peer identification: test failed\n")); 735 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
736 _("Connecting to peer with too long peer identification: test failed\n"));
702 } 737 }
703 if (res == &test_valid_ident) 738 if (res == &test_valid_ident)
704 { 739 {
705 if ((res->http_result_code==200)) 740 if ((res->http_result_code==200))
706 { 741 {
707 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connecting to peer with valid peer identification: test passed\n"); 742 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
743 "Connecting to peer with valid peer identification: test passed\n");
708 res->test_failed = GNUNET_NO; 744 res->test_failed = GNUNET_NO;
709 } 745 }
710 else 746 else
711 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Connecting to peer with valid peer identification: test failed\n"); 747 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
748 "Connecting to peer with valid peer identification: test failed\n");
712 } 749 }
713 curl_easy_cleanup(curl_handle); 750 curl_easy_cleanup(curl_handle);
714 curl_handle=NULL; 751 curl_handle=NULL;
@@ -728,12 +765,14 @@ static void send_execute (void *cls,
728 send_prepare(cls); 765 send_prepare(cls);
729} 766}
730 767
768
731/** 769/**
732 * Function setting up file descriptors and scheduling task to run 770 * Function setting up file descriptors and scheduling task to run
733 * @param ses session to send data to 771 * @param ses session to send data to
734 * @return bytes sent to peer 772 * @return bytes sent to peer
735 */ 773 */
736static size_t send_prepare( struct HTTP_Transfer * result) 774static size_t
775send_prepare( struct HTTP_Transfer * result)
737{ 776{
738 fd_set rs; 777 fd_set rs;
739 fd_set ws; 778 fd_set ws;
@@ -772,12 +811,12 @@ static size_t send_prepare( struct HTTP_Transfer * result)
772 GNUNET_NETWORK_fdset_copy_native (grs, &rs, max + 1); 811 GNUNET_NETWORK_fdset_copy_native (grs, &rs, max + 1);
773 GNUNET_NETWORK_fdset_copy_native (gws, &ws, max + 1); 812 GNUNET_NETWORK_fdset_copy_native (gws, &ws, max + 1);
774 http_task_send = GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT, 813 http_task_send = GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT,
775 GNUNET_SCHEDULER_NO_TASK, 814 GNUNET_SCHEDULER_NO_TASK,
776 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 0), 815 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 0),
777 grs, 816 grs,
778 gws, 817 gws,
779 &send_execute, 818 &send_execute,
780 result); 819 result);
781 GNUNET_NETWORK_fdset_destroy (gws); 820 GNUNET_NETWORK_fdset_destroy (gws);
782 GNUNET_NETWORK_fdset_destroy (grs); 821 GNUNET_NETWORK_fdset_destroy (grs);
783 822
@@ -788,15 +827,17 @@ static size_t send_prepare( struct HTTP_Transfer * result)
788/** 827/**
789 * function to send data to server 828 * function to send data to server
790 */ 829 */
791static int send_data( struct HTTP_Transfer * result, char * url) 830static int
831send_data(struct HTTP_Transfer * result,
832 char * url)
792{ 833{
793 834
794 curl_handle = curl_easy_init(); 835 curl_handle = curl_easy_init();
795 if( NULL == curl_handle) 836 if( NULL == curl_handle)
796 { 837 {
797 printf("easy_init failed \n"); 838 printf("easy_init failed \n");
798 return GNUNET_SYSERR; 839 return GNUNET_SYSERR;
799 } 840 }
800#if DEBUG_CURL 841#if DEBUG_CURL
801 curl_easy_setopt(curl_handle, CURLOPT_VERBOSE, 1L); 842 curl_easy_setopt(curl_handle, CURLOPT_VERBOSE, 1L);
802#endif 843#endif
@@ -822,7 +863,7 @@ static int send_data( struct HTTP_Transfer * result, char * url)
822/** 863/**
823 * Plugin notifies transport (aka testcase) about its addresses 864 * Plugin notifies transport (aka testcase) about its addresses
824 */ 865 */
825void 866static void
826notify_address (void *cls, 867notify_address (void *cls,
827 const char *name, 868 const char *name,
828 const void *addr, 869 const void *addr,
@@ -881,11 +922,14 @@ notify_address (void *cls,
881} 922}
882 923
883static void 924static void
884plugin_env_session_end (void *cls, 925plugin_env_session_end (void *cls,
885 const struct GNUNET_PeerIdentity *peer, 926 const struct GNUNET_PeerIdentity *peer,
886 struct Session *session) 927 struct Session *session)
887{ 928{
888 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Pluging tells me: session %X to peer `%s' ended\n", session, GNUNET_i2s(peer)); 929 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
930 "Pluging tells me: session %X to peer `%s' ended\n",
931 session,
932 GNUNET_i2s(peer));
889} 933}
890 934
891 935
@@ -923,19 +967,24 @@ task_timeout (void *cls,
923 return; 967 return;
924} 968}
925 969
926static void pretty_printer_cb (void *cls, 970
927 const char *address) 971static void
972pretty_printer_cb (void *cls,
973 const char *address)
928{ 974{
929 if (NULL==address) 975 if (NULL==address)
930 return; 976 return;
931 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Plugin returned pretty address: `%s'\n",address); 977 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
978 "Plugin returned pretty address: `%s'\n",
979 address);
932 fail_pretty_printer_count++; 980 fail_pretty_printer_count++;
933} 981}
934 982
935/** 983/**
936 * Runs every single test to test the plugin 984 * Runs every single test to test the plugin
937 */ 985 */
938static void run_connection_tests( int phase , void * cls) 986static void
987run_connection_tests( int phase , void * cls)
939{ 988{
940 struct GNUNET_MessageHeader * msg; 989 struct GNUNET_MessageHeader * msg;
941 unsigned int size; 990 unsigned int size;
@@ -953,136 +1002,184 @@ static void run_connection_tests( int phase , void * cls)
953 buffer_out.len = 0; 1002 buffer_out.len = 0;
954 1003
955 if (test_no_ident.test_executed == GNUNET_NO) 1004 if (test_no_ident.test_executed == GNUNET_NO)
956 { 1005 {
957 /* Connecting to peer without identification */ 1006 /* Connecting to peer without identification */
958 char * ident = ""; 1007 const char * ident = "";
959 GNUNET_asprintf (&host_str, "%s://%s/%s",PROTOCOL_PREFIX, test_addr,ident); 1008 GNUNET_asprintf (&host_str,
960 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Connecting to peer without any peer identification.\n")); 1009 "%s://%s/%s",
961 test_no_ident.test_executed = GNUNET_YES; 1010 PROTOCOL_PREFIX,
962 send_data ( &test_no_ident, host_str); 1011 test_addr,ident);
963 GNUNET_free (host_str); 1012 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
964 return; 1013 _("Connecting to peer without any peer identification.\n"));
965 } 1014 test_no_ident.test_executed = GNUNET_YES;
1015 send_data ( &test_no_ident, host_str);
1016 GNUNET_free (host_str);
1017 return;
1018 }
966 if (test_too_short_ident.test_executed == GNUNET_NO) 1019 if (test_too_short_ident.test_executed == GNUNET_NO)
967 { 1020 {
968 char * ident = "AAAAAAAAAA"; 1021 const char * ident = "AAAAAAAAAA";
969 /* Connecting to peer with too short identification */ 1022 /* Connecting to peer with too short identification */
970 GNUNET_asprintf (&host_str, "%s://%s/%s",PROTOCOL_PREFIX,test_addr,ident); 1023 GNUNET_asprintf (&host_str,
971 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Connecting to peer with too short peer identification.\n")); 1024 "%s://%s/%s",
972 test_too_short_ident.test_executed = GNUNET_YES; 1025 PROTOCOL_PREFIX,
973 send_data ( &test_too_short_ident, host_str); 1026 test_addr,
974 GNUNET_free (host_str); 1027 ident);
975 return; 1028 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
976 } 1029 _("Connecting to peer with too short peer identification.\n"));
1030 test_too_short_ident.test_executed = GNUNET_YES;
1031 send_data ( &test_too_short_ident, host_str);
1032 GNUNET_free (host_str);
1033 return;
1034 }
977 1035
978 if (test_too_long_ident.test_executed == GNUNET_NO) 1036 if (test_too_long_ident.test_executed == GNUNET_NO)
979 { 1037 {
980 char * ident = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; 1038 const char * ident = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
981 1039
982 /* Connecting to peer with too long identification */ 1040 /* Connecting to peer with too long identification */
983 GNUNET_asprintf (&host_str, "%s://%s/%s",PROTOCOL_PREFIX, test_addr,ident); 1041 GNUNET_asprintf (&host_str, "%s://%s/%s",PROTOCOL_PREFIX, test_addr,ident);
984 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Connecting to peer with too long peer identification.\n")); 1042 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
985 test_too_long_ident.test_executed = GNUNET_YES; 1043 _("Connecting to peer with too long peer identification.\n"));
986 send_data ( &test_too_long_ident, host_str); 1044 test_too_long_ident.test_executed = GNUNET_YES;
987 GNUNET_free (host_str); 1045 send_data ( &test_too_long_ident, host_str);
988 return; 1046 GNUNET_free (host_str);
1047 return;
989 } 1048 }
990 if (test_valid_ident.test_executed == GNUNET_NO) 1049 if (test_valid_ident.test_executed == GNUNET_NO)
991 { 1050 {
992 struct GNUNET_CRYPTO_HashAsciiEncoded ident; 1051 struct GNUNET_CRYPTO_HashAsciiEncoded ident;
993 GNUNET_CRYPTO_hash_to_enc(&my_identity.hashPubKey,&ident); 1052 GNUNET_CRYPTO_hash_to_enc(&my_identity.hashPubKey,&ident);
994 GNUNET_asprintf (&host_str, "%s://%s/%s%s",PROTOCOL_PREFIX, test_addr,(char *) &ident,";0"); 1053 GNUNET_asprintf (&host_str,
995 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Connecting to peer with valid peer identification.\n")); 1054 "%s://%s/%s%s",
996 test_valid_ident.test_executed = GNUNET_YES; 1055 PROTOCOL_PREFIX,
997 send_data ( &test_valid_ident, host_str); 1056 test_addr,
998 GNUNET_free (host_str); 1057 (char *) &ident,
999 return; 1058 ";0");
1000 } 1059 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1060 _("Connecting to peer with valid peer identification.\n"));
1061 test_valid_ident.test_executed = GNUNET_YES;
1062 send_data ( &test_valid_ident, host_str);
1063 GNUNET_free (host_str);
1064 return;
1065 }
1001 } 1066 }
1002 if (phase==1) 1067 if (phase==1)
1003 {
1004 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "\nPhase 1: transmit data to all suggested addresses\n\n");
1005 /* Using one of the addresses the plugin proposed */
1006 GNUNET_assert (addr_head->addr != NULL);
1007
1008 struct Plugin_Address * tmp_addr;
1009 struct GNUNET_MessageHeader msg;
1010 char * tmp = GNUNET_malloc(sizeof(struct GNUNET_MessageHeader));
1011 char address[INET6_ADDRSTRLEN];
1012 unsigned int port;
1013 unsigned int type = 10;
1014
1015 msg.size=htons(sizeof(struct GNUNET_MessageHeader));
1016 tmp_addr = addr_head;
1017 /* send a message to all addresses advertised by plugin */
1018
1019 int count = 0;
1020 while (tmp_addr != NULL)
1021 { 1068 {
1022 if (tmp_addr->addrlen == (sizeof (struct IPv4HttpAddress))) 1069 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1023 { 1070 "\nPhase 1: transmit data to all suggested addresses\n\n");
1024 inet_ntop(AF_INET, (struct in_addr *) tmp_addr->addr,address,INET_ADDRSTRLEN); 1071 /* Using one of the addresses the plugin proposed */
1025 port = ntohs(((struct IPv4HttpAddress *) tmp_addr->addr)->u_port); 1072 GNUNET_assert (addr_head->addr != NULL);
1026 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Sending message to addres no. %u: `%s':%u\n", count,address, port); 1073
1027 } 1074 struct Plugin_Address * tmp_addr;
1028 if (tmp_addr->addrlen == (sizeof (struct IPv6HttpAddress))) 1075 struct GNUNET_MessageHeader msg;
1029 { 1076 char * tmp = GNUNET_malloc(sizeof(struct GNUNET_MessageHeader));
1030 inet_ntop(AF_INET6, (struct in6_addr *) tmp_addr->addr,address,INET6_ADDRSTRLEN); 1077 char address[INET6_ADDRSTRLEN];
1031 port = ntohs(((struct IPv6HttpAddress *) tmp_addr->addr)->u6_port); 1078 unsigned int port;
1032 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Sending message to addres no. %u: `%s':%u\n", count,address,port); 1079 unsigned int type = 10;
1033 } 1080
1034 msg.type=htons(type); 1081 msg.size=htons(sizeof(struct GNUNET_MessageHeader));
1035 memcpy(tmp,&msg,sizeof(struct GNUNET_MessageHeader)); 1082 tmp_addr = addr_head;
1036 api->send(api->cls, &my_identity, tmp, sizeof(struct GNUNET_MessageHeader), 0, TIMEOUT, NULL,tmp_addr->addr, tmp_addr->addrlen, GNUNET_YES, &task_send_cont, &fail_msgs_transmited_to_local_addrs); 1083 /* send a message to all addresses advertised by plugin */
1037 tmp_addr = tmp_addr->next; 1084
1038 1085 int count = 0;
1039 count ++; 1086 while (tmp_addr != NULL)
1040 type ++; 1087 {
1088 if (tmp_addr->addrlen == (sizeof (struct IPv4HttpAddress)))
1089 {
1090 inet_ntop(AF_INET, (struct in_addr *) tmp_addr->addr,address,INET_ADDRSTRLEN);
1091 port = ntohs(((struct IPv4HttpAddress *) tmp_addr->addr)->u_port);
1092 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1093 "Sending message to addres no. %u: `%s':%u\n",
1094 count,
1095 address,
1096 port);
1097 }
1098 if (tmp_addr->addrlen == (sizeof (struct IPv6HttpAddress)))
1099 {
1100 inet_ntop(AF_INET6, (struct in6_addr *) tmp_addr->addr,address,INET6_ADDRSTRLEN);
1101 port = ntohs(((struct IPv6HttpAddress *) tmp_addr->addr)->u6_port);
1102 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1103 "Sending message to addres no. %u: `%s':%u\n",
1104 count,
1105 address,
1106 port);
1107 }
1108 msg.type=htons(type);
1109 memcpy(tmp,&msg,sizeof(struct GNUNET_MessageHeader));
1110 api->send(api->cls,
1111 &my_identity,
1112 tmp, sizeof(struct GNUNET_MessageHeader),
1113 0, TIMEOUT,
1114 NULL,
1115 tmp_addr->addr, tmp_addr->addrlen,
1116 GNUNET_YES,
1117 &task_send_cont, &fail_msgs_transmited_to_local_addrs);
1118 tmp_addr = tmp_addr->next;
1119 count++;
1120 type++;
1121 }
1122 GNUNET_free(tmp);
1123 return;
1041 } 1124 }
1042 GNUNET_free(tmp);
1043 return;
1044 }
1045 1125
1046 if (phase==2) 1126 if (phase==2)
1047 { 1127 {
1048 struct Session * session = cls; 1128 struct Session * session = cls;
1049 msg = GNUNET_malloc (sizeof(struct GNUNET_MessageHeader)); 1129 msg = GNUNET_malloc (sizeof(struct GNUNET_MessageHeader));
1050 1130
1051 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Phase 2: session selection\n\n"); 1131 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1052 size = sizeof(struct GNUNET_MessageHeader); 1132 "Phase 2: session selection\n\n");
1053 msg->size=htons(size); 1133 size = sizeof(struct GNUNET_MessageHeader);
1054 msg->type = htons(20); 1134 msg->size=htons(size);
1055 api->send(api->cls, &my_identity, (const char *) msg, size, 0, TIMEOUT, NULL, NULL, 0, GNUNET_NO, &task_send_cont, NULL); 1135 msg->type = htons(20);
1056 1136 api->send(api->cls,
1057 msg->type = htons(21); 1137 &my_identity,
1058 api->send(api->cls, &my_identity, (const char *) msg, size, 0, TIMEOUT, NULL, NULL, 0, GNUNET_SYSERR, &task_send_cont, NULL); 1138 (const char *) msg, size,
1059 1139 0, TIMEOUT, NULL, NULL, 0, GNUNET_NO,
1060 /* answer on session*/ 1140 &task_send_cont, NULL);
1061 size = sizeof( struct GNUNET_MessageHeader); 1141
1062 msg->size = htons(size); 1142 msg->type = htons(21);
1063 msg->type = htons(22); 1143 api->send(api->cls,
1064 api->send(api->cls, &my_identity, (const char *) msg, size, 0, TIMEOUT, session, NULL, 0, GNUNET_SYSERR, &task_send_cont, NULL); 1144 &my_identity,
1065 1145 (const char *) msg, size,
1066 GNUNET_free(msg); 1146 0, TIMEOUT, NULL, NULL, 0, GNUNET_SYSERR,
1067 1147 &task_send_cont, NULL);
1068 /* answer on session with big message not fitting in mhd send buffer*/ 1148
1069 size = GNUNET_SERVER_MAX_MESSAGE_SIZE-1; 1149 /* answer on session*/
1070 msg = GNUNET_malloc (size); 1150 size = sizeof( struct GNUNET_MessageHeader);
1071 msg->size=htons(size); 1151 msg->size = htons(size);
1072 msg->type = htons(23); 1152 msg->type = htons(22);
1073 api->send(api->cls, &my_identity, (const char *) msg, size, 0, TIMEOUT, session, NULL, 0, GNUNET_NO, &task_send_cont, NULL); 1153 api->send(api->cls,
1074 GNUNET_free(msg); 1154 &my_identity,
1075 return; 1155 (const char *) msg, size,
1076 } 1156 0, TIMEOUT, session, NULL, 0, GNUNET_SYSERR,
1077 1157 &task_send_cont, NULL);
1158 GNUNET_free(msg);
1159
1160 /* answer on session with big message not fitting in mhd send buffer*/
1161 size = GNUNET_SERVER_MAX_MESSAGE_SIZE-1;
1162 msg = GNUNET_malloc (size);
1163 msg->size=htons(size);
1164 msg->type = htons(23);
1165 api->send(api->cls,
1166 &my_identity,
1167 (const char *) msg, size,
1168 0, TIMEOUT, session, NULL, 0, GNUNET_NO,
1169 &task_send_cont, NULL);
1170 GNUNET_free(msg);
1171 return;
1172 }
1173
1078 if (phase==3) 1174 if (phase==3)
1079 { 1175 {
1080 1176
1081 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Phase 3: send multiple or big messages after disconnect\n\n"); 1177 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1178 "Phase 3: send multiple or big messages after disconnect\n\n");
1082 /* disconnect from peer, so new connections are created */ 1179 /* disconnect from peer, so new connections are created */
1083 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Disconnect from peer: `%s'\n", GNUNET_i2s(&my_identity)); 1180 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Disconnect from peer: `%s'\n", GNUNET_i2s(&my_identity));
1084 api->disconnect(api->cls, &my_identity); 1181 api->disconnect(api->cls, &my_identity);
1085 1182
1086 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Phase 3: sending messages\n"); 1183 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Phase 3: sending messages\n");
1087 /* send a multiple GNUNET_messages at a time*/ 1184 /* send a multiple GNUNET_messages at a time*/
1088 size = 2 * sizeof(struct GNUNET_MessageHeader); 1185 size = 2 * sizeof(struct GNUNET_MessageHeader);
@@ -1092,7 +1189,13 @@ static void run_connection_tests( int phase , void * cls)
1092 struct GNUNET_MessageHeader * msg2 = &msg[2]; 1189 struct GNUNET_MessageHeader * msg2 = &msg[2];
1093 msg2->size = htons(2 * sizeof(struct GNUNET_MessageHeader)); 1190 msg2->size = htons(2 * sizeof(struct GNUNET_MessageHeader));
1094 msg2->type = htons(31); 1191 msg2->type = htons(31);
1095 api->send(api->cls, &my_identity, (const char *) msg, 4 * sizeof(struct GNUNET_MessageHeader), 0, TIMEOUT, NULL,addr_head->addr, addr_head->addrlen, GNUNET_NO, &task_send_cont, &fail_multiple_msgs_in_transmission); 1192 api->send(api->cls,
1193 &my_identity,
1194 (const char *) msg, 4 * sizeof(struct GNUNET_MessageHeader),
1195 0, TIMEOUT, NULL,
1196 addr_head->addr, addr_head->addrlen,
1197 GNUNET_NO,
1198 &task_send_cont, &fail_multiple_msgs_in_transmission);
1096 GNUNET_free(msg); 1199 GNUNET_free(msg);
1097 /* send a message with size GNUNET_SERVER_MAX_MESSAGE_SIZE-1 */ 1200 /* send a message with size GNUNET_SERVER_MAX_MESSAGE_SIZE-1 */
1098 1201
@@ -1100,9 +1203,16 @@ static void run_connection_tests( int phase , void * cls)
1100 msg = GNUNET_malloc(size); 1203 msg = GNUNET_malloc(size);
1101 msg->size = htons(size); 1204 msg->size = htons(size);
1102 msg->type = htons(32); 1205 msg->type = htons(32);
1103 api->send(api->cls, &my_identity, (const char *) msg, size, 0, TIMEOUT, NULL,addr_head->addr, addr_head->addrlen, GNUNET_NO, &task_send_cont, &fail_msg_transmited_max_size); 1206 api->send(api->cls,
1207 &my_identity,
1208 (const char *) msg, size,
1209 0, TIMEOUT, NULL,
1210 addr_head->addr, addr_head->addrlen,
1211 GNUNET_NO,
1212 &task_send_cont, &fail_msg_transmited_max_size);
1104 GNUNET_free(msg); 1213 GNUNET_free(msg);
1105 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"No more tests to run\n"); 1214 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1215 "No more tests to run\n");
1106 } 1216 }
1107} 1217}
1108 1218
@@ -1286,10 +1396,7 @@ run (void *cls,
1286 1396
1287 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Phase 0\n\n")); 1397 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Phase 0\n\n"));
1288 run_connection_tests(0, NULL); 1398 run_connection_tests(0, NULL);
1289
1290 /* testing finished */ 1399 /* testing finished */
1291
1292 return;
1293} 1400}
1294 1401
1295 1402
@@ -1303,7 +1410,6 @@ run (void *cls,
1303int 1410int
1304main (int argc, char *const *argv) 1411main (int argc, char *const *argv)
1305{ 1412{
1306
1307 static struct GNUNET_GETOPT_CommandLineOption options[] = { 1413 static struct GNUNET_GETOPT_CommandLineOption options[] = {
1308 GNUNET_GETOPT_OPTION_END 1414 GNUNET_GETOPT_OPTION_END
1309 }; 1415 };
diff --git a/src/transport/test_quota_compliance.c b/src/transport/test_quota_compliance.c
index 1f4d21fc8..48a78f19d 100644
--- a/src/transport/test_quota_compliance.c
+++ b/src/transport/test_quota_compliance.c
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 (C) 2009, 2010 Christian Grothoff (and other contributing authors) 3 (C) 2009, 2010, 2011 Christian Grothoff (and other contributing authors)
4 4
5 GNUnet is free software; you can redistribute it and/or modify 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 6 it under the terms of the GNU General Public License as published
@@ -146,6 +146,7 @@ static int is_asymmetric_recv_constant;
146static struct GNUNET_TIME_Absolute start_time; 146static struct GNUNET_TIME_Absolute start_time;
147 147
148static GNUNET_SCHEDULER_TaskIdentifier die_task; 148static GNUNET_SCHEDULER_TaskIdentifier die_task;
149static GNUNET_SCHEDULER_TaskIdentifier tct;
149static GNUNET_SCHEDULER_TaskIdentifier measurement_task; 150static GNUNET_SCHEDULER_TaskIdentifier measurement_task;
150static GNUNET_SCHEDULER_TaskIdentifier measurement_counter_task; 151static GNUNET_SCHEDULER_TaskIdentifier measurement_counter_task;
151 152
@@ -154,33 +155,27 @@ static struct GNUNET_TRANSPORT_TransmitHandle * transmit_handle;
154#define OKPP do { ok++; } while (0) 155#define OKPP do { ok++; } while (0)
155 156
156 157
157
158static void
159end_send ()
160{
161
162}
163
164static void 158static void
165end () 159end ()
166{ 160{
167 GNUNET_SCHEDULER_cancel (die_task); 161 GNUNET_SCHEDULER_cancel (die_task);
168 die_task = GNUNET_SCHEDULER_NO_TASK; 162 die_task = GNUNET_SCHEDULER_NO_TASK;
169 163
170 if (measurement_task != GNUNET_SCHEDULER_NO_TASK) 164 if (measurement_task != GNUNET_SCHEDULER_NO_TASK)
171 { 165 {
172 GNUNET_SCHEDULER_cancel (measurement_task); 166 GNUNET_SCHEDULER_cancel (measurement_task);
173 measurement_task = GNUNET_SCHEDULER_NO_TASK; 167 measurement_task = GNUNET_SCHEDULER_NO_TASK;
174 } 168 }
175 if (measurement_counter_task != GNUNET_SCHEDULER_NO_TASK) 169 if (measurement_counter_task != GNUNET_SCHEDULER_NO_TASK)
176 { 170 {
177 GNUNET_SCHEDULER_cancel (measurement_counter_task); 171 GNUNET_SCHEDULER_cancel (measurement_counter_task);
178 measurement_counter_task = GNUNET_SCHEDULER_NO_TASK; 172 measurement_counter_task = GNUNET_SCHEDULER_NO_TASK;
179 } 173 }
180 fprintf(stderr,"\n"); 174 fprintf(stderr,"\n");
181 GNUNET_SCHEDULER_shutdown (); 175 GNUNET_SCHEDULER_shutdown ();
182#if DEBUG_CONNECTIONS 176#if DEBUG_CONNECTIONS
183 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting from transports!\n"); 177 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
178 "Disconnecting from transports!\n");
184#endif 179#endif
185 GNUNET_TRANSPORT_disconnect (p1.th); 180 GNUNET_TRANSPORT_disconnect (p1.th);
186 GNUNET_TRANSPORT_disconnect (p2.th); 181 GNUNET_TRANSPORT_disconnect (p2.th);
@@ -213,19 +208,24 @@ end_badly (void *cls,
213{ 208{
214 if (measurement_task != GNUNET_SCHEDULER_NO_TASK) 209 if (measurement_task != GNUNET_SCHEDULER_NO_TASK)
215 { 210 {
216 GNUNET_SCHEDULER_cancel (measurement_task); 211 GNUNET_SCHEDULER_cancel (measurement_task);
217 measurement_task = GNUNET_SCHEDULER_NO_TASK; 212 measurement_task = GNUNET_SCHEDULER_NO_TASK;
218 } 213 }
219 if (measurement_counter_task != GNUNET_SCHEDULER_NO_TASK) 214 if (measurement_counter_task != GNUNET_SCHEDULER_NO_TASK)
220 { 215 {
221 GNUNET_SCHEDULER_cancel (measurement_counter_task); 216 GNUNET_SCHEDULER_cancel (measurement_counter_task);
222 measurement_counter_task = GNUNET_SCHEDULER_NO_TASK; 217 measurement_counter_task = GNUNET_SCHEDULER_NO_TASK;
223 } 218 }
224 GNUNET_break (0); 219 GNUNET_break (0);
220 if (GNUNET_SCHEDULER_NO_TASK != tct)
221 {
222 GNUNET_SCHEDULER_cancel (tct);
223 tct = GNUNET_SCHEDULER_NO_TASK;
224 }
225 if (p1.th != NULL) 225 if (p1.th != NULL)
226 GNUNET_TRANSPORT_disconnect (p1.th); 226 GNUNET_TRANSPORT_disconnect (p1.th);
227 if (p2.th != NULL) 227 if (p2.th != NULL)
228 GNUNET_TRANSPORT_disconnect (p2.th); 228 GNUNET_TRANSPORT_disconnect (p2.th);
229 ok = 1; 229 ok = 1;
230} 230}
231 231
@@ -235,6 +235,7 @@ struct TestMessage
235 uint32_t num; 235 uint32_t num;
236}; 236};
237 237
238
238static unsigned int 239static unsigned int
239get_size () 240get_size ()
240{ 241{
@@ -271,6 +272,7 @@ notify_receive_new (void *cls,
271 last_msg_recv = ntohl (hdr->num); 272 last_msg_recv = ntohl (hdr->num);
272} 273}
273 274
275
274static size_t 276static size_t
275notify_ready (void *cls, size_t size, void *buf) 277notify_ready (void *cls, size_t size, void *buf)
276{ 278{
@@ -280,23 +282,19 @@ notify_ready (void *cls, size_t size, void *buf)
280 unsigned int ret; 282 unsigned int ret;
281 283
282 transmit_handle = NULL; 284 transmit_handle = NULL;
283
284 if (measurement_task == GNUNET_SCHEDULER_NO_TASK) 285 if (measurement_task == GNUNET_SCHEDULER_NO_TASK)
285 return 0; 286 return 0;
286 287
287 if (buf == NULL) 288 if (buf == NULL)
288 { 289 {
289 ok = 42; 290 ok = 42;
290 return 0; 291 return 0;
291 } 292 }
292
293 if (measurement_running != GNUNET_YES) 293 if (measurement_running != GNUNET_YES)
294 { 294 {
295 send_running = GNUNET_NO; 295 send_running = GNUNET_NO;
296 end_send(); 296 return 0;
297 return 0; 297 }
298 }
299
300 send_running = GNUNET_YES; 298 send_running = GNUNET_YES;
301 ret = 0; 299 ret = 0;
302 s = get_size (); 300 s = get_size ();
@@ -338,26 +336,28 @@ notify_ready (void *cls, size_t size, void *buf)
338 return ret; 336 return ret;
339} 337}
340 338
341static void measure (unsigned long long quota_p1, unsigned long long quota_p2 );
342 339
343static void measurement_counter 340static void
344 (void *cls, 341measure (unsigned long long quota_p1, unsigned long long quota_p2);
345 const struct GNUNET_SCHEDULER_TaskContext *tc) 342
343static void
344measurement_counter (void *cls,
345 const struct GNUNET_SCHEDULER_TaskContext *tc)
346{ 346{
347 measurement_counter_task = GNUNET_SCHEDULER_NO_TASK; 347 measurement_counter_task = GNUNET_SCHEDULER_NO_TASK;
348
349 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) 348 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
350 return; 349 return;
351 350
352 fprintf(stderr,"."); 351 fprintf(stderr,".");
353 measurement_counter_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, 352 measurement_counter_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
354 &measurement_counter, 353 &measurement_counter,
355 NULL); 354 NULL);
356} 355}
357 356
357
358static void 358static void
359measurement_end (void *cls, 359measurement_end (void *cls,
360 const struct GNUNET_SCHEDULER_TaskContext *tc) 360 const struct GNUNET_SCHEDULER_TaskContext *tc)
361{ 361{
362 static int strike_counter; 362 static int strike_counter;
363 static int failed_measurement_counter = 1; 363 static int failed_measurement_counter = 1;
@@ -366,219 +366,275 @@ measurement_end (void *cls,
366 366
367 measurement_task = GNUNET_SCHEDULER_NO_TASK; 367 measurement_task = GNUNET_SCHEDULER_NO_TASK;
368 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) 368 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
369 return; 369 return;
370 370
371 measurement_running = GNUNET_NO; 371 measurement_running = GNUNET_NO;
372 struct GNUNET_TIME_Relative duration = GNUNET_TIME_absolute_get_difference(start_time, GNUNET_TIME_absolute_get()); 372 struct GNUNET_TIME_Relative duration
373 = GNUNET_TIME_absolute_get_difference(start_time, GNUNET_TIME_absolute_get());
373 374
374 375
375 if (measurement_counter_task != GNUNET_SCHEDULER_NO_TASK) 376 if (measurement_counter_task != GNUNET_SCHEDULER_NO_TASK)
376 { 377 {
377 GNUNET_SCHEDULER_cancel (measurement_counter_task); 378 GNUNET_SCHEDULER_cancel (measurement_counter_task);
378 measurement_counter_task = GNUNET_SCHEDULER_NO_TASK; 379 measurement_counter_task = GNUNET_SCHEDULER_NO_TASK;
379 } 380 }
380 381
381 if (transmit_handle != NULL) 382 if (transmit_handle != NULL)
382 { 383 {
383 GNUNET_TRANSPORT_notify_transmit_ready_cancel(transmit_handle); 384 GNUNET_TRANSPORT_notify_transmit_ready_cancel(transmit_handle);
384 transmit_handle = NULL; 385 transmit_handle = NULL;
385 } 386 }
386 387
387 if (current_quota_p1 < current_quota_p2) 388 if (current_quota_p1 < current_quota_p2)
388 quota_allowed = current_quota_p1; 389 quota_allowed = current_quota_p1;
389 else 390 else
390 quota_allowed = current_quota_p2; 391 quota_allowed = current_quota_p2;
391 392
392 393
393 if (MEASUREMENT_SOFT_LIMIT > (quota_allowed/3)) 394 if (MEASUREMENT_SOFT_LIMIT > (quota_allowed/3))
394 delta = MEASUREMENT_SOFT_LIMIT; 395 delta = MEASUREMENT_SOFT_LIMIT;
395 else 396 else
396 delta = (quota_allowed/3); 397 delta = (quota_allowed/3);
397 398
398 /* Throughput is far too slow. This is to prevent the test to exit with success when throughput is 0 */ 399 /* 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) 400 if ((total_bytes_sent/(duration.rel_value / 1000)) < 100)
400 { 401 {
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));
411 ok = 1;
412 failed_measurement_counter--;
413 if (failed_measurement_counter < 0)
414 {
401 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 415 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
402 "\nQuota compliance failed: \n"\ 416 "\nQuota measurement failed and no free strike: %i\n",
403 "Hard quota limit allowed: %10llu kB/s (%llu B/s)\n"\ 417 failed_measurement_counter);
404 "Soft quota limit allowed: %10llu kB/s (%llu B/s)\n"\ 418 end();
405 "Throughput : %10llu kB/s (%llu B/s)\n", 419 return;
406 (quota_allowed / (1024)), quota_allowed, 420 }
407 ((quota_allowed+delta) / (1024)), quota_allowed+delta, 421 else
408 (total_bytes_sent/(duration.rel_value / 1000)/1024), 422 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
409 total_bytes_sent/(duration.rel_value / 1000)); 423 "\nQuota measurement failed and %i free strikes\n",
410 ok = 1; 424 failed_measurement_counter);
411 failed_measurement_counter--; 425 }
412 if (failed_measurement_counter < 0) 426
413 {
414 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
415 "\nQuota measurement failed and no free strike: %i\n",failed_measurement_counter);
416 end();
417 return;
418 }
419 else
420 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
421 "\nQuota measurement failed and %i free strikes\n",failed_measurement_counter);
422 }
423
424 /* Throughput is bigger than allowed quota + some extra*/ 427 /* Throughput is bigger than allowed quota + some extra*/
425 if ((total_bytes_sent/(duration.rel_value / 1000)) > (quota_allowed + delta)) 428 if ((total_bytes_sent/(duration.rel_value / 1000)) > (quota_allowed + delta))
426 { 429 {
430 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
431 "\nQuota compliance failed: \n" \
432 "Hard quota limit allowed: %10llu kB/s (%llu B/s)\n" \
433 "Soft quota limit allowed: %10llu kB/s (%llu B/s)\n" \
434 "Throughput : %10llu kB/s (%llu B/s)\n",
435 (quota_allowed / (1024)), quota_allowed,
436 ((quota_allowed+delta) / (1024)), quota_allowed+delta,
437 (total_bytes_sent/(duration.rel_value / 1000)/1024),
438 total_bytes_sent/(duration.rel_value / 1000));
439 ok = 1;
440 failed_measurement_counter--;
441 if (failed_measurement_counter < 0)
442 {
427 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 443 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
428 "\nQuota compliance failed: \n"\ 444 "\nQuota measurement failed and no free strike: %i\n",failed_measurement_counter);
429 "Hard quota limit allowed: %10llu kB/s (%llu B/s)\n"\ 445 end();
430 "Soft quota limit allowed: %10llu kB/s (%llu B/s)\n"\ 446 return;
431 "Throughput : %10llu kB/s (%llu B/s)\n", 447 }
432 (quota_allowed / (1024)), quota_allowed, 448 else
433 ((quota_allowed+delta) / (1024)), quota_allowed+delta, 449 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
434 (total_bytes_sent/(duration.rel_value / 1000)/1024), 450 "\nQuota measurement failed and %i free strikes\n",failed_measurement_counter);
435 total_bytes_sent/(duration.rel_value / 1000)); 451 }
436 ok = 1;
437 failed_measurement_counter--;
438 if (failed_measurement_counter < 0)
439 {
440 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
441 "\nQuota measurement failed and no free strike: %i\n",failed_measurement_counter);
442 end();
443 return;
444 }
445 else
446 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
447 "\nQuota measurement failed and %i free strikes\n",failed_measurement_counter);
448 }
449 else 452 else
450 { 453 {
451 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 454 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
452 "\nQuota compliance ok: \n"\ 455 "\nQuota compliance ok: \n" \
453 "Quota allowed: %10llu kB/s\n"\ 456 "Quota allowed: %10llu kB/s\n" \
454 "Throughput : %10llu kB/s\n", (quota_allowed / (1024)) , (total_bytes_sent/(duration.rel_value / 1000)/1024)); 457 "Throughput : %10llu kB/s\n",
455 if (failed_measurement_counter < 2) 458 (quota_allowed / (1024)),
456 failed_measurement_counter++; 459 (total_bytes_sent/(duration.rel_value / 1000)/1024));
457 ok = 0; 460 if (failed_measurement_counter < 2)
458 } 461 failed_measurement_counter++;
459 462 ok = 0;
463 }
464
460 if ((quota_allowed) > (2 *(total_bytes_sent/(duration.rel_value / 1000)))) 465 if ((quota_allowed) > (2 *(total_bytes_sent/(duration.rel_value / 1000))))
461 { 466 {
462 if (failed_measurement_counter < 2) 467 if (failed_measurement_counter < 2)
463 failed_measurement_counter++; 468 failed_measurement_counter++;
464 if (strike_counter == 2) 469 if (strike_counter == 2)
465 { 470 {
466 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 471 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
467 "Maximum transmission rate reached, stopping test\n"); 472 "Maximum transmission rate reached, stopping test\n");
468 end();
469 return;
470 }
471 }
472 else
473 {
474 strike_counter = 0;
475 }
476
477 if (quota_allowed == MEASUREMENT_MAX_QUOTA)
478 {
479 end(); 473 end();
480 return; 474 return;
481 } 475 }
476 }
477 else
478 {
479 strike_counter = 0;
480 }
481
482 if (quota_allowed == MEASUREMENT_MAX_QUOTA)
483 {
484 end();
485 return;
486 }
482 if (is_asymmetric_send_constant == GNUNET_YES) 487 if (is_asymmetric_send_constant == GNUNET_YES)
483 { 488 {
484 if ((quota_allowed * 2) < MEASUREMENT_MAX_QUOTA) 489 if ((quota_allowed * 2) < MEASUREMENT_MAX_QUOTA)
485 measure (current_quota_p1 * 2, MEASUREMENT_MAX_QUOTA); 490 measure (current_quota_p1 * 2, MEASUREMENT_MAX_QUOTA);
486 else 491 else
487 measure (MEASUREMENT_MAX_QUOTA, MEASUREMENT_MAX_QUOTA); 492 measure (MEASUREMENT_MAX_QUOTA, MEASUREMENT_MAX_QUOTA);
488 } 493 }
489 else if (is_asymmetric_recv_constant == GNUNET_YES) 494 else if (is_asymmetric_recv_constant == GNUNET_YES)
490 { 495 {
491 if ((quota_allowed * 2) < MEASUREMENT_MAX_QUOTA) 496 if ((quota_allowed * 2) < MEASUREMENT_MAX_QUOTA)
492 measure (MEASUREMENT_MAX_QUOTA, current_quota_p2 * 2); 497 measure (MEASUREMENT_MAX_QUOTA, current_quota_p2 * 2);
493 else 498 else
494 measure (MEASUREMENT_MAX_QUOTA, MEASUREMENT_MAX_QUOTA); 499 measure (MEASUREMENT_MAX_QUOTA, MEASUREMENT_MAX_QUOTA);
495 } 500 }
496 else 501 else
497 { 502 {
498 if ((quota_allowed * 2) < MEASUREMENT_MAX_QUOTA) 503 if ((quota_allowed * 2) < MEASUREMENT_MAX_QUOTA)
499 measure ((current_quota_p1) * 2, (current_quota_p2) * 2); 504 measure ((current_quota_p1) * 2, (current_quota_p2) * 2);
500 else 505 else
501 measure (MEASUREMENT_MAX_QUOTA, MEASUREMENT_MAX_QUOTA); 506 measure (MEASUREMENT_MAX_QUOTA, MEASUREMENT_MAX_QUOTA);
502 } 507 }
503} 508}
504 509
505static void measure (unsigned long long quota_p1, unsigned long long quota_p2 ) 510static void
511measure (unsigned long long quota_p1, unsigned long long quota_p2)
506{ 512{
507 current_quota_p1 = quota_p1; 513 current_quota_p1 = quota_p1;
508 current_quota_p2 = quota_p2; 514 current_quota_p2 = quota_p2;
509#if VERBOSE 515#if VERBOSE
510 if ((is_asymmetric_send_constant == GNUNET_YES) || (is_asymmetric_recv_constant == GNUNET_YES)) 516 if ((is_asymmetric_send_constant == GNUNET_YES) || (is_asymmetric_recv_constant == GNUNET_YES))
511 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 517 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); 518 "Starting transport level measurement for %u seconds, receiving peer quota %llu kB/s, sending peer quota %llu kB/s\n",
519 MEASUREMENT_INTERVALL.rel_value / 1000 ,
520 current_quota_p1 / 1024,
521 current_quota_p2 / 1024);
513 else 522 else
514 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 523 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); 524 "Starting transport level measurement for %u seconds, symmetric quota %llu kB/s\n",
516 525 MEASUREMENT_INTERVALL.rel_value / 1000,
526 current_quota_p2 / 1024);
527
517#endif 528#endif
518 GNUNET_TRANSPORT_set_quota (p1.th, 529 GNUNET_TRANSPORT_set_quota (p1.th,
519 &p2.id, 530 &p2.id,
520 GNUNET_BANDWIDTH_value_init (current_quota_p1), 531 GNUNET_BANDWIDTH_value_init (current_quota_p1),
521 GNUNET_BANDWIDTH_value_init (current_quota_p1)); 532 GNUNET_BANDWIDTH_value_init (current_quota_p1));
522 GNUNET_TRANSPORT_set_quota (p2.th, 533 GNUNET_TRANSPORT_set_quota (p2.th,
523 &p1.id, 534 &p1.id,
524 GNUNET_BANDWIDTH_value_init (current_quota_p2), 535 GNUNET_BANDWIDTH_value_init (current_quota_p2),
525 GNUNET_BANDWIDTH_value_init (current_quota_p2)); 536 GNUNET_BANDWIDTH_value_init (current_quota_p2));
526 GNUNET_SCHEDULER_cancel (die_task); 537 GNUNET_SCHEDULER_cancel (die_task);
527 die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, 538 die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT,
528 &end_badly, 539 &end_badly,
529 NULL); 540 NULL);
530 if (measurement_counter_task != GNUNET_SCHEDULER_NO_TASK) 541 if (measurement_counter_task != GNUNET_SCHEDULER_NO_TASK)
531 GNUNET_SCHEDULER_cancel (measurement_counter_task); 542 GNUNET_SCHEDULER_cancel (measurement_counter_task);
532 measurement_counter_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, 543 measurement_counter_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
533 &measurement_counter, 544 &measurement_counter,
534 NULL); 545 NULL);
535 measurement_task = GNUNET_SCHEDULER_add_delayed (MEASUREMENT_INTERVALL, 546 measurement_task = GNUNET_SCHEDULER_add_delayed (MEASUREMENT_INTERVALL,
536 &measurement_end, 547 &measurement_end,
537 NULL); 548 NULL);
538 total_bytes_sent = 0; 549 total_bytes_sent = 0;
539 last_msg_sent = 0; 550 last_msg_sent = 0;
540 last_msg_recv = 0; 551 last_msg_recv = 0;
541 measurement_running = GNUNET_YES; 552 measurement_running = GNUNET_YES;
542 start_time = GNUNET_TIME_absolute_get (); 553 start_time = GNUNET_TIME_absolute_get ();
543 554
544 if (transmit_handle != NULL) 555 if (transmit_handle != NULL)
545 GNUNET_TRANSPORT_notify_transmit_ready_cancel(transmit_handle); 556 GNUNET_TRANSPORT_notify_transmit_ready_cancel(transmit_handle);
546 transmit_handle = GNUNET_TRANSPORT_notify_transmit_ready (p2.th, 557 transmit_handle = GNUNET_TRANSPORT_notify_transmit_ready (p2.th,
547 &p1.id, 558 &p1.id,
548 get_size (), 0, SEND_TIMEOUT, 559 get_size (), 0, SEND_TIMEOUT,
549 &notify_ready, 560 &notify_ready,
550 NULL); 561 NULL);
562}
563
564
565static void
566exchange_hello_last (void *cls,
567 const struct GNUNET_MessageHeader *message)
568{
569 struct PeerContext *me = cls;
570
571 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
572 "Exchanging HELLO of size %d with peer (%s)!\n",
573 (int) GNUNET_HELLO_size((const struct GNUNET_HELLO_Message *)message),
574 GNUNET_i2s (&me->id));
575 GNUNET_assert (message != NULL);
576 GNUNET_assert (GNUNET_OK ==
577 GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *)
578 message, &me->id));
579 GNUNET_TRANSPORT_offer_hello (p1.th, message, NULL, NULL);
580}
581
582
583
584static void
585exchange_hello (void *cls,
586 const struct GNUNET_MessageHeader *message)
587{
588 struct PeerContext *me = cls;
589
590 GNUNET_assert (message != NULL);
591 GNUNET_assert (GNUNET_OK ==
592 GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *)
593 message, &me->id));
594 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
595 "Exchanging HELLO of size %d from peer %s!\n",
596 (int) GNUNET_HELLO_size((const struct GNUNET_HELLO_Message *)message),
597 GNUNET_i2s (&me->id));
598 GNUNET_TRANSPORT_offer_hello (p2.th, message, NULL, NULL);
551} 599}
552 600
601
553static void 602static void
554notify_connect (void *cls, 603notify_connect (void *cls,
555 const struct GNUNET_PeerIdentity *peer, 604 const struct GNUNET_PeerIdentity *peer,
556 const struct GNUNET_TRANSPORT_ATS_Information *ats, uint32_t ats_count) 605 const struct GNUNET_TRANSPORT_ATS_Information *ats, uint32_t ats_count)
557{ 606{
558 if (cls == &p1) 607 connected++;
608 if (cls == &p1)
559 { 609 {
560#if DEBUG_CONNECTIONS 610#if DEBUG_CONNECTIONS
561 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 611 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
562 "Peer 1 `%4s' connected to us (%p)!\n", GNUNET_i2s (peer), cls); 612 "Peer 1 `%4s' connected to us (%p)!\n",
613 GNUNET_i2s (peer),
614 cls);
563#endif 615#endif
564 connected++;
565 } 616 }
566 else 617 else
567 { 618 {
568#if DEBUG_CONNECTIONS 619#if DEBUG_CONNECTIONS
569 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 620 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
570 "Peer 2 `%4s' connected to us (%p)!\n", GNUNET_i2s (peer), cls); 621 "Peer 2 `%4s' connected to us (%p)!\n",
622 GNUNET_i2s (peer),
623 cls);
571#endif 624#endif
572 connected++;
573 } 625 }
574 if (connected == 2) 626 if (connected == 2)
575 { 627 {
576 if (is_asymmetric_send_constant == GNUNET_YES) 628 GNUNET_SCHEDULER_cancel (tct);
577 measure (MEASUREMENT_MIN_QUOTA, MEASUREMENT_MAX_QUOTA); 629 tct = GNUNET_SCHEDULER_NO_TASK;
578 else if (is_asymmetric_recv_constant == GNUNET_YES) 630 GNUNET_TRANSPORT_get_hello_cancel (p2.th, &exchange_hello_last, &p2);
579 measure (MEASUREMENT_MAX_QUOTA, MEASUREMENT_MIN_QUOTA); 631 GNUNET_TRANSPORT_get_hello_cancel (p1.th, &exchange_hello, &p1);
580 else 632 if (is_asymmetric_send_constant == GNUNET_YES)
581 measure (MEASUREMENT_MIN_QUOTA, MEASUREMENT_MIN_QUOTA); 633 measure (MEASUREMENT_MIN_QUOTA, MEASUREMENT_MAX_QUOTA);
634 else if (is_asymmetric_recv_constant == GNUNET_YES)
635 measure (MEASUREMENT_MAX_QUOTA, MEASUREMENT_MIN_QUOTA);
636 else
637 measure (MEASUREMENT_MIN_QUOTA, MEASUREMENT_MIN_QUOTA);
582 } 638 }
583} 639}
584 640
@@ -586,6 +642,7 @@ notify_connect (void *cls,
586static void 642static void
587notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) 643notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
588{ 644{
645 connected--;
589#if DEBUG_CONNECTIONS 646#if DEBUG_CONNECTIONS
590 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 647 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
591 "Peer `%4s' disconnected (%p)!\n", 648 "Peer `%4s' disconnected (%p)!\n",
@@ -617,56 +674,24 @@ setup_peer (struct PeerContext *p, const char *cfgname)
617 GNUNET_assert (p->th != NULL); 674 GNUNET_assert (p->th != NULL);
618} 675}
619 676
620static size_t
621notify_ready_connect (void *cls, size_t size, void *buf)
622{
623 return 0;
624}
625 677
626static void 678static void
627exchange_hello_last (void *cls, 679try_connect (void *cls,
628 const struct GNUNET_MessageHeader *message) 680 const struct GNUNET_SCHEDULER_TaskContext *tc)
629{ 681{
630 struct PeerContext *me = cls; 682 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
631 683 "Asking peers to connect...\n");
632 GNUNET_TRANSPORT_get_hello_cancel (p2.th, &exchange_hello_last, me); 684 GNUNET_TRANSPORT_try_connect (p2.th,
633 685 &p1.id);
634 GNUNET_assert (ok >= 3); 686 GNUNET_TRANSPORT_try_connect (p1.th,
635 OKPP; 687 &p2.id);
636 GNUNET_assert (message != NULL); 688 tct = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
637 GNUNET_assert (GNUNET_OK == 689 &try_connect,
638 GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *) 690 NULL);
639 message, &me->id));
640
641 GNUNET_assert(NULL != (transmit_handle = GNUNET_TRANSPORT_notify_transmit_ready (p2.th,
642 &p1.id,
643 sizeof (struct GNUNET_MessageHeader), 0,
644 TIMEOUT,
645 &notify_ready_connect,
646 NULL)));
647
648 /* both HELLOs exchanged, get ready to test transmission! */
649} 691}
650 692
651 693
652static void 694static void
653exchange_hello (void *cls,
654 const struct GNUNET_MessageHeader *message)
655{
656 struct PeerContext *me = cls;
657
658 GNUNET_TRANSPORT_get_hello_cancel (p1.th, &exchange_hello, me);
659 GNUNET_assert (ok >= 2);
660 OKPP;
661 GNUNET_assert (message != NULL);
662 GNUNET_assert (GNUNET_OK ==
663 GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *)
664 message, &me->id));
665 GNUNET_TRANSPORT_offer_hello (p2.th, message, NULL, NULL);
666 GNUNET_TRANSPORT_get_hello (p2.th, &exchange_hello_last, &p2);
667}
668
669static void
670run (void *cls, 695run (void *cls,
671 char *const *args, 696 char *const *args,
672 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) 697 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
@@ -683,67 +708,85 @@ run (void *cls,
683 708
684 if (is_tcp) 709 if (is_tcp)
685 { 710 {
686 if (is_asymmetric_recv_constant == GNUNET_YES) 711 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"); 712 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
688 else if (is_asymmetric_send_constant == GNUNET_YES) 713 "Testing asymmetric quota compliance (receiver quota constant) for TCP transport plugin\n");
689 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Testing asymmetric quota compliance (sender quota constant) for TCP transport plugin\n"); 714 else if (is_asymmetric_send_constant == GNUNET_YES)
690 else 715 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
691 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Testing symmetric quota compliance for TCP transport plugin\n"); 716 "Testing asymmetric quota compliance (sender quota constant) for TCP transport plugin\n");
717 else
718 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
719 "Testing symmetric quota compliance for TCP transport plugin\n");
692 setup_peer (&p1, "test_quota_compliance_tcp_peer1.conf"); 720 setup_peer (&p1, "test_quota_compliance_tcp_peer1.conf");
693 setup_peer (&p2, "test_quota_compliance_tcp_peer2.conf"); 721 setup_peer (&p2, "test_quota_compliance_tcp_peer2.conf");
694 } 722 }
695 else if (is_http) 723 else if (is_http)
696 { 724 {
697 if (is_asymmetric_recv_constant == GNUNET_YES) 725 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"); 726 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
699 else if (is_asymmetric_send_constant == GNUNET_YES) 727 "Testing asymmetric quota compliance (receiver quota constant) for HTTP transport plugin\n");
700 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Testing asymmetric quota compliance (sender quota constant) for HTTP transport plugin\n"); 728 else if (is_asymmetric_send_constant == GNUNET_YES)
701 else 729 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
702 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Testing symmetric quota compliance for HTTP transport plugin\n"); 730 "Testing asymmetric quota compliance (sender quota constant) for HTTP transport plugin\n");
731 else
732 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
733 "Testing symmetric quota compliance for HTTP transport plugin\n");
703 setup_peer (&p1, "test_quota_compliance_http_peer1.conf"); 734 setup_peer (&p1, "test_quota_compliance_http_peer1.conf");
704 setup_peer (&p2, "test_quota_compliance_http_peer2.conf"); 735 setup_peer (&p2, "test_quota_compliance_http_peer2.conf");
705 } 736 }
706 else if (is_https) 737 else if (is_https)
707 { 738 {
708 if (is_asymmetric_recv_constant == GNUNET_YES) 739 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"); 740 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
710 else if (is_asymmetric_send_constant == GNUNET_YES) 741 "Testing asymmetric quota compliance (receiver quota constant) for HTTPS transport plugin\n");
711 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Testing asymmetric quota compliance (sender quota constant) for HTTPS transport plugin\n"); 742 else if (is_asymmetric_send_constant == GNUNET_YES)
712 else 743 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
713 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Testing symmetric quota compliance for HTTPS transport plugin\n"); 744 "Testing asymmetric quota compliance (sender quota constant) for HTTPS transport plugin\n");
745 else
746 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
747 "Testing symmetric quota compliance for HTTPS transport plugin\n");
714 setup_peer (&p1, "test_quota_compliance_https_peer1.conf"); 748 setup_peer (&p1, "test_quota_compliance_https_peer1.conf");
715 setup_peer (&p2, "test_quota_compliance_https_peer2.conf"); 749 setup_peer (&p2, "test_quota_compliance_https_peer2.conf");
716 } 750 }
717 else if (is_udp) 751 else if (is_udp)
718 { 752 {
719 if (is_asymmetric_recv_constant == GNUNET_YES) 753 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"); 754 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
721 else if (is_asymmetric_send_constant == GNUNET_YES) 755 "Testing asymmetric quota compliance (receiver quota constant) for UDP transport plugin\n");
722 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Testing asymmetric quota compliance (sender quota constant) for UDP transport plugin\n"); 756 else if (is_asymmetric_send_constant == GNUNET_YES)
723 else 757 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
724 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Testing symmetric quota compliance for UDP transport plugin\n"); 758 "Testing asymmetric quota compliance (sender quota constant) for UDP transport plugin\n");
759 else
760 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
761 "Testing symmetric quota compliance for UDP transport plugin\n");
725 setup_peer (&p1, "test_quota_compliance_udp_peer1.conf"); 762 setup_peer (&p1, "test_quota_compliance_udp_peer1.conf");
726 setup_peer (&p2, "test_quota_compliance_udp_peer2.conf"); 763 setup_peer (&p2, "test_quota_compliance_udp_peer2.conf");
727 } 764 }
728 else if (is_unix) 765 else if (is_unix)
729 { 766 {
730 if (is_asymmetric_recv_constant == GNUNET_YES) 767 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"); 768 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
732 else if (is_asymmetric_send_constant == GNUNET_YES) 769 "Testing asymmetric quota compliance (receiver quota constant) for UNIX transport plugin\n");
733 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Testing asymmetric quota compliance (sender quota constant) for UNIX transport plugin\n"); 770 else if (is_asymmetric_send_constant == GNUNET_YES)
734 else 771 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
735 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Testing symmetric quota compliance for UNIX transport plugin\n"); 772 "Testing asymmetric quota compliance (sender quota constant) for UNIX transport plugin\n");
773 else
774 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
775 "Testing symmetric quota compliance for UNIX transport plugin\n");
736 setup_peer (&p1, "test_quota_compliance_unix_peer1.conf"); 776 setup_peer (&p1, "test_quota_compliance_unix_peer1.conf");
737 setup_peer (&p2, "test_quota_compliance_unix_peer2.conf"); 777 setup_peer (&p2, "test_quota_compliance_unix_peer2.conf");
738 } 778 }
739 else if (is_tcp_nat) 779 else if (is_tcp_nat)
740 { 780 {
741 if (is_asymmetric_recv_constant == GNUNET_YES) 781 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"); 782 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
743 else if (is_asymmetric_send_constant == GNUNET_YES) 783 "Testing asymmetric quota compliance (receiver quota constant) for TCP NAT transport plugin\n");
744 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Testing asymmetric quota compliance (sender quota constant) for TCP NAT transport plugin\n"); 784 else if (is_asymmetric_send_constant == GNUNET_YES)
745 else 785 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
746 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Testing symmetric quota compliance for TCP NAT transport plugin\n"); 786 "Testing asymmetric quota compliance (sender quota constant) for TCP NAT transport plugin\n");
787 else
788 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
789 "Testing symmetric quota compliance for TCP NAT transport plugin\n");
747 setup_peer (&p1, "test_quota_compliance_tcp_peer1.conf"); 790 setup_peer (&p1, "test_quota_compliance_tcp_peer1.conf");
748 setup_peer (&p2, "test_quota_compliance_tcp_peer2.conf"); 791 setup_peer (&p2, "test_quota_compliance_tcp_peer2.conf");
749 } 792 }
@@ -753,8 +796,11 @@ run (void *cls,
753 GNUNET_assert(p1.th != NULL); 796 GNUNET_assert(p1.th != NULL);
754 GNUNET_assert(p2.th != NULL); 797 GNUNET_assert(p2.th != NULL);
755 GNUNET_TRANSPORT_get_hello (p1.th, &exchange_hello, &p1); 798 GNUNET_TRANSPORT_get_hello (p1.th, &exchange_hello, &p1);
799 GNUNET_TRANSPORT_get_hello (p2.th, &exchange_hello_last, &p2);
800 tct = GNUNET_SCHEDULER_add_now (&try_connect, NULL);
756} 801}
757 802
803
758int 804int
759main (int argc, char *argv[]) 805main (int argc, char *argv[])
760{ 806{
@@ -789,67 +835,67 @@ main (int argc, char *argv[])
789 835
790 if (strstr(argv[0], "asymmetric_recv") != NULL) 836 if (strstr(argv[0], "asymmetric_recv") != NULL)
791 { 837 {
792 is_asymmetric_recv_constant = GNUNET_YES; 838 is_asymmetric_recv_constant = GNUNET_YES;
793 } 839 }
794 else 840 else
795 is_asymmetric_recv_constant = GNUNET_NO; 841 is_asymmetric_recv_constant = GNUNET_NO;
796 if (strstr(argv[0], "asymmetric_send") != NULL) 842 if (strstr(argv[0], "asymmetric_send") != NULL)
797 { 843 {
798 is_asymmetric_send_constant = GNUNET_YES; 844 is_asymmetric_send_constant = GNUNET_YES;
799 } 845 }
800 else 846 else
801 is_asymmetric_send_constant = GNUNET_NO; 847 is_asymmetric_send_constant = GNUNET_NO;
802 848
803 char * logger; 849 char * logger;
804 if (is_tcp == GNUNET_YES) 850 if (is_tcp == GNUNET_YES)
805 { 851 {
806 if (is_asymmetric_recv_constant == GNUNET_YES) 852 if (is_asymmetric_recv_constant == GNUNET_YES)
807 GNUNET_asprintf(&logger, "test-quota-compliance-%s-%s","tcp","asymmetric_recv_constant"); 853 GNUNET_asprintf(&logger, "test-quota-compliance-%s-%s","tcp","asymmetric_recv_constant");
808 else if (is_asymmetric_send_constant == GNUNET_YES) 854 else if (is_asymmetric_send_constant == GNUNET_YES)
809 GNUNET_asprintf(&logger, "test-quota-compliance-%s-%s","tcp","asymmetric_send_constant"); 855 GNUNET_asprintf(&logger, "test-quota-compliance-%s-%s","tcp","asymmetric_send_constant");
810 else 856 else
811 GNUNET_asprintf(&logger, "test-quota-compliance-%s-%s","tcp","symmetric"); 857 GNUNET_asprintf(&logger, "test-quota-compliance-%s-%s","tcp","symmetric");
812 } 858 }
813 else if (is_udp == GNUNET_YES) 859 else if (is_udp == GNUNET_YES)
814 { 860 {
815 if (is_asymmetric_recv_constant == GNUNET_YES) 861 if (is_asymmetric_recv_constant == GNUNET_YES)
816 GNUNET_asprintf(&logger, "test-quota-compliance-%s-%s","udp","asymmetric_recv_constant"); 862 GNUNET_asprintf(&logger, "test-quota-compliance-%s-%s","udp","asymmetric_recv_constant");
817 else if (is_asymmetric_send_constant == GNUNET_YES) 863 else if (is_asymmetric_send_constant == GNUNET_YES)
818 GNUNET_asprintf(&logger, "test-quota-compliance-%s-%s","udp","asymmetric_send_constant"); 864 GNUNET_asprintf(&logger, "test-quota-compliance-%s-%s","udp","asymmetric_send_constant");
819 else 865 else
820 GNUNET_asprintf(&logger, "test-quota-compliance-%s-%s","udp","symmetric"); 866 GNUNET_asprintf(&logger, "test-quota-compliance-%s-%s","udp","symmetric");
821 } 867 }
822 else if (is_unix == GNUNET_YES) 868 else if (is_unix == GNUNET_YES)
823 { 869 {
824 if (is_asymmetric_recv_constant == GNUNET_YES) 870 if (is_asymmetric_recv_constant == GNUNET_YES)
825 GNUNET_asprintf(&logger, "test-quota-compliance-%s-%s","unix","asymmetric_recv_constant"); 871 GNUNET_asprintf(&logger, "test-quota-compliance-%s-%s","unix","asymmetric_recv_constant");
826 else if (is_asymmetric_send_constant == GNUNET_YES) 872 else if (is_asymmetric_send_constant == GNUNET_YES)
827 GNUNET_asprintf(&logger, "test-quota-compliance-%s-%s","unix","asymmetric_send_constant"); 873 GNUNET_asprintf(&logger, "test-quota-compliance-%s-%s","unix","asymmetric_send_constant");
828 else 874 else
829 GNUNET_asprintf(&logger, "test-quota-compliance-%s-%s","unix","symmetric"); 875 GNUNET_asprintf(&logger, "test-quota-compliance-%s-%s","unix","symmetric");
830 } 876 }
831 else if (is_http == GNUNET_YES) 877 else if (is_http == GNUNET_YES)
832 { 878 {
833 if (is_asymmetric_recv_constant == GNUNET_YES) 879 if (is_asymmetric_recv_constant == GNUNET_YES)
834 GNUNET_asprintf(&logger, "test-quota-compliance-%s-%s","http","asymmetric_recv_constant"); 880 GNUNET_asprintf(&logger, "test-quota-compliance-%s-%s","http","asymmetric_recv_constant");
835 else if (is_asymmetric_send_constant == GNUNET_YES) 881 else if (is_asymmetric_send_constant == GNUNET_YES)
836 GNUNET_asprintf(&logger, "test-quota-compliance-%s-%s","http","asymmetric_send_constant"); 882 GNUNET_asprintf(&logger, "test-quota-compliance-%s-%s","http","asymmetric_send_constant");
837 else 883 else
838 GNUNET_asprintf(&logger, "test-quota-compliance-%s-%s","http","symmetric"); 884 GNUNET_asprintf(&logger, "test-quota-compliance-%s-%s","http","symmetric");
839 } 885 }
840 else if (is_https == GNUNET_YES) 886 else if (is_https == GNUNET_YES)
841 { 887 {
842 if (is_asymmetric_recv_constant == GNUNET_YES) 888 if (is_asymmetric_recv_constant == GNUNET_YES)
843 GNUNET_asprintf(&logger, "test-quota-compliance-%s-%s","https","asymmetric_recv_constant"); 889 GNUNET_asprintf(&logger, "test-quota-compliance-%s-%s","https","asymmetric_recv_constant");
844 else if (is_asymmetric_send_constant == GNUNET_YES) 890 else if (is_asymmetric_send_constant == GNUNET_YES)
845 GNUNET_asprintf(&logger, "test-quota-compliance-%s-%s","https","asymmetric_send_constant"); 891 GNUNET_asprintf(&logger, "test-quota-compliance-%s-%s","https","asymmetric_send_constant");
846 else 892 else
847 GNUNET_asprintf(&logger, "test-quota-compliance-%s-%s","https","symmetric"); 893 GNUNET_asprintf(&logger, "test-quota-compliance-%s-%s","https","symmetric");
848 } 894 }
849 else 895 else
850 { 896 {
851 GNUNET_asprintf(&logger, "test-quota-compliance-%s-%s","noplugin","none"); 897 GNUNET_asprintf(&logger, "test-quota-compliance-%s-%s","noplugin","none");
852 } 898 }
853 899
854 GNUNET_DISK_directory_remove ("/tmp/test_quota_compliance_peer1"); 900 GNUNET_DISK_directory_remove ("/tmp/test_quota_compliance_peer1");
855 GNUNET_DISK_directory_remove ("/tmp/test_quota_compliance_peer2"); 901 GNUNET_DISK_directory_remove ("/tmp/test_quota_compliance_peer2");
diff --git a/src/transport/test_transport_api_reliability.c b/src/transport/test_transport_api_reliability.c
index 2d44167d4..45642486c 100644
--- a/src/transport/test_transport_api_reliability.c
+++ b/src/transport/test_transport_api_reliability.c
@@ -95,6 +95,8 @@ static struct GNUNET_TIME_Absolute start_time;
95 95
96static GNUNET_SCHEDULER_TaskIdentifier die_task; 96static GNUNET_SCHEDULER_TaskIdentifier die_task;
97 97
98static GNUNET_SCHEDULER_TaskIdentifier tct;
99
98static char * key_file_p1; 100static char * key_file_p1;
99static char * cert_file_p1; 101static char * cert_file_p1;
100 102
@@ -105,7 +107,6 @@ static int msg_scheduled;
105static int msg_sent; 107static int msg_sent;
106static int msg_recv_expected; 108static int msg_recv_expected;
107static int msg_recv; 109static int msg_recv;
108static struct GNUNET_TRANSPORT_TransmitHandle * transmit_handle;
109 110
110#if VERBOSE 111#if VERBOSE
111#define OKPP do { ok++; fprintf (stderr, "Now at stage %u at %s:%u\n", ok, __FILE__, __LINE__); } while (0) 112#define OKPP do { ok++; fprintf (stderr, "Now at stage %u at %s:%u\n", ok, __FILE__, __LINE__); } while (0)
@@ -163,10 +164,19 @@ end_badly (void *cls,
163 const struct GNUNET_SCHEDULER_TaskContext *tc) 164 const struct GNUNET_SCHEDULER_TaskContext *tc)
164{ 165{
165 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 166 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
166 "Reliability failed: \nLast message sent %u \nNext message scheduled %u\nLast message received %u\nMessage expected %u \n ", msg_sent, msg_scheduled, msg_recv, msg_recv_expected); 167 "Reliability failed: Last message sent %u, Next message scheduled %u, Last message received %u, Message expected %u\n",
168 msg_sent,
169 msg_scheduled,
170 msg_recv,
171 msg_recv_expected);
167 GNUNET_break (0); 172 GNUNET_break (0);
168 GNUNET_TRANSPORT_disconnect (p1.th); 173 GNUNET_TRANSPORT_disconnect (p1.th);
169 GNUNET_TRANSPORT_disconnect (p2.th); 174 GNUNET_TRANSPORT_disconnect (p2.th);
175 if (GNUNET_SCHEDULER_NO_TASK != tct)
176 {
177 GNUNET_SCHEDULER_cancel (tct);
178 tct = GNUNET_SCHEDULER_NO_TASK;
179 }
170 ok = 1; 180 ok = 1;
171} 181}
172 182
@@ -331,11 +341,65 @@ notify_ready (void *cls, size_t size, void *buf)
331 341
332 342
333static void 343static void
344notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
345{
346 connected--;
347#if VERBOSE
348 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
349 "Peer `%4s' disconnected (%p)!\n",
350 GNUNET_i2s (peer), cls);
351#endif
352}
353
354
355static void
356exchange_hello_last (void *cls,
357 const struct GNUNET_MessageHeader *message)
358{
359 struct PeerContext *me = cls;
360
361 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
362 "Exchanging HELLO of size %d with peer (%s)!\n",
363 (int) GNUNET_HELLO_size((const struct GNUNET_HELLO_Message *)message),
364 GNUNET_i2s (&me->id));
365 GNUNET_assert (message != NULL);
366 GNUNET_assert (GNUNET_OK ==
367 GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *)
368 message, &me->id));
369 GNUNET_TRANSPORT_offer_hello (p1.th, message, NULL, NULL);
370}
371
372
373
374static void
375exchange_hello (void *cls,
376 const struct GNUNET_MessageHeader *message)
377{
378 struct PeerContext *me = cls;
379
380 GNUNET_assert (message != NULL);
381 GNUNET_assert (GNUNET_OK ==
382 GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *)
383 message, &me->id));
384 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
385 "Exchanging HELLO of size %d from peer %s!\n",
386 (int) GNUNET_HELLO_size((const struct GNUNET_HELLO_Message *)message),
387 GNUNET_i2s (&me->id));
388 GNUNET_TRANSPORT_offer_hello (p2.th, message, NULL, NULL);
389}
390
391
392static void
334notify_connect (void *cls, 393notify_connect (void *cls,
335 const struct GNUNET_PeerIdentity *peer, 394 const struct GNUNET_PeerIdentity *peer,
336 const struct GNUNET_TRANSPORT_ATS_Information *ats, 395 const struct GNUNET_TRANSPORT_ATS_Information *ats,
337 uint32_t ats_count) 396 uint32_t ats_count)
338{ 397{
398 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
399 "Peer `%4s' connected to us (%p)!\n",
400 GNUNET_i2s (peer),
401 cls);
402 connected++;
339 if (cls == &p1) 403 if (cls == &p1)
340 { 404 {
341 GNUNET_TRANSPORT_set_quota (p1.th, 405 GNUNET_TRANSPORT_set_quota (p1.th,
@@ -343,7 +407,6 @@ notify_connect (void *cls,
343 GNUNET_BANDWIDTH_value_init (1024 * 1024 * 1024), 407 GNUNET_BANDWIDTH_value_init (1024 * 1024 * 1024),
344 GNUNET_BANDWIDTH_value_init (1024 * 1024 * 1024)); 408 GNUNET_BANDWIDTH_value_init (1024 * 1024 * 1024));
345 start_time = GNUNET_TIME_absolute_get (); 409 start_time = GNUNET_TIME_absolute_get ();
346 connected++;
347 } 410 }
348 else 411 else
349 { 412 {
@@ -351,37 +414,23 @@ notify_connect (void *cls,
351 &p1.id, 414 &p1.id,
352 GNUNET_BANDWIDTH_value_init (1024 * 1024 * 1024), 415 GNUNET_BANDWIDTH_value_init (1024 * 1024 * 1024),
353 GNUNET_BANDWIDTH_value_init (1024 * 1024 * 1024)); 416 GNUNET_BANDWIDTH_value_init (1024 * 1024 * 1024));
354 connected++;
355 } 417 }
356 418 if (2 == connected)
357 if (connected == 2)
358 { 419 {
359 420 GNUNET_SCHEDULER_cancel (die_task);
360 if ((transmit_handle!=NULL) && (cls == NULL)) 421 GNUNET_SCHEDULER_cancel (tct);
361 GNUNET_TRANSPORT_notify_transmit_ready_cancel(transmit_handle); 422 tct = GNUNET_SCHEDULER_NO_TASK;
362 if ((transmit_handle!=NULL) && (cls == &transmit_handle)) 423 GNUNET_TRANSPORT_get_hello_cancel (p2.th, &exchange_hello_last, &p2);
363 transmit_handle=NULL; 424 GNUNET_TRANSPORT_get_hello_cancel (p1.th, &exchange_hello, &p1);
425 die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT,
426 &end_badly, NULL);
364 GNUNET_TRANSPORT_notify_transmit_ready (p2.th, 427 GNUNET_TRANSPORT_notify_transmit_ready (p2.th,
365 &p1.id, 428 &p1.id,
366 get_size (0), 0, TIMEOUT, 429 get_size (0), 0, TIMEOUT,
367 &notify_ready, 430 &notify_ready,
368 NULL); 431 NULL);
432
369 } 433 }
370#if VERBOSE
371 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
372 "Peer `%4s' connected to us (%p)!\n", GNUNET_i2s (peer), cls);
373#endif
374}
375
376
377static void
378notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
379{
380#if VERBOSE
381 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
382 "Peer `%4s' disconnected (%p)!\n",
383 GNUNET_i2s (peer), cls);
384#endif
385} 434}
386 435
387 436
@@ -401,62 +450,77 @@ setup_peer (struct PeerContext *p, const char *cfgname)
401 GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); 450 GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname));
402 451
403 if (is_https) 452 if (is_https)
404 { 453 {
405 struct stat sbuf; 454 struct stat sbuf;
406 if (p==&p1) 455 if (p==&p1)
407 { 456 {
408 if (GNUNET_CONFIGURATION_have_value (p->cfg, 457 if (GNUNET_CONFIGURATION_have_value (p->cfg,
409 "transport-https", "KEY_FILE")) 458 "transport-https", "KEY_FILE"))
410 GNUNET_CONFIGURATION_get_value_string (p->cfg, "transport-https", "KEY_FILE", &key_file_p1); 459 GNUNET_CONFIGURATION_get_value_string (p->cfg, "transport-https", "KEY_FILE", &key_file_p1);
411 if (key_file_p1 == NULL) 460 if (key_file_p1 == NULL)
412 GNUNET_asprintf(&key_file_p1,"https_p1.key"); 461 GNUNET_asprintf(&key_file_p1,"https_p1.key");
413 if (0 == stat (key_file_p1, &sbuf )) 462 if (0 == stat (key_file_p1, &sbuf ))
414 { 463 {
415 if (0 == remove(key_file_p1)) 464 if (0 == remove(key_file_p1))
416 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Successfully removed existing private key file `%s'\n",key_file_p1); 465 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
417 else 466 "Successfully removed existing private key file `%s'\n",
418 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to remove private key file `%s'\n",key_file_p1); 467 key_file_p1);
419 } 468 else
420 if (GNUNET_CONFIGURATION_have_value (p->cfg,"transport-https", "CERT_FILE")) 469 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
421 GNUNET_CONFIGURATION_get_value_string (p->cfg, "transport-https", "CERT_FILE", &cert_file_p1); 470 "Failed to remove private key file `%s'\n",
422 if (cert_file_p1 == NULL) 471 key_file_p1);
423 GNUNET_asprintf(&cert_file_p1,"https_p1.cert"); 472 }
424 if (0 == stat (cert_file_p1, &sbuf )) 473 if (GNUNET_CONFIGURATION_have_value (p->cfg,"transport-https", "CERT_FILE"))
425 { 474 GNUNET_CONFIGURATION_get_value_string (p->cfg, "transport-https", "CERT_FILE", &cert_file_p1);
426 if (0 == remove(cert_file_p1)) 475 if (cert_file_p1 == NULL)
427 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Successfully removed existing certificate file `%s'\n",cert_file_p1); 476 GNUNET_asprintf(&cert_file_p1,"https_p1.cert");
428 else 477 if (0 == stat (cert_file_p1, &sbuf ))
429 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to remove existing certificate file `%s'\n",cert_file_p1); 478 {
430 } 479 if (0 == remove(cert_file_p1))
431 } 480 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
432 else if (p==&p2) 481 "Successfully removed existing certificate file `%s'\n",
433 { 482 cert_file_p1);
434 if (GNUNET_CONFIGURATION_have_value (p->cfg, 483 else
435 "transport-https", "KEY_FILE")) 484 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
436 GNUNET_CONFIGURATION_get_value_string (p->cfg, "transport-https", "KEY_FILE", &key_file_p2); 485 "Failed to remove existing certificate file `%s'\n",
437 if (key_file_p2 == NULL) 486 cert_file_p1);
438 GNUNET_asprintf(&key_file_p2,"https_p2.key"); 487 }
439 if (0 == stat (key_file_p2, &sbuf )) 488 }
440 { 489 else if (p==&p2)
441 if (0 == remove(key_file_p2)) 490 {
442 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Successfully removed existing private key file `%s'\n",key_file_p2); 491 if (GNUNET_CONFIGURATION_have_value (p->cfg,
443 else 492 "transport-https", "KEY_FILE"))
444 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to remove private key file `%s'\n",key_file_p2); 493 GNUNET_CONFIGURATION_get_value_string (p->cfg, "transport-https", "KEY_FILE", &key_file_p2);
445 } 494 if (key_file_p2 == NULL)
446 if (GNUNET_CONFIGURATION_have_value (p->cfg,"transport-https", "CERT_FILE")) 495 GNUNET_asprintf(&key_file_p2,"https_p2.key");
447 GNUNET_CONFIGURATION_get_value_string (p->cfg, "transport-https", "CERT_FILE", &cert_file_p2); 496 if (0 == stat (key_file_p2, &sbuf ))
448 if (cert_file_p2 == NULL) 497 {
449 GNUNET_asprintf(&cert_file_p2,"https_p2.cert"); 498 if (0 == remove(key_file_p2))
450 if (0 == stat (cert_file_p2, &sbuf )) 499 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
451 { 500 "Successfully removed existing private key file `%s'\n",
452 if (0 == remove(cert_file_p2)) 501 key_file_p2);
453 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Successfully removed existing certificate file `%s'\n",cert_file_p2); 502 else
454 else 503 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
455 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to remove existing certificate file `%s'\n",cert_file_p2); 504 "Failed to remove private key file `%s'\n",
456 } 505 key_file_p2);
457 } 506 }
458 } 507 if (GNUNET_CONFIGURATION_have_value (p->cfg,"transport-https", "CERT_FILE"))
459 508 GNUNET_CONFIGURATION_get_value_string (p->cfg, "transport-https", "CERT_FILE", &cert_file_p2);
509 if (cert_file_p2 == NULL)
510 GNUNET_asprintf(&cert_file_p2,"https_p2.cert");
511 if (0 == stat (cert_file_p2, &sbuf ))
512 {
513 if (0 == remove(cert_file_p2))
514 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
515 "Successfully removed existing certificate file `%s'\n",
516 cert_file_p2);
517 else
518 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
519 "Failed to remove existing certificate file `%s'\n",
520 cert_file_p2);
521 }
522 }
523 }
460 p->th = GNUNET_TRANSPORT_connect (p->cfg, NULL, 524 p->th = GNUNET_TRANSPORT_connect (p->cfg, NULL,
461 p, 525 p,
462 &notify_receive, 526 &notify_receive,
@@ -465,69 +529,6 @@ setup_peer (struct PeerContext *p, const char *cfgname)
465 GNUNET_assert (p->th != NULL); 529 GNUNET_assert (p->th != NULL);
466} 530}
467 531
468static size_t
469notify_ready_connect (void *cls, size_t size, void *buf)
470{
471 return 0;
472}
473
474static void
475exchange_hello_last (void *cls,
476 const struct GNUNET_MessageHeader *message)
477{
478 struct PeerContext *me = cls;
479 transmit_handle = NULL;
480 GNUNET_TRANSPORT_get_hello_cancel (p2.th, &exchange_hello_last, me);
481#if VERBOSE
482 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
483 "Exchanging HELLO with peer (%p)!\n", cls);
484#endif
485 GNUNET_assert (ok >= 3);
486 OKPP;
487 GNUNET_assert (message != NULL);
488 GNUNET_assert (GNUNET_OK ==
489 GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *)
490 message, &me->id));
491
492 GNUNET_assert(NULL != (transmit_handle = GNUNET_TRANSPORT_notify_transmit_ready (p2.th,
493 &p1.id,
494 sizeof (struct GNUNET_MessageHeader), 0,
495 TIMEOUT,
496 &notify_ready_connect,
497 &transmit_handle)));
498
499 /* both HELLOs exchanged, get ready to test transmission! */
500 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
501 "Finished exchanging HELLOs, now waiting for transmission!\n");
502}
503
504
505static void
506exchange_hello (void *cls,
507 const struct GNUNET_MessageHeader *message)
508{
509 struct PeerContext *me = cls;
510
511 GNUNET_TRANSPORT_get_hello_cancel (p1.th, &exchange_hello, me);
512#if VERBOSE
513 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
514 "Exchanging HELLO with peer (%p)!\n", cls);
515#endif
516 GNUNET_assert (ok >= 2);
517 OKPP;
518 GNUNET_assert (message != NULL);
519 GNUNET_assert (GNUNET_OK ==
520 GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *)
521 message, &me->id));
522
523#if VERBOSE
524 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
525 "Received HELLO size %d\n",
526 GNUNET_HELLO_size((const struct GNUNET_HELLO_Message *)message));
527#endif
528 GNUNET_TRANSPORT_offer_hello (p2.th, message, NULL, NULL);
529 GNUNET_TRANSPORT_get_hello (p2.th, &exchange_hello_last, &p2);
530}
531 532
532/** 533/**
533 * Return the actual path to a file found in the current 534 * Return the actual path to a file found in the current
@@ -640,6 +641,23 @@ check_gnunet_nat_binary(char *binary)
640#endif 641#endif
641} 642}
642 643
644
645static void
646try_connect (void *cls,
647 const struct GNUNET_SCHEDULER_TaskContext *tc)
648{
649 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
650 "Asking peers to connect...\n");
651 GNUNET_TRANSPORT_try_connect (p2.th,
652 &p1.id);
653 GNUNET_TRANSPORT_try_connect (p1.th,
654 &p2.id);
655 tct = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
656 &try_connect,
657 NULL);
658}
659
660
643static void 661static void
644run (void *cls, 662run (void *cls,
645 char *const *args, 663 char *const *args,
@@ -690,6 +708,8 @@ run (void *cls,
690 GNUNET_assert(p1.th != NULL); 708 GNUNET_assert(p1.th != NULL);
691 GNUNET_assert(p2.th != NULL); 709 GNUNET_assert(p2.th != NULL);
692 GNUNET_TRANSPORT_get_hello (p1.th, &exchange_hello, &p1); 710 GNUNET_TRANSPORT_get_hello (p1.th, &exchange_hello, &p1);
711 GNUNET_TRANSPORT_get_hello (p2.th, &exchange_hello_last, &p2);
712 tct = GNUNET_SCHEDULER_add_now (&try_connect, NULL);
693} 713}
694 714
695 715
@@ -715,7 +735,8 @@ check ()
715 735
716 if ((GNUNET_YES == is_tcp_nat) && (check_gnunet_nat_binary("gnunet-nat-server") != GNUNET_YES)) 736 if ((GNUNET_YES == is_tcp_nat) && (check_gnunet_nat_binary("gnunet-nat-server") != GNUNET_YES))
717 { 737 {
718 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Not running NAT test case, binaries not properly installed.\n"); 738 GNUNET_log(GNUNET_ERROR_TYPE_WARNING,
739 "Not running NAT test case, binaries not properly installed.\n");
719 return 0; 740 return 0;
720 } 741 }
721 742
@@ -731,33 +752,47 @@ check ()
731 if (0 == stat (cert_file_p1, &sbuf )) 752 if (0 == stat (cert_file_p1, &sbuf ))
732 { 753 {
733 if (0 == remove(cert_file_p1)) 754 if (0 == remove(cert_file_p1))
734 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Successfully removed existing certificate file `%s'\n",cert_file_p1); 755 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
756 "Successfully removed existing certificate file `%s'\n",
757 cert_file_p1);
735 else 758 else
736 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to remove certfile `%s'\n",cert_file_p1); 759 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
760 "Failed to remove certfile `%s'\n",
761 cert_file_p1);
737 } 762 }
738 763
739 if (0 == stat (key_file_p1, &sbuf )) 764 if (0 == stat (key_file_p1, &sbuf ))
740 { 765 {
741 if (0 == remove(key_file_p1)) 766 if (0 == remove(key_file_p1))
742 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Successfully removed private key file `%s'\n",key_file_p1); 767 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
768 "Successfully removed private key file `%s'\n",
769 key_file_p1);
743 else 770 else
744 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to private key file `%s'\n",key_file_p1); 771 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
772 "Failed to private key file `%s'\n",key_file_p1);
745 } 773 }
746 774
747 if (0 == stat (cert_file_p2, &sbuf )) 775 if (0 == stat (cert_file_p2, &sbuf ))
748 { 776 {
749 if (0 == remove(cert_file_p2)) 777 if (0 == remove(cert_file_p2))
750 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Successfully removed existing certificate file `%s'\n",cert_file_p2); 778 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
779 "Successfully removed existing certificate file `%s'\n",
780 cert_file_p2);
751 else 781 else
752 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to remove certfile `%s'\n",cert_file_p2); 782 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
783 "Failed to remove certfile `%s'\n",cert_file_p2);
753 } 784 }
754 785
755 if (0 == stat (key_file_p2, &sbuf )) 786 if (0 == stat (key_file_p2, &sbuf ))
756 { 787 {
757 if (0 == remove(key_file_p2)) 788 if (0 == remove(key_file_p2))
758 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Successfully removed private key file `%s'\n",key_file_p2); 789 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
790 "Successfully removed private key file `%s'\n",
791 key_file_p2);
759 else 792 else
760 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to private key file `%s'\n",key_file_p2); 793 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
794 "Failed to private key file `%s'\n",
795 key_file_p2);
761 } 796 }
762 GNUNET_free(key_file_p1); 797 GNUNET_free(key_file_p1);
763 GNUNET_free(key_file_p2); 798 GNUNET_free(key_file_p2);
diff --git a/src/transport/test_transport_api_unreliability.c b/src/transport/test_transport_api_unreliability.c
index d27a5193e..fadb49f5d 100644
--- a/src/transport/test_transport_api_unreliability.c
+++ b/src/transport/test_transport_api_unreliability.c
@@ -98,6 +98,8 @@ static struct GNUNET_TIME_Absolute start_time;
98 98
99static GNUNET_SCHEDULER_TaskIdentifier die_task; 99static GNUNET_SCHEDULER_TaskIdentifier die_task;
100 100
101static GNUNET_SCHEDULER_TaskIdentifier tct;
102
101static char *key_file_p1; 103static char *key_file_p1;
102static char *cert_file_p1; 104static char *cert_file_p1;
103 105
@@ -112,13 +114,6 @@ static int msg_scheduled;
112static int msg_sent; 114static int msg_sent;
113static int msg_recv_expected; 115static int msg_recv_expected;
114static int msg_recv; 116static int msg_recv;
115static struct GNUNET_TRANSPORT_TransmitHandle * transmit_handle;
116
117#if VERBOSE
118#define OKPP do { ok++; fprintf (stderr, "Now at stage %u at %s:%u\n", ok, __FILE__, __LINE__); } while (0)
119#else
120#define OKPP do { ok++; } while (0)
121#endif
122 117
123/** 118/**
124 * Sets a bit active in the bitmap. 119 * Sets a bit active in the bitmap.
@@ -261,10 +256,20 @@ end_badly (void *cls,
261 const struct GNUNET_SCHEDULER_TaskContext *tc) 256 const struct GNUNET_SCHEDULER_TaskContext *tc)
262{ 257{
263 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 258 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
264 "Reliability failed: \nLast message sent %u \nNext message scheduled %u\nLast message received %u\nMessage expected %u \n ", msg_sent, msg_scheduled, msg_recv, msg_recv_expected); 259 "Reliability failed: Last message sent %u Next message scheduled %u Last message received %u Message expected %u\n",
260 msg_sent,
261 msg_scheduled,
262 msg_recv,
263 msg_recv_expected);
265 GNUNET_break (0); 264 GNUNET_break (0);
266 GNUNET_TRANSPORT_disconnect (p1.th); 265 GNUNET_TRANSPORT_disconnect (p1.th);
267 GNUNET_TRANSPORT_disconnect (p2.th); 266 GNUNET_TRANSPORT_disconnect (p2.th);
267
268 if (GNUNET_SCHEDULER_NO_TASK != tct)
269 {
270 GNUNET_SCHEDULER_cancel (tct);
271 tct = GNUNET_SCHEDULER_NO_TASK;
272 }
268 ok = 1; 273 ok = 1;
269} 274}
270 275
@@ -427,12 +432,67 @@ notify_ready (void *cls, size_t size, void *buf)
427} 432}
428 433
429 434
435
436static void
437notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
438{
439 connected--;
440#if VERBOSE
441 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
442 "Peer `%4s' disconnected (%p)!\n",
443 GNUNET_i2s (peer), cls);
444#endif
445}
446
447
448
449static void
450exchange_hello_last (void *cls,
451 const struct GNUNET_MessageHeader *message)
452{
453 struct PeerContext *me = cls;
454
455 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
456 "Exchanging HELLO of size %d with peer (%s)!\n",
457 (int) GNUNET_HELLO_size((const struct GNUNET_HELLO_Message *)message),
458 GNUNET_i2s (&me->id));
459 GNUNET_assert (message != NULL);
460 GNUNET_assert (GNUNET_OK ==
461 GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *)
462 message, &me->id));
463 GNUNET_TRANSPORT_offer_hello (p1.th, message, NULL, NULL);
464}
465
466
467
468static void
469exchange_hello (void *cls,
470 const struct GNUNET_MessageHeader *message)
471{
472 struct PeerContext *me = cls;
473
474 GNUNET_assert (message != NULL);
475 GNUNET_assert (GNUNET_OK ==
476 GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *)
477 message, &me->id));
478 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
479 "Exchanging HELLO of size %d from peer %s!\n",
480 (int) GNUNET_HELLO_size((const struct GNUNET_HELLO_Message *)message),
481 GNUNET_i2s (&me->id));
482 GNUNET_TRANSPORT_offer_hello (p2.th, message, NULL, NULL);
483}
484
485
430static void 486static void
431notify_connect (void *cls, 487notify_connect (void *cls,
432 const struct GNUNET_PeerIdentity *peer, 488 const struct GNUNET_PeerIdentity *peer,
433 const struct GNUNET_TRANSPORT_ATS_Information *ats, 489 const struct GNUNET_TRANSPORT_ATS_Information *ats,
434 uint32_t ats_count) 490 uint32_t ats_count)
435{ 491{
492 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
493 "Peer `%4s' connected to us (%p)!\n",
494 GNUNET_i2s (peer),
495 cls);
436 if (cls == &p1) 496 if (cls == &p1)
437 { 497 {
438 GNUNET_TRANSPORT_set_quota (p1.th, 498 GNUNET_TRANSPORT_set_quota (p1.th,
@@ -450,35 +510,22 @@ notify_connect (void *cls,
450 GNUNET_BANDWIDTH_value_init (1024 * 1024 * 1024)); 510 GNUNET_BANDWIDTH_value_init (1024 * 1024 * 1024));
451 connected++; 511 connected++;
452 } 512 }
453 513 if (2 == connected)
454 if (connected == 2)
455 { 514 {
456 515 GNUNET_SCHEDULER_cancel (die_task);
457 if ((transmit_handle!=NULL) && (cls == NULL)) 516 GNUNET_SCHEDULER_cancel (tct);
458 GNUNET_TRANSPORT_notify_transmit_ready_cancel(transmit_handle); 517 tct = GNUNET_SCHEDULER_NO_TASK;
459 if ((transmit_handle!=NULL) && (cls == &transmit_handle)) 518 GNUNET_TRANSPORT_get_hello_cancel (p2.th, &exchange_hello_last, &p2);
460 transmit_handle=NULL; 519 GNUNET_TRANSPORT_get_hello_cancel (p1.th, &exchange_hello, &p1);
520 die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT,
521 &end_badly, NULL);
461 GNUNET_TRANSPORT_notify_transmit_ready (p2.th, 522 GNUNET_TRANSPORT_notify_transmit_ready (p2.th,
462 &p1.id, 523 &p1.id,
463 get_size (0), 0, TIMEOUT, 524 get_size (0), 0, TIMEOUT,
464 &notify_ready, 525 &notify_ready,
465 NULL); 526 NULL);
527
466 } 528 }
467#if VERBOSE
468 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
469 "Peer `%4s' connected to us (%p)!\n", GNUNET_i2s (peer), cls);
470#endif
471}
472
473
474static void
475notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
476{
477#if VERBOSE
478 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
479 "Peer `%4s' disconnected (%p)!\n",
480 GNUNET_i2s (peer), cls);
481#endif
482} 529}
483 530
484 531
@@ -562,69 +609,6 @@ setup_peer (struct PeerContext *p, const char *cfgname)
562 GNUNET_assert (p->th != NULL); 609 GNUNET_assert (p->th != NULL);
563} 610}
564 611
565static size_t
566notify_ready_connect (void *cls, size_t size, void *buf)
567{
568 return 0;
569}
570
571static void
572exchange_hello_last (void *cls,
573 const struct GNUNET_MessageHeader *message)
574{
575 struct PeerContext *me = cls;
576 transmit_handle = NULL;
577 GNUNET_TRANSPORT_get_hello_cancel (p2.th, &exchange_hello_last, me);
578#if VERBOSE
579 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
580 "Exchanging HELLO with peer (%p)!\n", cls);
581#endif
582 GNUNET_assert (ok >= 3);
583 OKPP;
584 GNUNET_assert (message != NULL);
585 GNUNET_assert (GNUNET_OK ==
586 GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *)
587 message, &me->id));
588
589 GNUNET_assert(NULL != (transmit_handle = GNUNET_TRANSPORT_notify_transmit_ready (p2.th,
590 &p1.id,
591 sizeof (struct GNUNET_MessageHeader), 0,
592 TIMEOUT,
593 &notify_ready_connect,
594 &transmit_handle)));
595
596 /* both HELLOs exchanged, get ready to test transmission! */
597 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
598 "Finished exchanging HELLOs, now waiting for transmission!\n");
599}
600
601
602static void
603exchange_hello (void *cls,
604 const struct GNUNET_MessageHeader *message)
605{
606 struct PeerContext *me = cls;
607
608 GNUNET_TRANSPORT_get_hello_cancel (p1.th, &exchange_hello, me);
609#if VERBOSE
610 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
611 "Exchanging HELLO with peer (%p)!\n", cls);
612#endif
613 GNUNET_assert (ok >= 2);
614 OKPP;
615 GNUNET_assert (message != NULL);
616 GNUNET_assert (GNUNET_OK ==
617 GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *)
618 message, &me->id));
619
620#if VERBOSE
621 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
622 "Received HELLO size %d\n",
623 GNUNET_HELLO_size((const struct GNUNET_HELLO_Message *)message));
624#endif
625 GNUNET_TRANSPORT_offer_hello (p2.th, message, NULL, NULL);
626 GNUNET_TRANSPORT_get_hello (p2.th, &exchange_hello_last, &p2);
627}
628 612
629/** 613/**
630 * Return the actual path to a file found in the current 614 * Return the actual path to a file found in the current
@@ -737,13 +721,29 @@ check_gnunet_nat_binary(char *binary)
737#endif 721#endif
738} 722}
739 723
724
725static void
726try_connect (void *cls,
727 const struct GNUNET_SCHEDULER_TaskContext *tc)
728{
729 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
730 "Asking peers to connect...\n");
731 GNUNET_TRANSPORT_try_connect (p2.th,
732 &p1.id);
733 GNUNET_TRANSPORT_try_connect (p1.th,
734 &p2.id);
735 tct = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
736 &try_connect,
737 NULL);
738}
739
740
741
740static void 742static void
741run (void *cls, 743run (void *cls,
742 char *const *args, 744 char *const *args,
743 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) 745 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
744{ 746{
745 GNUNET_assert (ok == 1);
746 OKPP;
747 die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, 747 die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT,
748 &end_badly, 748 &end_badly,
749 NULL); 749 NULL);
@@ -787,6 +787,8 @@ run (void *cls,
787 GNUNET_assert(p1.th != NULL); 787 GNUNET_assert(p1.th != NULL);
788 GNUNET_assert(p2.th != NULL); 788 GNUNET_assert(p2.th != NULL);
789 GNUNET_TRANSPORT_get_hello (p1.th, &exchange_hello, &p1); 789 GNUNET_TRANSPORT_get_hello (p1.th, &exchange_hello, &p1);
790 GNUNET_TRANSPORT_get_hello (p2.th, &exchange_hello_last, &p2);
791 tct = GNUNET_SCHEDULER_add_now (&try_connect, NULL);
790} 792}
791 793
792 794
diff --git a/src/transport/test_transport_ats.c b/src/transport/test_transport_ats.c
index 08f38398e..314d78172 100644
--- a/src/transport/test_transport_ats.c
+++ b/src/transport/test_transport_ats.c
@@ -63,12 +63,12 @@ struct GNUNET_STATISTICS_Handle * stats;
63 63
64struct TEST_result 64struct TEST_result
65{ 65{
66 uint64_t timestamp; 66 uint64_t timestamp;
67 uint64_t duration; 67 uint64_t duration;
68 uint64_t mechs; 68 uint64_t mechs;
69 uint64_t peers; 69 uint64_t peers;
70 uint64_t solution; 70 uint64_t solution;
71 uint64_t state; 71 uint64_t state;
72}; 72};
73 73
74struct TestMessage 74struct TestMessage
@@ -109,13 +109,14 @@ struct GNUNET_TRANSPORT_Handle * th;
109/** 109/**
110 * Check whether peers successfully shut down. 110 * Check whether peers successfully shut down.
111 */ 111 */
112void 112static void
113shutdown_callback (void *cls, const char *emsg) 113shutdown_callback (void *cls, const char *emsg)
114{ 114{
115 if (emsg != NULL) 115 if (emsg != NULL)
116 { 116 {
117#if VERBOSE 117#if VERBOSE
118 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Shutdown of peers failed!\n"); 118 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
119 "Shutdown of peers failed!\n");
119#endif 120#endif
120 if (ok == 0) 121 if (ok == 0)
121 ok = 666; 122 ok = 666;
@@ -132,464 +133,511 @@ shutdown_callback (void *cls, const char *emsg)
132 } 133 }
133} 134}
134 135
135static void shutdown_peers() 136static void
137shutdown_peers()
136{ 138{
137 if (shutdown_task != GNUNET_SCHEDULER_NO_TASK) 139 if (shutdown_task != GNUNET_SCHEDULER_NO_TASK)
138 { 140 {
139 GNUNET_SCHEDULER_cancel(shutdown_task); 141 GNUNET_SCHEDULER_cancel(shutdown_task);
140 shutdown_task = GNUNET_SCHEDULER_NO_TASK; 142 shutdown_task = GNUNET_SCHEDULER_NO_TASK;
141 } 143 }
142 if (stats_task != GNUNET_SCHEDULER_NO_TASK) 144 if (stats_task != GNUNET_SCHEDULER_NO_TASK)
143 { 145 {
144 GNUNET_SCHEDULER_cancel(stats_task); 146 GNUNET_SCHEDULER_cancel(stats_task);
145 stats_task = GNUNET_SCHEDULER_NO_TASK; 147 stats_task = GNUNET_SCHEDULER_NO_TASK;
146 } 148 }
147 if (send_task != GNUNET_SCHEDULER_NO_TASK) 149 if (send_task != GNUNET_SCHEDULER_NO_TASK)
148 { 150 {
149 GNUNET_SCHEDULER_cancel(send_task); 151 GNUNET_SCHEDULER_cancel(send_task);
150 send_task = GNUNET_SCHEDULER_NO_TASK; 152 send_task = GNUNET_SCHEDULER_NO_TASK;
151 } 153 }
152 154
153 if (t!=NULL) 155 if (t != NULL)
154 { 156 {
155 GNUNET_TRANSPORT_notify_transmit_ready_cancel(t); 157 GNUNET_TRANSPORT_notify_transmit_ready_cancel(t);
156 t = NULL; 158 t = NULL;
157 } 159 }
158 160 GNUNET_TRANSPORT_disconnect(th);
159 GNUNET_TRANSPORT_disconnect(th); 161 if (s_time != NULL)
160 162 {
161 if (s_time != NULL) 163 GNUNET_STATISTICS_get_cancel(s_time);
162 { 164 s_time = NULL;
163 GNUNET_STATISTICS_get_cancel(s_time); 165 }
164 s_time = NULL; 166 if (s_peers != NULL)
165 } 167 {
166 if (s_peers != NULL) 168 GNUNET_STATISTICS_get_cancel(s_peers);
167 { 169 s_peers = NULL;
168 GNUNET_STATISTICS_get_cancel(s_peers); 170 }
169 s_peers = NULL; 171 if (s_mechs != NULL)
170 } 172 {
171 if (s_mechs != NULL) 173 GNUNET_STATISTICS_get_cancel(s_mechs);
172 { 174 s_mechs = NULL;
173 GNUNET_STATISTICS_get_cancel(s_mechs); 175 }
174 s_mechs = NULL; 176 if (s_solution != NULL)
175 } 177 {
176 if (s_solution != NULL) 178 GNUNET_STATISTICS_get_cancel(s_solution);
177 { 179 s_solution = NULL;
178 GNUNET_STATISTICS_get_cancel(s_solution); 180 }
179 s_solution = NULL; 181 if (s_duration != NULL)
180 } 182 {
181 if (s_duration != NULL) 183 GNUNET_STATISTICS_get_cancel(s_duration);
182 { 184 s_duration = NULL;
183 GNUNET_STATISTICS_get_cancel(s_duration); 185 }
184 s_duration = NULL; 186 if (s_invalid != NULL)
185 } 187 {
186 if (s_invalid != NULL) 188 GNUNET_STATISTICS_get_cancel(s_invalid);
187 { 189 s_invalid = NULL;
188 GNUNET_STATISTICS_get_cancel(s_invalid); 190 }
189 s_invalid = NULL; 191 if (s_state != NULL)
190 } 192 {
191 if (s_state != NULL) 193 GNUNET_STATISTICS_get_cancel(s_state);
192 { 194 s_state = NULL;
193 GNUNET_STATISTICS_get_cancel(s_state); 195 }
194 s_state = NULL; 196 GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL);
195 }
196
197 GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL);
198} 197}
199 198
200static void evaluate_measurements() 199static void
200evaluate_measurements()
201{ 201{
202 int c; 202 int c;
203 //int mechs = 0; 203 //int mechs = 0;
204 double average[3]; 204 double average[3];
205 double stddev[3]; 205 double stddev[3];
206 //char * output; 206 //char * output;
207 c = 1; 207 c = 1;
208 208
209 //GNUNET_asprintf(&output, "p,%i,m,%i,",peers, MEASUREMENTS, results_modified[0].mechs, 209 //GNUNET_asprintf(&output, "p,%i,m,%i,",peers, MEASUREMENTS, results_modified[0].mechs,
210 210
211 average[0] = 0.0; 211 average[0] = 0.0;
212 for (c=0; c<c_new;c++) 212 for (c=0; c<c_new;c++)
213 { 213 {
214 average[0] += (double) results_new[c].duration; 214 average[0] += (double) results_new[c].duration;
215 } 215 }
216 average[0] /= c_new; 216 average[0] /= c_new;
217 217
218 stddev[0] = 0.0; 218 stddev[0] = 0.0;
219 for (c=0; c<c_new;c++) 219 for (c=0; c<c_new;c++)
220 { 220 {
221 stddev[0] += (results_new[c].duration - average[0]) * (results_new[c].duration - average[0]); 221 stddev[0] += (results_new[c].duration - average[0]) * (results_new[c].duration - average[0]);
222 } 222 }
223 stddev[0] /= c_new; 223 stddev[0] /= c_new;
224 stddev[0] = sqrt (stddev[0]); 224 stddev[0] = sqrt (stddev[0]);
225 if (!machine_parsable) 225 if (!machine_parsable)
226 fprintf (stderr, 226 fprintf (stderr,
227 "new, %i measurements, average: %f stddev: %f\n", 227 "new, %i measurements, average: %f stddev: %f\n",
228 c_new, average[0], stddev[0]); 228 c_new, average[0], stddev[0]);
229 229
230 average[1] = 0.0; 230 average[1] = 0.0;
231 for (c=0; c<c_modified;c++) 231 for (c=0; c<c_modified;c++)
232 { 232 {
233 average[1] += (double) results_modified[c].duration; 233 average[1] += (double) results_modified[c].duration;
234 } 234 }
235 average[1] /= c_modified; 235 average[1] /= c_modified;
236 236
237 stddev[1] = 0.0; 237 stddev[1] = 0.0;
238 for (c=0; c<c_modified;c++) 238 for (c=0; c<c_modified;c++)
239 { 239 {
240 stddev[1] += (results_modified[c].duration - average[1]) * (results_modified[c].duration - average[1]); 240 stddev[1] += (results_modified[c].duration - average[1]) * (results_modified[c].duration - average[1]);
241 } 241 }
242 stddev[1] /= c_modified; 242 stddev[1] /= c_modified;
243 stddev[1] = sqrt (stddev[1]); 243 stddev[1] = sqrt (stddev[1]);
244 if (!machine_parsable) 244 if (!machine_parsable)
245 fprintf (stderr, 245 fprintf (stderr,
246 "modified, %i measurements, average: %f stddev: %f\n", 246 "modified, %i measurements, average: %f stddev: %f\n",
247 c_modified, average[1], stddev[1]); 247 c_modified, average[1], stddev[1]);
248 248
249 average[2] = 0.0; 249 average[2] = 0.0;
250 for (c=0; c<c_unmodified;c++) 250 for (c=0; c<c_unmodified;c++)
251 { 251 {
252 average[2] += (double) results_unmodified[c].duration; 252 average[2] += (double) results_unmodified[c].duration;
253 } 253 }
254 average[2] /= c_unmodified; 254 average[2] /= c_unmodified;
255 stddev[2] = 0.0; 255 stddev[2] = 0.0;
256 for (c=0; c<c_unmodified;c++) 256 for (c=0; c<c_unmodified;c++)
257 { 257 {
258 stddev[2] += (results_unmodified[c].duration - average[2]) * (results_unmodified[c].duration - average[2]); 258 stddev[2] += (results_unmodified[c].duration - average[2]) * (results_unmodified[c].duration - average[2]);
259 } 259 }
260 stddev[2] /= c_unmodified; 260 stddev[2] /= c_unmodified;
261 stddev[2] = sqrt (stddev[2]); 261 stddev[2] = sqrt (stddev[2]);
262 262
263 if (!machine_parsable) 263 if (!machine_parsable)
264 fprintf (stderr, 264 fprintf (stderr,
265 "unmodified, %i measurements, average: %f stddev: %f\n", 265 "unmodified, %i measurements, average: %f stddev: %f\n",
266 c_unmodified, average[2], stddev[2]); 266 c_unmodified, average[2], stddev[2]);
267 267
268 if (machine_parsable) 268 if (machine_parsable)
269 fprintf (stderr, 269 fprintf (stderr,
270 "peers,%i,mechs,%llu," 270 "peers,%i,mechs,%llu,"
271 "new,%i,%f,%f," 271 "new,%i,%f,%f,"
272 "mod,%i,%f,%f," 272 "mod,%i,%f,%f,"
273 "unmod,%i,%f,%f\n", 273 "unmod,%i,%f,%f\n",
274 peers-1, (unsigned long long) results_unmodified[0].mechs, 274 peers-1, (unsigned long long) results_unmodified[0].mechs,
275 c_new, average[0], stddev[0], 275 c_new, average[0], stddev[0],
276 c_modified, average[1], stddev[1], 276 c_modified, average[1], stddev[1],
277 c_unmodified, average[2], stddev[2]); 277 c_unmodified, average[2], stddev[2]);
278 shutdown_peers(); 278 shutdown_peers();
279} 279}
280 280
281int stats_cb (void *cls,
282 const char *subsystem,
283 const char *name,
284 uint64_t value,
285 int is_persistent)
286{
287 static int printed = GNUNET_NO;
288 //GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%s = %llu\n", name ,value);
289 if (0 == strcmp (name,"ATS invalid solutions"))
290 {
291 if (stats_task != GNUNET_SCHEDULER_NO_TASK)
292 {
293 GNUNET_SCHEDULER_cancel(stats_task);
294 stats_task = GNUNET_SCHEDULER_NO_TASK;
295 }
296 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"MLP produced invalid %llu result(s)!\n", value);
297 shutdown_peers();
298 return GNUNET_SYSERR;
299 }
300
301 if (0 == strcmp (name,"ATS solution"))
302 {
303 s_solution = NULL;
304 }
305
306 if (0 == strcmp (name,"ATS peers"))
307 {
308 s_peers = NULL;
309 }
310
311 if (0 == strcmp (name,"ATS mechanisms"))
312 {
313 s_mechs = NULL;
314 }
315 281
316 if (0 == strcmp (name,"ATS duration")) 282static int
317 { 283stats_cb (void *cls,
318 s_duration = NULL; 284 const char *subsystem,
319 } 285 const char *name,
320 if (0 == strcmp (name,"ATS timestamp")) 286 uint64_t value,
321 { 287 int is_persistent)
322 s_time = NULL; 288{
323 } 289 static int printed = GNUNET_NO;
324 if (0 == strcmp (name,"ATS state")) 290 //GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%s = %llu\n", name ,value);
291 if (0 == strcmp (name,"ATS invalid solutions"))
292 {
293 if (stats_task != GNUNET_SCHEDULER_NO_TASK)
325 { 294 {
326 s_state = NULL; 295 GNUNET_SCHEDULER_cancel(stats_task);
296 stats_task = GNUNET_SCHEDULER_NO_TASK;
327 } 297 }
328 298 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"MLP produced invalid %llu result(s)!\n", value);
329 if ((measurement_started == GNUNET_NO) && (0 == strcmp (name, "ATS peers")) && (value == peers-1)) 299 shutdown_peers();
300 return GNUNET_SYSERR;
301 }
302
303 if (0 == strcmp (name,"ATS solution"))
330 { 304 {
331 measurement_started = GNUNET_YES; 305 s_solution = NULL;
332 count = 1;
333 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "All %llu peers connected\n", value);
334#if !VERBOSE
335 if (!machine_parsable) fprintf(stderr, "%i", count);
336#endif
337 } 306 }
338 307
339 if (measurement_started == GNUNET_YES) 308 if (0 == strcmp (name,"ATS peers"))
340 { 309 {
341 // GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%s == %llu\n", name ,value); 310 s_peers = NULL;
342 if (0 == strcmp (name,"ATS timestamp")) 311 }
343 { 312
344 if (current.timestamp == 0) 313 if (0 == strcmp (name,"ATS mechanisms"))
345 { 314 {
346 printed = GNUNET_NO; 315 s_mechs = NULL;
347 current.timestamp = value; 316 }
348 } 317
349 if (current.timestamp == value) 318 if (0 == strcmp (name,"ATS duration"))
350 { 319 {
351 printed = GNUNET_YES; 320 s_duration = NULL;
352 } 321 }
353 if (current.timestamp != value) 322 if (0 == strcmp (name,"ATS timestamp"))
354 { 323 {
355 if (current.state == ATS_NEW) 324 s_time = NULL;
356 { 325 }
357 if (c_new < MEASUREMENTS) 326 if (0 == strcmp (name,"ATS state"))
358 { 327 {
359 results_new[c_new] = current; 328 s_state = NULL;
360 c_new++; 329 }
361 } 330
362 else 331 if ( (measurement_started == GNUNET_NO) &&
363 { 332 (0 == strcmp (name, "ATS peers")) &&
364 force_rebuild = GNUNET_NO; 333 (value == peers-1) )
365 force_q_updates = GNUNET_NO; 334 {
366 send_msg = GNUNET_NO; 335 measurement_started = GNUNET_YES;
367 } 336 count = 1;
368 } 337 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
369 if (current.state == ATS_UNMODIFIED) 338 "All %llu peers connected\n",
370 { 339 value);
371 if (c_unmodified < MEASUREMENTS)
372 {
373 results_unmodified[c_unmodified] = current;
374 c_unmodified++;
375 }
376
377 }
378 if (current.state == ATS_Q_UPDATED)
379 {
380 if (c_modified < MEASUREMENTS)
381 {
382 results_modified[c_modified] = current;
383 c_modified++;
384 }
385 else
386 {
387 force_q_updates = GNUNET_NO;
388 force_rebuild = GNUNET_YES;
389 }
390 }
391 count ++;
392#if VERBOSE
393 fprintf (stderr,
394 "(new: %i / modified: %i / unmodified: %i) of %i \n",
395 c_new, c_modified, c_unmodified , MEASUREMENTS);
396#endif
397 if ((c_modified >= MEASUREMENTS) && (c_new >= MEASUREMENTS) && (c_unmodified >= MEASUREMENTS))
398 {
399#if !VERBOSE
400 if (!machine_parsable) fprintf(stdout, "\n");
401#endif
402 if (stats_task != GNUNET_SCHEDULER_NO_TASK)
403 {
404 GNUNET_SCHEDULER_cancel(stats_task);
405 stats_task = GNUNET_SCHEDULER_NO_TASK;
406 }
407 evaluate_measurements();
408 return GNUNET_SYSERR;
409 }
410
411 printed = GNUNET_NO;
412 current.timestamp = value;
413#if !VERBOSE 340#if !VERBOSE
414 if (!machine_parsable) fprintf(stderr, "..%i", count); 341 if (! machine_parsable)
342 fprintf(stderr, "%i", count);
415#endif 343#endif
416 return GNUNET_OK; 344 }
417 } 345
418 } 346 if (measurement_started == GNUNET_YES)
419 347 {
420 if (0 == strcmp (name,"ATS solution")) 348 // GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%s == %llu\n", name ,value);
421 { 349 if (0 == strcmp (name,"ATS timestamp"))
422 current.solution = value; 350 {
423 if (printed == GNUNET_NO) 351 if (current.timestamp == 0)
424 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "[%i] %s: %llu \n", count, name, value); 352 {
425 } 353 printed = GNUNET_NO;
426 354 current.timestamp = value;
427 if (0 == strcmp (name,"ATS peers")) 355 }
356 if (current.timestamp == value)
357 {
358 printed = GNUNET_YES;
359 }
360 if (current.timestamp != value)
361 {
362 if (current.state == ATS_NEW)
428 { 363 {
429 current.peers = value; 364 if (c_new < MEASUREMENTS)
430 if (printed == GNUNET_NO) 365 {
431 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "[%i] %s: %llu \n", count, name, value); 366 results_new[c_new] = current;
367 c_new++;
368 }
369 else
370 {
371 force_rebuild = GNUNET_NO;
372 force_q_updates = GNUNET_NO;
373 send_msg = GNUNET_NO;
374 }
432 } 375 }
433 376 if (current.state == ATS_UNMODIFIED)
434 if (0 == strcmp (name,"ATS mechanisms"))
435 { 377 {
436 current.mechs = value; 378 if (c_unmodified < MEASUREMENTS)
437 if (printed == GNUNET_NO) 379 {
438 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "[%i] %s: %llu \n", count, name, value); 380 results_unmodified[c_unmodified] = current;
381 c_unmodified++;
382 }
383
439 } 384 }
440 385 if (current.state == ATS_Q_UPDATED)
441 if (0 == strcmp (name,"ATS duration"))
442 { 386 {
443 current.duration = value; 387 if (c_modified < MEASUREMENTS)
444 if (printed == GNUNET_NO) 388 {
445 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "[%i] %s: %llu \n", count, name, value); 389 results_modified[c_modified] = current;
390 c_modified++;
391 }
392 else
393 {
394 force_q_updates = GNUNET_NO;
395 force_rebuild = GNUNET_YES;
396 }
446 } 397 }
447 if (0 == strcmp (name,"ATS state")) 398 count ++;
399#if VERBOSE
400 fprintf (stderr,
401 "(new: %i / modified: %i / unmodified: %i) of %i \n",
402 c_new, c_modified, c_unmodified , MEASUREMENTS);
403#endif
404 if ((c_modified >= MEASUREMENTS) && (c_new >= MEASUREMENTS) && (c_unmodified >= MEASUREMENTS))
448 { 405 {
449 current.state = value; 406#if !VERBOSE
450 char * cont; 407 if (!machine_parsable)
451 if (value == ATS_NEW) 408 fprintf(stdout, "\n");
452 cont = "NEW"; 409#endif
453 if (value == ATS_C_UPDATED) 410 if (stats_task != GNUNET_SCHEDULER_NO_TASK)
454 cont = "C_UPDATED"; 411 {
455 if (value == ATS_Q_UPDATED) 412 GNUNET_SCHEDULER_cancel(stats_task);
456 cont = "Q_UPDATED"; 413 stats_task = GNUNET_SCHEDULER_NO_TASK;
457 if (value == ATS_QC_UPDATED) 414 }
458 cont = "QC_UPDATED"; 415 evaluate_measurements();
459 if (value == ATS_UNMODIFIED) 416 return GNUNET_SYSERR;
460 cont = "UNMODIFIED";
461 if (printed == GNUNET_NO)
462 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "[%i] ATS state: %s\n", count, cont);
463 } 417 }
418
419 printed = GNUNET_NO;
420 current.timestamp = value;
421#if !VERBOSE
422 if (! machine_parsable)
423 fprintf(stderr, "..%i", count);
424#endif
425 return GNUNET_OK;
426 }
427 }
428
429 if (0 == strcmp (name,"ATS solution"))
430 {
431 current.solution = value;
432 if (printed == GNUNET_NO)
433 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "[%i] %s: %llu \n", count, name, value);
434 }
435
436 if (0 == strcmp (name,"ATS peers"))
437 {
438 current.peers = value;
439 if (printed == GNUNET_NO)
440 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "[%i] %s: %llu \n", count, name, value);
441 }
442
443 if (0 == strcmp (name,"ATS mechanisms"))
444 {
445 current.mechs = value;
446 if (printed == GNUNET_NO)
447 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "[%i] %s: %llu \n", count, name, value);
448 }
449
450 if (0 == strcmp (name,"ATS duration"))
451 {
452 current.duration = value;
453 if (printed == GNUNET_NO)
454 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "[%i] %s: %llu \n", count, name, value);
455 }
456 if (0 == strcmp (name,"ATS state"))
457 {
458 current.state = value;
459 char * cont;
460 if (value == ATS_NEW)
461 cont = "NEW";
462 if (value == ATS_C_UPDATED)
463 cont = "C_UPDATED";
464 if (value == ATS_Q_UPDATED)
465 cont = "Q_UPDATED";
466 if (value == ATS_QC_UPDATED)
467 cont = "QC_UPDATED";
468 if (value == ATS_UNMODIFIED)
469 cont = "UNMODIFIED";
470 if (printed == GNUNET_NO)
471 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
472 "[%i] ATS state: %s\n", count, cont);
473 }
464 } 474 }
465 return GNUNET_OK; 475 return GNUNET_OK;
466} 476}
467 477
468 478
469void 479static void
470stats_get_task (void *cls, 480stats_get_task (void *cls,
471 const struct GNUNET_SCHEDULER_TaskContext *tc) 481 const struct GNUNET_SCHEDULER_TaskContext *tc)
472{ 482{
473 stats_task = GNUNET_SCHEDULER_NO_TASK; 483 stats_task = GNUNET_SCHEDULER_NO_TASK;
474 if ( (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0) 484 if ( (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0)
475 return; 485 return;
476 486
477 s_time = GNUNET_STATISTICS_get (stats, "transport", "ATS timestamp", TIMEOUT, NULL, &stats_cb, NULL); 487 s_time = GNUNET_STATISTICS_get (stats, "transport", "ATS timestamp", TIMEOUT, NULL, &stats_cb, NULL);
478 s_solution = GNUNET_STATISTICS_get (stats, "transport", "ATS solution", TIMEOUT, NULL, &stats_cb, NULL); 488 s_solution = GNUNET_STATISTICS_get (stats, "transport", "ATS solution", TIMEOUT, NULL, &stats_cb, NULL);
479 s_duration = GNUNET_STATISTICS_get (stats, "transport","ATS duration", TIMEOUT, NULL, &stats_cb, NULL); 489 s_duration = GNUNET_STATISTICS_get (stats, "transport","ATS duration", TIMEOUT, NULL, &stats_cb, NULL);
480 s_peers = GNUNET_STATISTICS_get (stats, "transport", "ATS peers", TIMEOUT, NULL, &stats_cb, NULL); 490 s_peers = GNUNET_STATISTICS_get (stats, "transport", "ATS peers", TIMEOUT, NULL, &stats_cb, NULL);
481 s_mechs = GNUNET_STATISTICS_get (stats, "transport", "ATS mechanisms", TIMEOUT, NULL, &stats_cb, NULL); 491 s_mechs = GNUNET_STATISTICS_get (stats, "transport", "ATS mechanisms", TIMEOUT, NULL, &stats_cb, NULL);
482 s_invalid = GNUNET_STATISTICS_get (stats, "transport", "ATS invalid solutions", TIMEOUT, NULL, &stats_cb, NULL); 492 s_invalid = GNUNET_STATISTICS_get (stats, "transport", "ATS invalid solutions", TIMEOUT, NULL, &stats_cb, NULL);
483 s_state = GNUNET_STATISTICS_get (stats, "transport", "ATS state", TIMEOUT, NULL, &stats_cb, NULL); 493 s_state = GNUNET_STATISTICS_get (stats, "transport", "ATS state", TIMEOUT, NULL, &stats_cb, NULL);
484 494
485 stats_task = GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 100), &stats_get_task, NULL); 495 stats_task = GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 100),
496 &stats_get_task, NULL);
486} 497}
487 498
488void 499
500static void
489delay (void *cls, 501delay (void *cls,
490 const struct GNUNET_SCHEDULER_TaskContext *tc) 502 const struct GNUNET_SCHEDULER_TaskContext *tc)
491{ 503{
492 shutdown_task = GNUNET_SCHEDULER_NO_TASK; 504 shutdown_task = GNUNET_SCHEDULER_NO_TASK;
493 if ( (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0) 505 if ( (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0)
494 return; 506 return;
495
496#if VERBOSE 507#if VERBOSE
497 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Delay over\n"); 508 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
509 "Delay over\n");
498#endif 510#endif
499 shutdown_peers (); 511 shutdown_peers ();
500} 512}
501 513
502static void connect_peers() 514static void
515connect_peers()
503{ 516{
504 shutdown_task = GNUNET_SCHEDULER_add_delayed(DELAY, &delay, NULL); 517 shutdown_task = GNUNET_SCHEDULER_add_delayed(DELAY, &delay, NULL);
505
506} 518}
507 519
508size_t send_dummy_data_task (void *cls, size_t size, void *buf) 520static size_t
521send_dummy_data_task (void *cls, size_t size, void *buf)
509{ 522{
510 523 int s = sizeof (struct TestMessage);
511 int s = sizeof (struct TestMessage); 524 struct TestMessage hdr;
512 struct TestMessage hdr; 525
513 526 hdr.header.size = htons (s);
514 hdr.header.size = htons (s); 527 hdr.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_ATS);
515 hdr.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_ATS); 528 if (force_rebuild)
516 if (force_rebuild) 529 hdr.num = htonl (1);
517 hdr.num = htonl (1); 530 if (force_q_updates)
518 if (force_q_updates) 531 hdr.num = htonl (2);
519 hdr.num = htonl (2); 532 memcpy (buf,&hdr, s);
533 // GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Sent bytes: %i of %i\n", s, s);
534 t = NULL;
535 return s;
536}
520 537
521 538
522 memcpy (buf,&hdr, s); 539static void
523 // GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Sent bytes: %i of %i\n", s, s); 540send_task_f (void *cls,
524 t = NULL; 541 const struct GNUNET_SCHEDULER_TaskContext *tc)
525 return s; 542{
543 send_task = GNUNET_SCHEDULER_NO_TASK;
544 if ( (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0)
545 return;
546
547 if (t!=NULL)
548 {
549 GNUNET_TRANSPORT_notify_transmit_ready_cancel(t);
550 t = NULL;
551 }
552 // GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Sent bytes: %i to %s\n", size, GNUNET_i2s(&master_deamon->id));
553 if (send_msg == GNUNET_YES)
554 t = GNUNET_TRANSPORT_notify_transmit_ready(th,
555 &master_deamon->id,
556 sizeof (struct TestMessage), 0,
557 SEND_TIMEOUT,
558 &send_dummy_data_task, NULL);
559 send_task = GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS,1000),
560 &send_task_f, NULL);
526} 561}
527 562
528void send_task_f (void *cls, 563static void
529 const struct GNUNET_SCHEDULER_TaskContext *tc) 564notify_connect (void *cls,
565 const struct GNUNET_PeerIdentity *peer,
566 const struct GNUNET_TRANSPORT_ATS_Information *ats,
567 uint32_t ats_count)
530{ 568{
531 send_task = GNUNET_SCHEDULER_NO_TASK; 569 send_task = GNUNET_SCHEDULER_add_now(&send_task_f, NULL);
532 if ( (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0)
533 return;
534
535 if (t!=NULL)
536 {
537 GNUNET_TRANSPORT_notify_transmit_ready_cancel(t);
538 t = NULL;
539 }
540 // GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Sent bytes: %i to %s\n", size, GNUNET_i2s(&master_deamon->id));
541 if (send_msg == GNUNET_YES)
542 t = GNUNET_TRANSPORT_notify_transmit_ready(th, &master_deamon->id, sizeof (struct TestMessage), 0, SEND_TIMEOUT, &send_dummy_data_task, NULL);
543 send_task = GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS,1000), &send_task_f, NULL);
544} 570}
545 571
546 572static void
547 573notify_disconnect (void *cls,
548void daemon_connect_cb(void *cls, 574 const struct GNUNET_PeerIdentity *peer)
549 const struct GNUNET_PeerIdentity *first,
550 const struct GNUNET_PeerIdentity *second,
551 uint32_t distance,
552 const struct GNUNET_CONFIGURATION_Handle *first_cfg,
553 const struct GNUNET_CONFIGURATION_Handle *second_cfg,
554 struct GNUNET_TESTING_Daemon *first_daemon,
555 struct GNUNET_TESTING_Daemon *second_daemon,
556 const char *emsg)
557{ 575{
558 char * firstc = strdup(GNUNET_i2s(first)); 576 if (GNUNET_SCHEDULER_NO_TASK != send_task)
559 char * secondc = strdup(GNUNET_i2s(second)); 577 {
560 connected++; 578 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
561 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 579 "Disconnect event before transmission request could be scheduled!\n");
562 "Connected peers `%s'<->`%s' (%i/%i)\n", firstc, secondc, connected, peers-1); 580 GNUNET_SCHEDULER_cancel (send_task);
563 GNUNET_free(firstc); 581 send_task = GNUNET_SCHEDULER_NO_TASK;
564 GNUNET_free(secondc); 582 }
565 583 if (NULL != t)
566 if (((first_daemon == ping_deamon) || (second_daemon == ping_deamon)) && (master_deamon != NULL) && (ping_deamon != NULL)) 584 {
567 { 585 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
568 th = GNUNET_TRANSPORT_connect (ping_deamon->cfg,&ping_deamon->id, NULL, NULL,NULL, NULL); 586 "Disconnect event before transmission request could be completed!\n");
569 t = NULL; 587 GNUNET_TRANSPORT_notify_transmit_ready_cancel (t);
570 force_q_updates = GNUNET_YES; 588 t = NULL;
571 send_msg = GNUNET_YES; 589 }
572 send_task = GNUNET_SCHEDULER_add_now(&send_task_f, NULL);
573 }
574} 590}
575 591
576void cont_cb (void *cls, int success) 592static void
593daemon_connect_cb(void *cls,
594 const struct GNUNET_PeerIdentity *first,
595 const struct GNUNET_PeerIdentity *second,
596 uint32_t distance,
597 const struct GNUNET_CONFIGURATION_Handle *first_cfg,
598 const struct GNUNET_CONFIGURATION_Handle *second_cfg,
599 struct GNUNET_TESTING_Daemon *first_daemon,
600 struct GNUNET_TESTING_Daemon *second_daemon,
601 const char *emsg)
577{ 602{
578 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 603 char * firstc = strdup(GNUNET_i2s(first));
579 "STATS cont_cb: %i\n", success); 604 char * secondc = strdup(GNUNET_i2s(second));
605 connected++;
606 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
607 "Connected peers `%s'<->`%s' (%i/%i)\n",
608 firstc, secondc, connected, peers-1);
609 GNUNET_free(firstc);
610 GNUNET_free(secondc);
611
612 if ( ( (first_daemon == ping_deamon) ||
613 (second_daemon == ping_deamon) ) &&
614 (master_deamon != NULL) &&
615 (ping_deamon != NULL) )
616 {
617 th = GNUNET_TRANSPORT_connect (ping_deamon->cfg,
618 &ping_deamon->id,
619 NULL, NULL,
620 &notify_connect,
621 &notify_disconnect);
622 force_q_updates = GNUNET_YES;
623 send_msg = GNUNET_YES;
624 }
580} 625}
581 626
627
628
582static void 629static void
583daemon_start_cb (void *cls, 630daemon_start_cb (void *cls,
584 const struct GNUNET_PeerIdentity *id, 631 const struct GNUNET_PeerIdentity *id,
585 const struct GNUNET_CONFIGURATION_Handle *cfg, 632 const struct GNUNET_CONFIGURATION_Handle *cfg,
586 struct GNUNET_TESTING_Daemon *d, const char *emsg) 633 struct GNUNET_TESTING_Daemon *d, const char *emsg)
587{ 634{
588 if (id == NULL) 635 if (id == NULL)
589 { 636 {
590 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 637 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
591 "Start callback called with error (too long starting peers), aborting test!\n"); 638 "Start callback called with error (too long starting peers), aborting test!\n");
592 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Error from testing: `%s'\n"); 639 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
640 "Error from testing: `%s'\n");
593 failed_peers++; 641 failed_peers++;
594 if (failed_peers == peers_left) 642 if (failed_peers == peers_left)
595 { 643 {
@@ -603,29 +651,33 @@ daemon_start_cb (void *cls,
603 peers_left--; 651 peers_left--;
604 652
605 if (master_deamon == NULL) 653 if (master_deamon == NULL)
606 { 654 {
607 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Master peer `%s' '%s'\n", GNUNET_i2s(id), d->cfgfile); 655 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
608 656 "Master peer `%s' '%s'\n",
609 master_deamon = d; 657 GNUNET_i2s(id), d->cfgfile);
610 stats = GNUNET_STATISTICS_create("transport", master_deamon->cfg); 658 master_deamon = d;
611 GNUNET_assert (stats != NULL); 659 stats = GNUNET_STATISTICS_create("transport", master_deamon->cfg);
612 stats_task = GNUNET_SCHEDULER_add_now(&stats_get_task, NULL); 660 GNUNET_assert (stats != NULL);
613 } 661 stats_task = GNUNET_SCHEDULER_add_now(&stats_get_task, NULL);
662 }
614 else 663 else
615 { 664 {
616 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connecting peer `%s'\n", GNUNET_i2s(id), GNUNET_i2s(&master_deamon->id)); 665 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
617 GNUNET_TESTING_daemons_connect(d, master_deamon, TIMEOUT, 0, GNUNET_YES,&daemon_connect_cb, NULL); 666 "Connecting peer `%s'\n",
618 } 667 GNUNET_i2s(id), GNUNET_i2s(&master_deamon->id));
619 668 GNUNET_TESTING_daemons_connect(d, master_deamon, TIMEOUT, 0, GNUNET_YES,&daemon_connect_cb, NULL);
669 }
670
620 if (peers_left == 0) 671 if (peers_left == 0)
621 { 672 {
622 if (ping_deamon == NULL) 673 if (ping_deamon == NULL)
623 { 674 {
624 ping_deamon = d; 675 ping_deamon = d;
625 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Ping peer `%s' '%s'\n", GNUNET_i2s(id), d->cfgfile); 676 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
626 } 677 "Ping peer `%s' '%s'\n", GNUNET_i2s(id), d->cfgfile);
627 678 }
628 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 679
680 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
629 "All peers started successfully!\n"); 681 "All peers started successfully!\n");
630 connect_peers(); 682 connect_peers();
631 ok = 0; 683 ok = 0;
@@ -661,6 +713,7 @@ run (void *cls,
661 GNUNET_assert (pg != NULL); 713 GNUNET_assert (pg != NULL);
662} 714}
663 715
716
664static int 717static int
665check () 718check ()
666{ 719{
@@ -681,10 +734,10 @@ check ()
681 return ok; 734 return ok;
682} 735}
683 736
737
684int 738int
685main (int argc, char *argv[]) 739main (int argc, char *argv[])
686{ 740{
687
688 int ret; 741 int ret;
689 742
690 GNUNET_log_setup ("test-transport-ats", 743 GNUNET_log_setup ("test-transport-ats",
@@ -696,40 +749,38 @@ main (int argc, char *argv[])
696 NULL); 749 NULL);
697 750
698#if !HAVE_LIBGLPK 751#if !HAVE_LIBGLPK
699 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "GLPK not installed, exiting testcase\n"); 752 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
700 return 0; 753 "GLPK not installed, exiting testcase\n");
754 return 0;
701#endif 755#endif
702
703 GNUNET_DISK_directory_remove ("/tmp/test-gnunet-testing"); 756 GNUNET_DISK_directory_remove ("/tmp/test-gnunet-testing");
704
705
706 machine_parsable = GNUNET_NO; 757 machine_parsable = GNUNET_NO;
707 peers = NUM_PEERS; 758 peers = NUM_PEERS;
708 config_file = "test_transport_ats_4addr.conf"; 759 config_file = "test_transport_ats_4addr.conf";
709 760
710 int c = 0; 761 int c = 0;
711 if (argc >= 2) 762 if (argc >= 2)
712 { 763 {
713 for (c=0; c<argc; c++) 764 for (c=0; c<argc; c++)
714 { 765 {
715 /* set peers */ 766 /* set peers */
716 if ((strcmp(argv[c], "-p") == 0) && c < (argc-1)) 767 if ((strcmp(argv[c], "-p") == 0) && c < (argc-1))
717 { 768 {
718 peers = atoi(argv[c+1]); 769 peers = atoi(argv[c+1]);
719 peers++; 770 peers++;
720 } 771 }
721 /* set machine parsable */ 772 /* set machine parsable */
722 if (strcmp(argv[c], "-m") == 0) 773 if (strcmp(argv[c], "-m") == 0)
723 { 774 {
724 machine_parsable = GNUNET_YES; 775 machine_parsable = GNUNET_YES;
725 } 776 }
726 /* set config file */ 777 /* set config file */
727 if ((strcmp(argv[c], "-c") == 0) && c < (argc-1)) 778 if ((strcmp(argv[c], "-c") == 0) && c < (argc-1))
728 { 779 {
729 config_file = argv[c+1]; 780 config_file = argv[c+1];
730 } 781 }
731 } 782 }
732 } 783 }
733 784
734 785
735 786