gnunet_transport_SOURCES = \
gnunet-transport.c
gnunet_transport_LDADD = \
- $(top_builddir)/src/transport/libgnunettransport.la \
+ $(top_builddir)/src/transport/libgnunettransportnew.la \
$(top_builddir)/src/util/libgnunetutil.la \
$(GN_LIBINTL)
gnunet_transport_DEPENDENCIES = \
- libgnunettransport.la
+ libgnunettransportnew.la
if HAVE_LIBGLPK
GN_GLPK = -lglpk
$(top_builddir)/src/util/libgnunetutil.la \
$(GN_GLPK) \
$(GN_LIBINTL)
-gnunet_service_transport_DEPENDENCIES = \
- libgnunettransport.la
plugin_LTLIBRARIES = \
libgnunet_plugin_transport_tcp.la \
test_transport_ats_SOURCES = \
test_transport_ats.c
test_transport_ats_LDADD = -lm \
- $(top_builddir)/src/transport/libgnunettransport.la \
+ $(top_builddir)/src/transport/libgnunettransportnew.la \
$(top_builddir)/src/statistics/libgnunetstatistics.la \
$(top_builddir)/src/testing/libgnunettesting.la \
$(top_builddir)/src/util/libgnunetutil.la
perf_transport_ats_SOURCES = \
perf_transport_ats.c
perf_transport_ats_LDADD = \
- $(top_builddir)/src/transport/libgnunettransport.la \
- $(top_builddir)/src/statistics/libgnunetstatistics.la \
- $(top_builddir)/src/testing/libgnunettesting.la \
$(GN_GLPK) \
$(top_builddir)/src/util/libgnunetutil.la
test_transport_api_reliability_tcp_SOURCES = \
test_transport_api_reliability.c
test_transport_api_reliability_tcp_LDADD = \
- $(top_builddir)/src/transport/libgnunettransport.la \
+ $(top_builddir)/src/transport/libgnunettransportnew.la \
$(top_builddir)/src/hello/libgnunethello.la \
$(top_builddir)/src/util/libgnunetutil.la
test_transport_api_reliability_tcp_nat_SOURCES = \
test_transport_api_reliability.c
test_transport_api_reliability_tcp_nat_LDADD = \
- $(top_builddir)/src/transport/libgnunettransport.la \
+ $(top_builddir)/src/transport/libgnunettransportnew.la \
$(top_builddir)/src/hello/libgnunethello.la \
$(top_builddir)/src/util/libgnunetutil.la
test_transport_api_reliability_wlan_SOURCES = \
test_transport_api_reliability.c
test_transport_api_reliability_wlan_LDADD = \
- $(top_builddir)/src/transport/libgnunettransport.la \
+ $(top_builddir)/src/transport/libgnunettransportnew.la \
$(top_builddir)/src/hello/libgnunethello.la \
$(top_builddir)/src/util/libgnunetutil.la
test_transport_api_unreliability_wlan_SOURCES = \
test_transport_api_unreliability.c
test_transport_api_unreliability_wlan_LDADD = \
- $(top_builddir)/src/transport/libgnunettransport.la \
+ $(top_builddir)/src/transport/libgnunettransportnew.la \
$(top_builddir)/src/hello/libgnunethello.la \
$(top_builddir)/src/util/libgnunetutil.la
test_plugin_transport_http_SOURCES = \
test_plugin_transport_http.c
test_plugin_transport_http_LDADD = \
- $(top_builddir)/src/transport/libgnunettransport.la \
$(top_builddir)/src/statistics/libgnunetstatistics.la \
@LIBCURL@ \
$(top_builddir)/src/hello/libgnunethello.la \
test_transport_api_reliability_http_SOURCES = \
test_transport_api_reliability.c
test_transport_api_reliability_http_LDADD = \
- $(top_builddir)/src/transport/libgnunettransport.la \
+ $(top_builddir)/src/transport/libgnunettransportnew.la \
$(top_builddir)/src/hello/libgnunethello.la \
$(top_builddir)/src/util/libgnunetutil.la
test_plugin_transport_https_SOURCES = \
test_plugin_transport_https.c
test_plugin_transport_https_LDADD = \
- $(top_builddir)/src/transport/libgnunettransport.la \
$(top_builddir)/src/statistics/libgnunetstatistics.la \
@LIBCURL@ \
$(top_builddir)/src/hello/libgnunethello.la \
test_transport_api_reliability_https_SOURCES = \
test_transport_api_reliability.c
test_transport_api_reliability_https_LDADD = \
- $(top_builddir)/src/transport/libgnunettransport.la \
+ $(top_builddir)/src/transport/libgnunettransportnew.la \
$(top_builddir)/src/hello/libgnunethello.la \
$(top_builddir)/src/util/libgnunetutil.la
test_transport_api_unreliability_unix_SOURCES = \
test_transport_api_unreliability.c
test_transport_api_unreliability_unix_LDADD = \
- $(top_builddir)/src/transport/libgnunettransport.la \
+ $(top_builddir)/src/transport/libgnunettransportnew.la \
$(top_builddir)/src/hello/libgnunethello.la \
$(top_builddir)/src/util/libgnunetutil.la
test_transport_api_unreliability_udp_SOURCES = \
test_transport_api_unreliability.c
test_transport_api_unreliability_udp_LDADD = \
- $(top_builddir)/src/transport/libgnunettransport.la \
+ $(top_builddir)/src/transport/libgnunettransportnew.la \
$(top_builddir)/src/hello/libgnunethello.la \
$(top_builddir)/src/util/libgnunetutil.la
test_quota_compliance_tcp_SOURCES = \
test_quota_compliance.c
test_quota_compliance_tcp_LDADD = \
- $(top_builddir)/src/transport/libgnunettransport.la \
+ $(top_builddir)/src/transport/libgnunettransportnew.la \
$(top_builddir)/src/hello/libgnunethello.la \
$(top_builddir)/src/util/libgnunetutil.la
test_quota_compliance_tcp_asymmetric_recv_constant_SOURCES = \
test_quota_compliance.c
test_quota_compliance_tcp_asymmetric_recv_constant_LDADD = \
- $(top_builddir)/src/transport/libgnunettransport.la \
+ $(top_builddir)/src/transport/libgnunettransportnew.la \
$(top_builddir)/src/hello/libgnunethello.la \
$(top_builddir)/src/util/libgnunetutil.la
#test_quota_compliance_tcp_asymmetric_send_constant_SOURCES = \
# test_quota_compliance.c
#test_quota_compliance_tcp_asymmetric_send_constant_LDADD = \
-# $(top_builddir)/src/transport/libgnunettransport.la \
+# $(top_builddir)/src/transport/libgnunettransportnew.la \
# $(top_builddir)/src/util/libgnunetutil.la
test_quota_compliance_http_SOURCES = \
test_quota_compliance.c
test_quota_compliance_http_LDADD = \
- $(top_builddir)/src/transport/libgnunettransport.la \
+ $(top_builddir)/src/transport/libgnunettransportnew.la \
$(top_builddir)/src/hello/libgnunethello.la \
$(top_builddir)/src/util/libgnunetutil.la
test_quota_compliance_http_asymmetric_recv_constant_SOURCES = \
test_quota_compliance.c
test_quota_compliance_http_asymmetric_recv_constant_LDADD = \
- $(top_builddir)/src/transport/libgnunettransport.la \
+ $(top_builddir)/src/transport/libgnunettransportnew.la \
$(top_builddir)/src/hello/libgnunethello.la \
$(top_builddir)/src/util/libgnunetutil.la
#test_quota_compliance_http_asymmetric_send_constant_SOURCES = \
# test_quota_compliance.c
#test_quota_compliance_http_asymmetric_send_constant_LDADD = \
-# $(top_builddir)/src/transport/libgnunettransport.la \
+# $(top_builddir)/src/transport/libgnunettransportnew.la \
# $(top_builddir)/src/util/libgnunetutil.la
test_quota_compliance_https_SOURCES = \
test_quota_compliance.c
test_quota_compliance_https_LDADD = \
- $(top_builddir)/src/transport/libgnunettransport.la \
+ $(top_builddir)/src/transport/libgnunettransportnew.la \
$(top_builddir)/src/hello/libgnunethello.la \
$(top_builddir)/src/util/libgnunetutil.la
test_quota_compliance_https_asymmetric_recv_constant_SOURCES = \
test_quota_compliance.c
test_quota_compliance_https_asymmetric_recv_constant_LDADD = \
- $(top_builddir)/src/transport/libgnunettransport.la \
+ $(top_builddir)/src/transport/libgnunettransportnew.la \
$(top_builddir)/src/hello/libgnunethello.la \
$(top_builddir)/src/util/libgnunetutil.la
#test_quota_compliance_https_asymmetric_send_constant_SOURCES = \
# test_quota_compliance.c
#test_quota_compliance_https_asymmetric_send_constant_LDADD = \
-# $(top_builddir)/src/transport/libgnunettransport.la \
+# $(top_builddir)/src/transport/libgnunettransportnew.la \
# $(top_builddir)/src/util/libgnunetutil.la
test_quota_compliance_udp_SOURCES = \
test_quota_compliance.c
test_quota_compliance_udp_LDADD = \
- $(top_builddir)/src/transport/libgnunettransport.la \
+ $(top_builddir)/src/transport/libgnunettransportnew.la \
$(top_builddir)/src/hello/libgnunethello.la \
$(top_builddir)/src/util/libgnunetutil.la
test_quota_compliance_udp_asymmetric_recv_constant_SOURCES = \
test_quota_compliance.c
test_quota_compliance_udp_asymmetric_recv_constant_LDADD = \
- $(top_builddir)/src/transport/libgnunettransport.la \
+ $(top_builddir)/src/transport/libgnunettransportnew.la \
$(top_builddir)/src/hello/libgnunethello.la \
$(top_builddir)/src/util/libgnunetutil.la
#test_quota_compliance_udp_asymmetric_send_constant_SOURCES = \
# test_quota_compliance.c
#test_quota_compliance_udp_asymmetric_send_constant_LDADD = \
-# $(top_builddir)/src/transport/libgnunettransport.la \
+# $(top_builddir)/src/transport/libgnunettransportnew.la \
# $(top_builddir)/src/util/libgnunetutil.la
test_quota_compliance_unix_SOURCES = \
test_quota_compliance.c
test_quota_compliance_unix_LDADD = \
- $(top_builddir)/src/transport/libgnunettransport.la \
+ $(top_builddir)/src/transport/libgnunettransportnew.la \
$(top_builddir)/src/hello/libgnunethello.la \
$(top_builddir)/src/util/libgnunetutil.la
test_quota_compliance_unix_asymmetric_recv_constant_SOURCES = \
test_quota_compliance.c
test_quota_compliance_unix_asymmetric_recv_constant_LDADD = \
- $(top_builddir)/src/transport/libgnunettransport.la \
+ $(top_builddir)/src/transport/libgnunettransportnew.la \
$(top_builddir)/src/hello/libgnunethello.la \
$(top_builddir)/src/util/libgnunetutil.la
$(top_builddir)/src/util/libgnunetutil.la
EXTRA_DIST = \
gnunet-transport-certificate-creation \
+ ats_mlp_p100_m400.problem \
test_transport_api_data.conf \
test_transport_api_tcp_peer1.conf \
test_transport_api_tcp_peer2.conf \
/*
This file is part of GNUnet.
- (C) 2009 Christian Grothoff (and other contributing authors)
+ (C) 2010, 2011 Christian Grothoff (and other contributing authors)
GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
Boston, MA 02111-1307, USA.
*/
/**
- * @file testing/per_transport_ats.c
+ * @file testing/perf_transport_ats.c
* @brief testcase for ats functionality
*/
#include "platform.h"
static struct GNUNET_TIME_Absolute end;
-void solve_mlp(int presolve)
+static void
+solve_mlp(int presolve)
{
- int result, solution;
-
- glp_iocp opt_mlp;
- glp_init_iocp(&opt_mlp);
- opt_mlp.msg_lev = GLP_MSG_OFF;
- opt_mlp.presolve = GLP_OFF;
-
- result = glp_intopt (prob, &opt_mlp);
- solution = glp_mip_status (prob);
- GNUNET_assert ((solution == 5) && (result==0));
+ int result, solution;
+
+ glp_iocp opt_mlp;
+ glp_init_iocp(&opt_mlp);
+ opt_mlp.msg_lev = GLP_MSG_OFF;
+ opt_mlp.presolve = GLP_OFF;
+
+ result = glp_intopt (prob, &opt_mlp);
+ solution = glp_mip_status (prob);
+ GNUNET_assert ((solution == 5) && (result==0));
}
-void solve_lp(int presolve)
+static void
+solve_lp(int presolve)
{
- int result, solution;
-
- glp_smcp opt_lp;
- glp_init_smcp(&opt_lp);
-
- opt_lp.msg_lev = GLP_MSG_OFF;
- if (presolve==GNUNET_YES) opt_lp.presolve = GLP_ON;
- else opt_lp.presolve = GLP_OFF;
-
- result = glp_simplex(prob, &opt_lp);
- solution = glp_get_status (prob);
- GNUNET_assert ((solution == 5) && (result==0));
+ int result, solution;
+
+ glp_smcp opt_lp;
+ glp_init_smcp(&opt_lp);
+
+ opt_lp.msg_lev = GLP_MSG_OFF;
+ if (presolve==GNUNET_YES) opt_lp.presolve = GLP_ON;
+ else opt_lp.presolve = GLP_OFF;
+
+ result = glp_simplex(prob, &opt_lp);
+ solution = glp_get_status (prob);
+ GNUNET_assert ((solution == 5) && (result==0));
}
+#if 0
/* Modify quality constraint */
-void modify_qm(int start, int length, int values_to_change)
+static void
+modify_qm(int start, int length, int values_to_change)
{
- //int * ind = GNUNET_malloc (length * sizeof (int));
- //double *val = GNUNET_malloc (length * sizeof (double));
- int ind[1000];
- double val[1000];
-
- int res = 0;
- int c = start, c2=1;
- while (c<=(start+values_to_change))
+ //int * ind = GNUNET_malloc (length * sizeof (int));
+ //double *val = GNUNET_malloc (length * sizeof (double));
+ int ind[1000];
+ double val[1000];
+
+ int res = 0;
+ int c = start, c2=1;
+ while (c<=(start+values_to_change))
+ {
+ res = glp_get_mat_row(prob, c, ind, val);
+
+ printf("%i %i \n", c, res);
+ for (c2=0; c2<res; c2++)
{
- res = glp_get_mat_row(prob, c, ind, val);
-
- printf("%i %i \n", c, res);
- for (c2=0; c2<res; c2++)
- {
- printf("%i = %f \n", ind[c2], val[c2]);
- }
-
- c++;
+ printf("%i = %f \n", ind[c2], val[c2]);
}
- //glp_set_mat_row(prob, start, length, ind, val);
+
+ c++;
+ }
+ //glp_set_mat_row(prob, start, length, ind, val);
}
+#endif
-
-void bench_simplex_optimization(char * file, int executions)
+static void
+bench_simplex_optimization(char * file, int executions)
{
-
- int c;
- prob = glp_create_prob();
- glp_read_lp(prob, NULL, file);
-
- solve_lp(GNUNET_YES);
-
- for (c=0; c<executions;c++)
- {
- start = GNUNET_TIME_absolute_get();
- solve_lp(GNUNET_NO);
- end = GNUNET_TIME_absolute_get();
-
- exec_time[c] = GNUNET_TIME_absolute_get_difference(start, end).rel_value;
-
- sim_with_opt_avg += exec_time[c];
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Simplex /w optimization iterations %i: %llu \n", c, exec_time[c]);
- }
-
- glp_delete_prob(prob);
+
+ int c;
+ prob = glp_create_prob();
+ glp_read_lp(prob, NULL, file);
+
+ solve_lp(GNUNET_YES);
+
+ for (c=0; c<executions;c++)
+ {
+ start = GNUNET_TIME_absolute_get();
+ solve_lp(GNUNET_NO);
+ end = GNUNET_TIME_absolute_get();
+
+ exec_time[c] = GNUNET_TIME_absolute_get_difference(start, end).rel_value;
+
+ sim_with_opt_avg += exec_time[c];
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Simplex /w optimization iterations %i: %llu \n",
+ c, exec_time[c]);
+ }
+
+ glp_delete_prob(prob);
}
-void bench_simplex_no_optimization(char * file, int executions)
+static void
+bench_simplex_no_optimization(char * file, int executions)
{
-
- int c;
- prob = glp_create_prob();
- glp_read_lp(prob, NULL, file);
-
- for (c=0; c<executions;c++)
- {
- start = GNUNET_TIME_absolute_get();
- solve_lp(GNUNET_YES);
- end = GNUNET_TIME_absolute_get();
-
- exec_time[c] = GNUNET_TIME_absolute_get_difference(start, end).rel_value;
-
- sim_no_opt_avg += exec_time[c];
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Simplex iterations %i: %llu \n", c, exec_time[c]);
- }
-
- glp_delete_prob(prob);
+
+ int c;
+ prob = glp_create_prob();
+ glp_read_lp(prob, NULL, file);
+
+ for (c=0; c<executions;c++)
+ {
+ start = GNUNET_TIME_absolute_get();
+ solve_lp(GNUNET_YES);
+ end = GNUNET_TIME_absolute_get();
+
+ exec_time[c] = GNUNET_TIME_absolute_get_difference(start, end).rel_value;
+
+ sim_no_opt_avg += exec_time[c];
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Simplex iterations %i: %llu \n",
+ c, exec_time[c]);
+ }
+
+ glp_delete_prob(prob);
}
-void bench_mlp_no_optimization(char * file, int executions)
-{
-
- int c;
- prob = glp_create_prob();
- glp_read_lp(prob, NULL, file);
-
- for (c=0; c<executions;c++)
- {
- start = GNUNET_TIME_absolute_get();
- solve_lp(GNUNET_YES);
- solve_mlp (GNUNET_NO);
- end = GNUNET_TIME_absolute_get();
-
- exec_time[c] = GNUNET_TIME_absolute_get_difference(start, end).rel_value;
-
- mlp_no_opt_avg += exec_time[c];
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MLP iterations no optimization %i: %llu \n", c, exec_time[c]);
- }
- glp_delete_prob(prob);
+static void
+bench_mlp_no_optimization(char * file, int executions)
+{
+
+ int c;
+ prob = glp_create_prob();
+ glp_read_lp(prob, NULL, file);
+
+ for (c=0; c<executions;c++)
+ {
+ start = GNUNET_TIME_absolute_get();
+ solve_lp(GNUNET_YES);
+ solve_mlp (GNUNET_NO);
+ end = GNUNET_TIME_absolute_get();
+
+ exec_time[c] = GNUNET_TIME_absolute_get_difference(start, end).rel_value;
+
+ mlp_no_opt_avg += exec_time[c];
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MLP iterations no optimization %i: %llu \n", c, exec_time[c]);
+ }
+
+ glp_delete_prob(prob);
}
-void bench_mlp_with_optimization(char * file, int executions, int changes)
+static void
+bench_mlp_with_optimization(char * file, int executions, int changes)
{
- int c;
- prob = glp_create_prob();
- glp_read_lp(prob, NULL, file);
-
- solve_lp(GNUNET_YES);
-
- for (c=0; c<executions;c++)
- {
- start = GNUNET_TIME_absolute_get();
- //modify_qm(906, 0, 0);
- solve_lp(GNUNET_NO);
- solve_mlp (GNUNET_NO);
- end = GNUNET_TIME_absolute_get();
-
- exec_time[c] = GNUNET_TIME_absolute_get_difference(start, end).rel_value;
-
- mlp_with_opt_avg += exec_time[c];
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MLP /w optimization iterations %i: %llu \n", c, exec_time[c]);
- }
-
- glp_delete_prob(prob);
+ int c;
+ prob = glp_create_prob();
+ glp_read_lp(prob, NULL, file);
+
+ solve_lp(GNUNET_YES);
+
+ for (c=0; c<executions;c++)
+ {
+ start = GNUNET_TIME_absolute_get();
+ // modify_qm(906, 0, 0);
+ solve_lp(GNUNET_NO);
+ solve_mlp (GNUNET_NO);
+ end = GNUNET_TIME_absolute_get();
+
+ exec_time[c] = GNUNET_TIME_absolute_get_difference(start, end).rel_value;
+
+ mlp_with_opt_avg += exec_time[c];
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MLP /w optimization iterations %i: %llu \n", c, exec_time[c]);
+ }
+
+ glp_delete_prob(prob);
}
#if 0
-void modify_cr (int start, int length, int count)
+static void
+modify_cr (int start, int length, int count)
{
- //int * ind = GNUNET_malloc (length * sizeof (int));
- //double *val = GNUNET_malloc (length * sizeof (double));
- int ind[500];
- double val[500];
- int res = 0;
- int c = start, c2=1;
- while (c<=(start+count))
+ //int * ind = GNUNET_malloc (length * sizeof (int));
+ //double *val = GNUNET_malloc (length * sizeof (double));
+ int ind[500];
+ double val[500];
+ int res = 0;
+ int c = start, c2=1;
+ while (c<=(start+count))
+ {
+ res = glp_get_mat_row(prob, c, ind, val);
+
+ printf("row index: %i non-zero elements: %i \n", c, res);
+ for (c2=1; c2<=res; c2++)
{
- res = glp_get_mat_row(prob, c, ind, val);
-
- printf("row index: %i non-zero elements: %i \n", c, res);
- for (c2=1; c2<=res; c2++)
- {
- printf("%i = %f ", ind[c2], val[c2]);
- }
- c++;
- printf ("\n----\n");
+ printf("%i = %f ", ind[c2], val[c2]);
}
- //glp_set_mat_row(prob, start, length, ind, val);
+ c++;
+ printf ("\n----\n");
+ }
+ //glp_set_mat_row(prob, start, length, ind, val);
}
#endif
#endif
-int main (int argc, char *argv[])
+
+int
+main (int argc, char *argv[])
{
- int ret = 0;
- GNUNET_log_setup ("perf-transport-ats",
+ int ret = 0;
+ GNUNET_log_setup ("perf-transport-ats",
#if VERBOSE
"DEBUG",
#else
"INFO",
#endif
NULL);
-
+
#if !HAVE_LIBGLPK
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "GLPK not installed, exiting testcase\n");
- return 0;
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "GLPK not installed, exiting testcase\n");
+ return 0;
#else
-
+
char * file = "ats_mlp_p100_m400.problem";
- // char * file = "mlps/ats_mlp_p500_m2000.problem";
+ // char * file = "mlps/ats_mlp_p500_m2000.problem";
bench_simplex_no_optimization (file, executions);
bench_simplex_optimization (file, executions);
bench_mlp_no_optimization (file, executions);
bench_mlp_with_optimization (file, executions, 0);
-
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Simplex no optimization average: %llu\n", sim_no_opt_avg / EXECS);
+
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Simplex no optimization average: %llu\n",
+ sim_no_opt_avg / EXECS);
// -> 400 addresses
- GAUGER ("TRANSPORT","GLPK simplex no optimization", (sim_no_opt_avg / EXECS) / 400, "ms/address");
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Simplex, no optimization, average per peer: %llu\n", (sim_with_opt_avg / EXECS) / 400);
- GAUGER ("TRANSPORT","GLPK simplex, 100 peers 400 addresses with optimization", (sim_with_opt_avg / EXECS) / 400, "ms/address");
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MLP no optimization average: %llu\n", (mlp_no_opt_avg / EXECS) / 400);
- GAUGER ("TRANSPORT","GLPK MLP 100 peers 400 addresses no optimization", (mlp_no_opt_avg / EXECS) / 400, "ms/address");
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MLP optimization average: %llu\n", (mlp_with_opt_avg/ EXECS) / 400);
- GAUGER ("TRANSPORT","GLPK MLP 100 peers 400 addresses with optimization", (mlp_with_opt_avg / EXECS) / 400, "ms/address");
+ GAUGER ("GLPK",
+ "GLPK simplex no optimization",
+ (sim_no_opt_avg / EXECS) / 400,
+ "ms/address");
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Simplex, no optimization, average per peer: %llu\n",
+ (sim_with_opt_avg / EXECS) / 400);
+ GAUGER ("GLPK",
+ "GLPK simplex with optimization",
+ (sim_with_opt_avg / EXECS) / 400,
+ "ms/address");
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "MLP no optimization average: %llu\n",
+ (mlp_no_opt_avg / EXECS) / 400);
+ GAUGER ("GLPK",
+ "GLPK MLP no optimization",
+ (mlp_no_opt_avg / EXECS) / 400,
+ "ms/address");
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MLP optimization average: %llu\n",
+ (mlp_with_opt_avg/ EXECS) / 400);
+ GAUGER ("GLPK",
+ "GLPK MLP with optimization",
+ (mlp_with_opt_avg / EXECS) / 400, "ms/address");
#endif
return ret;
/* Evaluate results */
fail = 0;
- if ((fail_notify_address == GNUNET_YES) || (fail_pretty_printer == GNUNET_YES) || (fail_addr_to_str == GNUNET_YES))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Phase 0: Test plugin functions failed\n");
- fail = 1;
- }
- 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))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Phase 1: Test connect with wrong data failed\n");
- fail = 1;
- }
- 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))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Phase 2: Test session selection failed\n");
- fail = 1;
- }
- if ((fail_msgs_transmited_to_local_addrs != count_str_addr) || (fail_multiple_msgs_in_transmission != 2) || (fail_msg_transmited_max_size == GNUNET_YES))
+ if ( (fail_notify_address == GNUNET_YES) ||
+ (fail_pretty_printer == GNUNET_YES) ||
+ (fail_addr_to_str == GNUNET_YES))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Phase 0: Test plugin functions failed\n");
+ fail = 1;
+ }
+ 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) )
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Phase 3: Test sending with plugin failed\n");
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Phase 1: Test connect with wrong data failed\n");
fail = 1;
}
+ 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) )
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Phase 2: Test session selection failed\n");
+ fail = 1;
+ }
+ if ( (fail_msgs_transmited_to_local_addrs != count_str_addr) ||
+ (fail_multiple_msgs_in_transmission != 2) ||
+ (fail_msg_transmited_max_size == GNUNET_YES) )
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Phase 3: Test sending with plugin failed\n");
+ fail = 1;
+ }
if (fail != 1)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "All tests successful\n");
- }
-
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "All tests successful\n");
+ }
+
api->disconnect(api->cls,&my_identity);
curl_multi_cleanup(multi_handle);
}
GNUNET_free(test_addr);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Unloading http plugin\n");
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Unloading http plugin\n");
GNUNET_assert (NULL == GNUNET_PLUGIN_unload ("libgnunet_gnunet_transport_plugin_http", api));
GNUNET_SCHEDULER_shutdown();
GNUNET_DISK_directory_remove ("/tmp/test_gnunet_transport_plugin_http");
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Exiting testcase\n");
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Exiting testcase\n");
exit(fail);
return;
}
* @result GNUNET_OK or GNUNET_SYSERR
*/
-static void task_send_cont (void *cls,
- const struct GNUNET_PeerIdentity * target,
- int result)
+static void
+task_send_cont (void *cls,
+ const struct GNUNET_PeerIdentity * target,
+ int result)
{
if ((cls == &fail_msg_transmited_bigger_max_size) && (result == GNUNET_SYSERR))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Message bigger max msg size was not sent!\n");
- fail_msg_transmited_bigger_max_size = GNUNET_NO;
- return;
- }
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Message bigger max msg size was not sent!\n");
+ fail_msg_transmited_bigger_max_size = GNUNET_NO;
+ return;
+ }
if ((cls == &fail_msg_transmited_max_size) && (result == GNUNET_OK))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Message with max msg size succesfully sent!\n",fail_msgs_transmited_to_local_addrs);
- fail_msg_transmited_max_size = GNUNET_NO;
- }
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Message with max msg size succesfully sent!\n",
+ fail_msgs_transmited_to_local_addrs);
+ fail_msg_transmited_max_size = GNUNET_NO;
+ }
}
const char *sender_address,
uint16_t sender_address_len)
{
- 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);
-
- if ((ntohs(message->type)>=10) && (ntohs(message->type)<20))
- {
- fail_msgs_transmited_to_local_addrs++;
- if (fail_msgs_transmited_to_local_addrs == count_str_addr)
- run_connection_tests(2, session);
- }
-
-
+ 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);
+
+ if ( (ntohs(message->type)>=10) &&
+ (ntohs(message->type)<20) )
+ {
+ fail_msgs_transmited_to_local_addrs++;
+ if (fail_msgs_transmited_to_local_addrs == count_str_addr)
+ run_connection_tests(2, session);
+ }
if ((ntohs(message->type)==20))
- {
- fail_session_selection_reliable = GNUNET_NO;
- }
-
+ {
+ fail_session_selection_reliable = GNUNET_NO;
+ }
if ((ntohs(message->type)==21))
- {
- fail_session_selection_any = GNUNET_NO;
- }
+ {
+ fail_session_selection_any = GNUNET_NO;
+ }
if ((ntohs(message->type)==22))
- {
- fail_session_selection_session = GNUNET_NO;
- }
-
+ {
+ fail_session_selection_session = GNUNET_NO;
+ }
if ((ntohs(message->type)==23))
- {
- fail_session_selection_session_big = GNUNET_NO;
- run_connection_tests(3, NULL);
- }
-
+ {
+ fail_session_selection_session_big = GNUNET_NO;
+ run_connection_tests(3, NULL);
+ }
if ((ntohs(message->type)==30) || (ntohs(message->type)==31))
- {
- fail_multiple_msgs_in_transmission ++;
- }
-
+ {
+ fail_multiple_msgs_in_transmission ++;
+ }
if ((ntohs(message->type)==32) && (ntohs(message->size) == GNUNET_SERVER_MAX_MESSAGE_SIZE-1))
- {
- fail_msg_transmited_max_size = GNUNET_NO;
- shutdown_clean();
- }
-
+ {
+ fail_msg_transmited_max_size = GNUNET_NO;
+ shutdown_clean();
+ }
return GNUNET_TIME_UNIT_ZERO;
}
-static size_t send_function (void *stream, size_t size, size_t nmemb, void *ptr)
+
+static size_t
+send_function (void *stream, size_t size, size_t nmemb, void *ptr)
{
unsigned int len;
memcpy(stream, buffer_out.buf, len);
buffer_out.pos = len;
return len;
+
}
-static size_t recv_function (void *ptr, size_t size, size_t nmemb, void *ctx)
+static size_t
+recv_function (void *ptr, size_t size, size_t nmemb, void *ctx)
{
if (buffer_in.pos + size * nmemb > buffer_in.size)
return buffer_in.pos;
}
-static size_t header_function( void *ptr, size_t size, size_t nmemb, void *stream)
+static size_t
+header_function( void *ptr, size_t size, size_t nmemb, void *stream)
{
- struct HTTP_Transfer * res = (struct HTTP_Transfer *) stream;
+ struct HTTP_Transfer * res = stream;
char * tmp;
unsigned int len = size * nmemb;
if (tmp[len-2] == 13)
tmp[len-2]= '\0';
#if DEBUG_CURL
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Header: `%s'\n",tmp);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Header: `%s'\n",
+ tmp);
#endif
if (0==strcmp (tmp,"HTTP/1.1 100 Continue"))
- {
- res->http_result_code=100;
- }
+ {
+ res->http_result_code=100;
+ }
if (0==strcmp (tmp,"HTTP/1.1 200 OK"))
- {
- res->http_result_code=200;
- }
+ {
+ res->http_result_code=200;
+ }
if (0==strcmp (tmp,"HTTP/1.1 400 Bad Request"))
- {
- res->http_result_code=400;
- }
+ {
+ res->http_result_code=400;
+ }
if (0==strcmp (tmp,"HTTP/1.1 404 Not Found"))
- {
- res->http_result_code=404;
- }
+ {
+ res->http_result_code=404;
+ }
if (0==strcmp (tmp,"HTTP/1.1 413 Request entity too large"))
- {
- res->http_result_code=413;
- }
-
+ {
+ res->http_result_code=413;
+ }
+
GNUNET_free (tmp);
return size * nmemb;
}
-static size_t send_prepare( struct HTTP_Transfer * result);
+static size_t
+send_prepare( struct HTTP_Transfer * result);
-static void send_execute (void *cls,
- const struct GNUNET_SCHEDULER_TaskContext *tc)
+static void
+send_execute (void *cls,
+ const struct GNUNET_SCHEDULER_TaskContext *tc)
{
struct HTTP_Transfer *res;
if (res == &test_no_ident)
{
if ((res->http_result_code==404) && (buffer_in.len==208))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connecting to peer without any peer identification: test passed\n");
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Connecting to peer without any peer identification: test passed\n");
res->test_failed = GNUNET_NO;
}
else
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Connecting to peer without any peer identification: test failed\n"));
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ _("Connecting to peer without any peer identification: test failed\n"));
}
if (res == &test_too_short_ident)
{
if ((res->http_result_code==404) && (buffer_in.len==208))
{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connecting to peer with too short peer identification: test passed\n");
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Connecting to peer with too short peer identification: test passed\n");
res->test_failed = GNUNET_NO;
}
else
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Connecting to peer with too short peer identification: test failed\n"));
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ _("Connecting to peer with too short peer identification: test failed\n"));
}
if (res == &test_too_long_ident)
{
if ((res->http_result_code==404) && (buffer_in.len==208))
{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connecting to peer with too long peer identification: test passed\n");
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Connecting to peer with too long peer identification: test passed\n");
res->test_failed = GNUNET_NO;
}
else
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Connecting to peer with too long peer identification: test failed\n"));
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ _("Connecting to peer with too long peer identification: test failed\n"));
}
if (res == &test_valid_ident)
{
if ((res->http_result_code==200))
{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connecting to peer with valid peer identification: test passed\n");
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Connecting to peer with valid peer identification: test passed\n");
res->test_failed = GNUNET_NO;
}
else
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Connecting to peer with valid peer identification: test failed\n");
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Connecting to peer with valid peer identification: test failed\n");
}
curl_easy_cleanup(curl_handle);
curl_handle=NULL;
send_prepare(cls);
}
+
/**
* Function setting up file descriptors and scheduling task to run
* @param ses session to send data to
* @return bytes sent to peer
*/
-static size_t send_prepare( struct HTTP_Transfer * result)
+static size_t
+send_prepare( struct HTTP_Transfer * result)
{
fd_set rs;
fd_set ws;
GNUNET_NETWORK_fdset_copy_native (grs, &rs, max + 1);
GNUNET_NETWORK_fdset_copy_native (gws, &ws, max + 1);
http_task_send = GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT,
- GNUNET_SCHEDULER_NO_TASK,
- GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 0),
- grs,
- gws,
- &send_execute,
- result);
+ GNUNET_SCHEDULER_NO_TASK,
+ GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 0),
+ grs,
+ gws,
+ &send_execute,
+ result);
GNUNET_NETWORK_fdset_destroy (gws);
GNUNET_NETWORK_fdset_destroy (grs);
/**
* function to send data to server
*/
-static int send_data( struct HTTP_Transfer * result, char * url)
+static int
+send_data(struct HTTP_Transfer * result,
+ char * url)
{
curl_handle = curl_easy_init();
if( NULL == curl_handle)
- {
- printf("easy_init failed \n");
- return GNUNET_SYSERR;
- }
+ {
+ printf("easy_init failed \n");
+ return GNUNET_SYSERR;
+ }
#if DEBUG_CURL
curl_easy_setopt(curl_handle, CURLOPT_VERBOSE, 1L);
#endif
/**
* Plugin notifies transport (aka testcase) about its addresses
*/
-void
+static void
notify_address (void *cls,
const char *name,
const void *addr,
}
static void
-plugin_env_session_end (void *cls,
- const struct GNUNET_PeerIdentity *peer,
- struct Session *session)
+plugin_env_session_end (void *cls,
+ const struct GNUNET_PeerIdentity *peer,
+ struct Session *session)
{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Pluging tells me: session %X to peer `%s' ended\n", session, GNUNET_i2s(peer));
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Pluging tells me: session %X to peer `%s' ended\n",
+ session,
+ GNUNET_i2s(peer));
}
return;
}
-static void pretty_printer_cb (void *cls,
- const char *address)
+
+static void
+pretty_printer_cb (void *cls,
+ const char *address)
{
if (NULL==address)
return;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Plugin returned pretty address: `%s'\n",address);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Plugin returned pretty address: `%s'\n",
+ address);
fail_pretty_printer_count++;
}
/**
* Runs every single test to test the plugin
*/
-static void run_connection_tests( int phase , void * cls)
+static void
+run_connection_tests( int phase , void * cls)
{
struct GNUNET_MessageHeader * msg;
unsigned int size;
buffer_out.len = 0;
if (test_no_ident.test_executed == GNUNET_NO)
- {
- /* Connecting to peer without identification */
- char * ident = "";
- GNUNET_asprintf (&host_str, "%s://%s/%s",PROTOCOL_PREFIX, test_addr,ident);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Connecting to peer without any peer identification.\n"));
- test_no_ident.test_executed = GNUNET_YES;
- send_data ( &test_no_ident, host_str);
- GNUNET_free (host_str);
- return;
- }
+ {
+ /* Connecting to peer without identification */
+ const char * ident = "";
+ GNUNET_asprintf (&host_str,
+ "%s://%s/%s",
+ PROTOCOL_PREFIX,
+ test_addr,ident);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ _("Connecting to peer without any peer identification.\n"));
+ test_no_ident.test_executed = GNUNET_YES;
+ send_data ( &test_no_ident, host_str);
+ GNUNET_free (host_str);
+ return;
+ }
if (test_too_short_ident.test_executed == GNUNET_NO)
- {
- char * ident = "AAAAAAAAAA";
- /* Connecting to peer with too short identification */
- GNUNET_asprintf (&host_str, "%s://%s/%s",PROTOCOL_PREFIX,test_addr,ident);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Connecting to peer with too short peer identification.\n"));
- test_too_short_ident.test_executed = GNUNET_YES;
- send_data ( &test_too_short_ident, host_str);
- GNUNET_free (host_str);
- return;
- }
+ {
+ const char * ident = "AAAAAAAAAA";
+ /* Connecting to peer with too short identification */
+ GNUNET_asprintf (&host_str,
+ "%s://%s/%s",
+ PROTOCOL_PREFIX,
+ test_addr,
+ ident);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ _("Connecting to peer with too short peer identification.\n"));
+ test_too_short_ident.test_executed = GNUNET_YES;
+ send_data ( &test_too_short_ident, host_str);
+ GNUNET_free (host_str);
+ return;
+ }
if (test_too_long_ident.test_executed == GNUNET_NO)
- {
- char * ident = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
-
- /* Connecting to peer with too long identification */
- GNUNET_asprintf (&host_str, "%s://%s/%s",PROTOCOL_PREFIX, test_addr,ident);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Connecting to peer with too long peer identification.\n"));
- test_too_long_ident.test_executed = GNUNET_YES;
- send_data ( &test_too_long_ident, host_str);
- GNUNET_free (host_str);
- return;
+ {
+ const char * ident = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
+
+ /* Connecting to peer with too long identification */
+ GNUNET_asprintf (&host_str, "%s://%s/%s",PROTOCOL_PREFIX, test_addr,ident);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ _("Connecting to peer with too long peer identification.\n"));
+ test_too_long_ident.test_executed = GNUNET_YES;
+ send_data ( &test_too_long_ident, host_str);
+ GNUNET_free (host_str);
+ return;
}
if (test_valid_ident.test_executed == GNUNET_NO)
- {
- struct GNUNET_CRYPTO_HashAsciiEncoded ident;
- GNUNET_CRYPTO_hash_to_enc(&my_identity.hashPubKey,&ident);
- GNUNET_asprintf (&host_str, "%s://%s/%s%s",PROTOCOL_PREFIX, test_addr,(char *) &ident,";0");
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Connecting to peer with valid peer identification.\n"));
- test_valid_ident.test_executed = GNUNET_YES;
- send_data ( &test_valid_ident, host_str);
- GNUNET_free (host_str);
- return;
- }
+ {
+ struct GNUNET_CRYPTO_HashAsciiEncoded ident;
+ GNUNET_CRYPTO_hash_to_enc(&my_identity.hashPubKey,&ident);
+ GNUNET_asprintf (&host_str,
+ "%s://%s/%s%s",
+ PROTOCOL_PREFIX,
+ test_addr,
+ (char *) &ident,
+ ";0");
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ _("Connecting to peer with valid peer identification.\n"));
+ test_valid_ident.test_executed = GNUNET_YES;
+ send_data ( &test_valid_ident, host_str);
+ GNUNET_free (host_str);
+ return;
+ }
}
if (phase==1)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "\nPhase 1: transmit data to all suggested addresses\n\n");
- /* Using one of the addresses the plugin proposed */
- GNUNET_assert (addr_head->addr != NULL);
-
- struct Plugin_Address * tmp_addr;
- struct GNUNET_MessageHeader msg;
- char * tmp = GNUNET_malloc(sizeof(struct GNUNET_MessageHeader));
- char address[INET6_ADDRSTRLEN];
- unsigned int port;
- unsigned int type = 10;
-
- msg.size=htons(sizeof(struct GNUNET_MessageHeader));
- tmp_addr = addr_head;
- /* send a message to all addresses advertised by plugin */
-
- int count = 0;
- while (tmp_addr != NULL)
{
- if (tmp_addr->addrlen == (sizeof (struct IPv4HttpAddress)))
- {
- inet_ntop(AF_INET, (struct in_addr *) tmp_addr->addr,address,INET_ADDRSTRLEN);
- port = ntohs(((struct IPv4HttpAddress *) tmp_addr->addr)->u_port);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Sending message to addres no. %u: `%s':%u\n", count,address, port);
- }
- if (tmp_addr->addrlen == (sizeof (struct IPv6HttpAddress)))
- {
- inet_ntop(AF_INET6, (struct in6_addr *) tmp_addr->addr,address,INET6_ADDRSTRLEN);
- port = ntohs(((struct IPv6HttpAddress *) tmp_addr->addr)->u6_port);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Sending message to addres no. %u: `%s':%u\n", count,address,port);
- }
- msg.type=htons(type);
- memcpy(tmp,&msg,sizeof(struct GNUNET_MessageHeader));
- 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);
- tmp_addr = tmp_addr->next;
-
- count ++;
- type ++;
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "\nPhase 1: transmit data to all suggested addresses\n\n");
+ /* Using one of the addresses the plugin proposed */
+ GNUNET_assert (addr_head->addr != NULL);
+
+ struct Plugin_Address * tmp_addr;
+ struct GNUNET_MessageHeader msg;
+ char * tmp = GNUNET_malloc(sizeof(struct GNUNET_MessageHeader));
+ char address[INET6_ADDRSTRLEN];
+ unsigned int port;
+ unsigned int type = 10;
+
+ msg.size=htons(sizeof(struct GNUNET_MessageHeader));
+ tmp_addr = addr_head;
+ /* send a message to all addresses advertised by plugin */
+
+ int count = 0;
+ while (tmp_addr != NULL)
+ {
+ if (tmp_addr->addrlen == (sizeof (struct IPv4HttpAddress)))
+ {
+ inet_ntop(AF_INET, (struct in_addr *) tmp_addr->addr,address,INET_ADDRSTRLEN);
+ port = ntohs(((struct IPv4HttpAddress *) tmp_addr->addr)->u_port);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Sending message to addres no. %u: `%s':%u\n",
+ count,
+ address,
+ port);
+ }
+ if (tmp_addr->addrlen == (sizeof (struct IPv6HttpAddress)))
+ {
+ inet_ntop(AF_INET6, (struct in6_addr *) tmp_addr->addr,address,INET6_ADDRSTRLEN);
+ port = ntohs(((struct IPv6HttpAddress *) tmp_addr->addr)->u6_port);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Sending message to addres no. %u: `%s':%u\n",
+ count,
+ address,
+ port);
+ }
+ msg.type=htons(type);
+ memcpy(tmp,&msg,sizeof(struct GNUNET_MessageHeader));
+ 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);
+ tmp_addr = tmp_addr->next;
+ count++;
+ type++;
+ }
+ GNUNET_free(tmp);
+ return;
}
- GNUNET_free(tmp);
- return;
- }
if (phase==2)
- {
- struct Session * session = cls;
- msg = GNUNET_malloc (sizeof(struct GNUNET_MessageHeader));
-
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Phase 2: session selection\n\n");
- size = sizeof(struct GNUNET_MessageHeader);
- msg->size=htons(size);
- msg->type = htons(20);
- api->send(api->cls, &my_identity, (const char *) msg, size, 0, TIMEOUT, NULL, NULL, 0, GNUNET_NO, &task_send_cont, NULL);
-
- msg->type = htons(21);
- api->send(api->cls, &my_identity, (const char *) msg, size, 0, TIMEOUT, NULL, NULL, 0, GNUNET_SYSERR, &task_send_cont, NULL);
-
- /* answer on session*/
- size = sizeof( struct GNUNET_MessageHeader);
- msg->size = htons(size);
- msg->type = htons(22);
- api->send(api->cls, &my_identity, (const char *) msg, size, 0, TIMEOUT, session, NULL, 0, GNUNET_SYSERR, &task_send_cont, NULL);
-
- GNUNET_free(msg);
-
- /* answer on session with big message not fitting in mhd send buffer*/
- size = GNUNET_SERVER_MAX_MESSAGE_SIZE-1;
- msg = GNUNET_malloc (size);
- msg->size=htons(size);
- msg->type = htons(23);
- api->send(api->cls, &my_identity, (const char *) msg, size, 0, TIMEOUT, session, NULL, 0, GNUNET_NO, &task_send_cont, NULL);
- GNUNET_free(msg);
- return;
- }
-
+ {
+ struct Session * session = cls;
+ msg = GNUNET_malloc (sizeof(struct GNUNET_MessageHeader));
+
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Phase 2: session selection\n\n");
+ size = sizeof(struct GNUNET_MessageHeader);
+ msg->size=htons(size);
+ msg->type = htons(20);
+ api->send(api->cls,
+ &my_identity,
+ (const char *) msg, size,
+ 0, TIMEOUT, NULL, NULL, 0, GNUNET_NO,
+ &task_send_cont, NULL);
+
+ msg->type = htons(21);
+ api->send(api->cls,
+ &my_identity,
+ (const char *) msg, size,
+ 0, TIMEOUT, NULL, NULL, 0, GNUNET_SYSERR,
+ &task_send_cont, NULL);
+
+ /* answer on session*/
+ size = sizeof( struct GNUNET_MessageHeader);
+ msg->size = htons(size);
+ msg->type = htons(22);
+ api->send(api->cls,
+ &my_identity,
+ (const char *) msg, size,
+ 0, TIMEOUT, session, NULL, 0, GNUNET_SYSERR,
+ &task_send_cont, NULL);
+ GNUNET_free(msg);
+
+ /* answer on session with big message not fitting in mhd send buffer*/
+ size = GNUNET_SERVER_MAX_MESSAGE_SIZE-1;
+ msg = GNUNET_malloc (size);
+ msg->size=htons(size);
+ msg->type = htons(23);
+ api->send(api->cls,
+ &my_identity,
+ (const char *) msg, size,
+ 0, TIMEOUT, session, NULL, 0, GNUNET_NO,
+ &task_send_cont, NULL);
+ GNUNET_free(msg);
+ return;
+ }
+
if (phase==3)
- {
-
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Phase 3: send multiple or big messages after disconnect\n\n");
+ {
+
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Phase 3: send multiple or big messages after disconnect\n\n");
/* disconnect from peer, so new connections are created */
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Disconnect from peer: `%s'\n", GNUNET_i2s(&my_identity));
api->disconnect(api->cls, &my_identity);
-
+
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Phase 3: sending messages\n");
/* send a multiple GNUNET_messages at a time*/
size = 2 * sizeof(struct GNUNET_MessageHeader);
struct GNUNET_MessageHeader * msg2 = &msg[2];
msg2->size = htons(2 * sizeof(struct GNUNET_MessageHeader));
msg2->type = htons(31);
- 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);
+ 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);
GNUNET_free(msg);
/* send a message with size GNUNET_SERVER_MAX_MESSAGE_SIZE-1 */
msg = GNUNET_malloc(size);
msg->size = htons(size);
msg->type = htons(32);
- 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);
+ 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);
GNUNET_free(msg);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"No more tests to run\n");
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "No more tests to run\n");
}
}
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Phase 0\n\n"));
run_connection_tests(0, NULL);
-
/* testing finished */
-
- return;
}
int
main (int argc, char *const *argv)
{
-
static struct GNUNET_GETOPT_CommandLineOption options[] = {
GNUNET_GETOPT_OPTION_END
};
/*
This file is part of GNUnet.
- (C) 2009, 2010 Christian Grothoff (and other contributing authors)
+ (C) 2009, 2010, 2011 Christian Grothoff (and other contributing authors)
GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
static struct GNUNET_TIME_Absolute start_time;
static GNUNET_SCHEDULER_TaskIdentifier die_task;
+static GNUNET_SCHEDULER_TaskIdentifier tct;
static GNUNET_SCHEDULER_TaskIdentifier measurement_task;
static GNUNET_SCHEDULER_TaskIdentifier measurement_counter_task;
#define OKPP do { ok++; } while (0)
-
-static void
-end_send ()
-{
-
-}
-
static void
end ()
{
GNUNET_SCHEDULER_cancel (die_task);
die_task = GNUNET_SCHEDULER_NO_TASK;
-
+
if (measurement_task != GNUNET_SCHEDULER_NO_TASK)
- {
- GNUNET_SCHEDULER_cancel (measurement_task);
- measurement_task = GNUNET_SCHEDULER_NO_TASK;
- }
+ {
+ GNUNET_SCHEDULER_cancel (measurement_task);
+ measurement_task = GNUNET_SCHEDULER_NO_TASK;
+ }
if (measurement_counter_task != GNUNET_SCHEDULER_NO_TASK)
- {
- GNUNET_SCHEDULER_cancel (measurement_counter_task);
- measurement_counter_task = GNUNET_SCHEDULER_NO_TASK;
- }
+ {
+ GNUNET_SCHEDULER_cancel (measurement_counter_task);
+ measurement_counter_task = GNUNET_SCHEDULER_NO_TASK;
+ }
fprintf(stderr,"\n");
GNUNET_SCHEDULER_shutdown ();
#if DEBUG_CONNECTIONS
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting from transports!\n");
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Disconnecting from transports!\n");
#endif
GNUNET_TRANSPORT_disconnect (p1.th);
GNUNET_TRANSPORT_disconnect (p2.th);
{
if (measurement_task != GNUNET_SCHEDULER_NO_TASK)
{
- GNUNET_SCHEDULER_cancel (measurement_task);
- measurement_task = GNUNET_SCHEDULER_NO_TASK;
+ GNUNET_SCHEDULER_cancel (measurement_task);
+ measurement_task = GNUNET_SCHEDULER_NO_TASK;
}
if (measurement_counter_task != GNUNET_SCHEDULER_NO_TASK)
- {
- GNUNET_SCHEDULER_cancel (measurement_counter_task);
- measurement_counter_task = GNUNET_SCHEDULER_NO_TASK;
- }
+ {
+ GNUNET_SCHEDULER_cancel (measurement_counter_task);
+ measurement_counter_task = GNUNET_SCHEDULER_NO_TASK;
+ }
GNUNET_break (0);
+ if (GNUNET_SCHEDULER_NO_TASK != tct)
+ {
+ GNUNET_SCHEDULER_cancel (tct);
+ tct = GNUNET_SCHEDULER_NO_TASK;
+ }
if (p1.th != NULL)
- GNUNET_TRANSPORT_disconnect (p1.th);
+ GNUNET_TRANSPORT_disconnect (p1.th);
if (p2.th != NULL)
- GNUNET_TRANSPORT_disconnect (p2.th);
+ GNUNET_TRANSPORT_disconnect (p2.th);
ok = 1;
}
uint32_t num;
};
+
static unsigned int
get_size ()
{
last_msg_recv = ntohl (hdr->num);
}
+
static size_t
notify_ready (void *cls, size_t size, void *buf)
{
unsigned int ret;
transmit_handle = NULL;
-
if (measurement_task == GNUNET_SCHEDULER_NO_TASK)
- return 0;
+ return 0;
if (buf == NULL)
{
ok = 42;
return 0;
}
-
if (measurement_running != GNUNET_YES)
- {
- send_running = GNUNET_NO;
- end_send();
- return 0;
- }
-
+ {
+ send_running = GNUNET_NO;
+ return 0;
+ }
send_running = GNUNET_YES;
ret = 0;
s = get_size ();
return ret;
}
-static void measure (unsigned long long quota_p1, unsigned long long quota_p2 );
-static void measurement_counter
- (void *cls,
- const struct GNUNET_SCHEDULER_TaskContext *tc)
+static void
+measure (unsigned long long quota_p1, unsigned long long quota_p2);
+
+static void
+measurement_counter (void *cls,
+ const struct GNUNET_SCHEDULER_TaskContext *tc)
{
measurement_counter_task = GNUNET_SCHEDULER_NO_TASK;
-
if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
- return;
-
+ return;
+
fprintf(stderr,".");
measurement_counter_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
&measurement_counter,
NULL);
}
+
static void
measurement_end (void *cls,
- const struct GNUNET_SCHEDULER_TaskContext *tc)
+ const struct GNUNET_SCHEDULER_TaskContext *tc)
{
static int strike_counter;
static int failed_measurement_counter = 1;
measurement_task = GNUNET_SCHEDULER_NO_TASK;
if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
- return;
+ return;
measurement_running = GNUNET_NO;
- struct GNUNET_TIME_Relative duration = GNUNET_TIME_absolute_get_difference(start_time, GNUNET_TIME_absolute_get());
+ struct GNUNET_TIME_Relative duration
+ = GNUNET_TIME_absolute_get_difference(start_time, GNUNET_TIME_absolute_get());
if (measurement_counter_task != GNUNET_SCHEDULER_NO_TASK)
- {
- GNUNET_SCHEDULER_cancel (measurement_counter_task);
- measurement_counter_task = GNUNET_SCHEDULER_NO_TASK;
- }
-
+ {
+ GNUNET_SCHEDULER_cancel (measurement_counter_task);
+ measurement_counter_task = GNUNET_SCHEDULER_NO_TASK;
+ }
+
if (transmit_handle != NULL)
- {
- GNUNET_TRANSPORT_notify_transmit_ready_cancel(transmit_handle);
- transmit_handle = NULL;
- }
-
+ {
+ GNUNET_TRANSPORT_notify_transmit_ready_cancel(transmit_handle);
+ transmit_handle = NULL;
+ }
+
if (current_quota_p1 < current_quota_p2)
- quota_allowed = current_quota_p1;
+ quota_allowed = current_quota_p1;
else
- quota_allowed = current_quota_p2;
-
-
+ quota_allowed = current_quota_p2;
+
+
if (MEASUREMENT_SOFT_LIMIT > (quota_allowed/3))
- delta = MEASUREMENT_SOFT_LIMIT;
+ delta = MEASUREMENT_SOFT_LIMIT;
else
- delta = (quota_allowed/3);
-
+ delta = (quota_allowed/3);
+
/* Throughput is far too slow. This is to prevent the test to exit with success when throughput is 0 */
if ((total_bytes_sent/(duration.rel_value / 1000)) < 100)
- {
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "\nQuota compliance failed: \n" \
+ "Hard quota limit allowed: %10llu kB/s (%llu B/s)\n" \
+ "Soft quota limit allowed: %10llu kB/s (%llu B/s)\n" \
+ "Throughput : %10llu kB/s (%llu B/s)\n",
+ (quota_allowed / (1024)), quota_allowed,
+ ((quota_allowed+delta) / (1024)), quota_allowed+delta,
+ (total_bytes_sent/(duration.rel_value / 1000)/1024),
+ total_bytes_sent/(duration.rel_value / 1000));
+ ok = 1;
+ failed_measurement_counter--;
+ if (failed_measurement_counter < 0)
+ {
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "\nQuota compliance failed: \n"\
- "Hard quota limit allowed: %10llu kB/s (%llu B/s)\n"\
- "Soft quota limit allowed: %10llu kB/s (%llu B/s)\n"\
- "Throughput : %10llu kB/s (%llu B/s)\n",
- (quota_allowed / (1024)), quota_allowed,
- ((quota_allowed+delta) / (1024)), quota_allowed+delta,
- (total_bytes_sent/(duration.rel_value / 1000)/1024),
- total_bytes_sent/(duration.rel_value / 1000));
- ok = 1;
- failed_measurement_counter--;
- if (failed_measurement_counter < 0)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "\nQuota measurement failed and no free strike: %i\n",failed_measurement_counter);
- end();
- return;
- }
- else
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "\nQuota measurement failed and %i free strikes\n",failed_measurement_counter);
- }
-
+ "\nQuota measurement failed and no free strike: %i\n",
+ failed_measurement_counter);
+ end();
+ return;
+ }
+ else
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "\nQuota measurement failed and %i free strikes\n",
+ failed_measurement_counter);
+ }
+
/* Throughput is bigger than allowed quota + some extra*/
if ((total_bytes_sent/(duration.rel_value / 1000)) > (quota_allowed + delta))
- {
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "\nQuota compliance failed: \n" \
+ "Hard quota limit allowed: %10llu kB/s (%llu B/s)\n" \
+ "Soft quota limit allowed: %10llu kB/s (%llu B/s)\n" \
+ "Throughput : %10llu kB/s (%llu B/s)\n",
+ (quota_allowed / (1024)), quota_allowed,
+ ((quota_allowed+delta) / (1024)), quota_allowed+delta,
+ (total_bytes_sent/(duration.rel_value / 1000)/1024),
+ total_bytes_sent/(duration.rel_value / 1000));
+ ok = 1;
+ failed_measurement_counter--;
+ if (failed_measurement_counter < 0)
+ {
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "\nQuota compliance failed: \n"\
- "Hard quota limit allowed: %10llu kB/s (%llu B/s)\n"\
- "Soft quota limit allowed: %10llu kB/s (%llu B/s)\n"\
- "Throughput : %10llu kB/s (%llu B/s)\n",
- (quota_allowed / (1024)), quota_allowed,
- ((quota_allowed+delta) / (1024)), quota_allowed+delta,
- (total_bytes_sent/(duration.rel_value / 1000)/1024),
- total_bytes_sent/(duration.rel_value / 1000));
- ok = 1;
- failed_measurement_counter--;
- if (failed_measurement_counter < 0)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "\nQuota measurement failed and no free strike: %i\n",failed_measurement_counter);
- end();
- return;
- }
- else
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "\nQuota measurement failed and %i free strikes\n",failed_measurement_counter);
- }
+ "\nQuota measurement failed and no free strike: %i\n",failed_measurement_counter);
+ end();
+ return;
+ }
+ else
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "\nQuota measurement failed and %i free strikes\n",failed_measurement_counter);
+ }
else
- {
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "\nQuota compliance ok: \n"\
- "Quota allowed: %10llu kB/s\n"\
- "Throughput : %10llu kB/s\n", (quota_allowed / (1024)) , (total_bytes_sent/(duration.rel_value / 1000)/1024));
- if (failed_measurement_counter < 2)
- failed_measurement_counter++;
- ok = 0;
- }
-
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "\nQuota compliance ok: \n" \
+ "Quota allowed: %10llu kB/s\n" \
+ "Throughput : %10llu kB/s\n",
+ (quota_allowed / (1024)),
+ (total_bytes_sent/(duration.rel_value / 1000)/1024));
+ if (failed_measurement_counter < 2)
+ failed_measurement_counter++;
+ ok = 0;
+ }
+
if ((quota_allowed) > (2 *(total_bytes_sent/(duration.rel_value / 1000))))
- {
- if (failed_measurement_counter < 2)
- failed_measurement_counter++;
- if (strike_counter == 2)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Maximum transmission rate reached, stopping test\n");
- end();
- return;
- }
- }
- else
- {
- strike_counter = 0;
- }
-
- if (quota_allowed == MEASUREMENT_MAX_QUOTA)
- {
+ {
+ if (failed_measurement_counter < 2)
+ failed_measurement_counter++;
+ if (strike_counter == 2)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Maximum transmission rate reached, stopping test\n");
end();
return;
- }
+ }
+ }
+ else
+ {
+ strike_counter = 0;
+ }
+
+ if (quota_allowed == MEASUREMENT_MAX_QUOTA)
+ {
+ end();
+ return;
+ }
if (is_asymmetric_send_constant == GNUNET_YES)
- {
- if ((quota_allowed * 2) < MEASUREMENT_MAX_QUOTA)
- measure (current_quota_p1 * 2, MEASUREMENT_MAX_QUOTA);
- else
- measure (MEASUREMENT_MAX_QUOTA, MEASUREMENT_MAX_QUOTA);
- }
+ {
+ if ((quota_allowed * 2) < MEASUREMENT_MAX_QUOTA)
+ measure (current_quota_p1 * 2, MEASUREMENT_MAX_QUOTA);
+ else
+ measure (MEASUREMENT_MAX_QUOTA, MEASUREMENT_MAX_QUOTA);
+ }
else if (is_asymmetric_recv_constant == GNUNET_YES)
- {
- if ((quota_allowed * 2) < MEASUREMENT_MAX_QUOTA)
- measure (MEASUREMENT_MAX_QUOTA, current_quota_p2 * 2);
- else
- measure (MEASUREMENT_MAX_QUOTA, MEASUREMENT_MAX_QUOTA);
- }
+ {
+ if ((quota_allowed * 2) < MEASUREMENT_MAX_QUOTA)
+ measure (MEASUREMENT_MAX_QUOTA, current_quota_p2 * 2);
+ else
+ measure (MEASUREMENT_MAX_QUOTA, MEASUREMENT_MAX_QUOTA);
+ }
else
- {
- if ((quota_allowed * 2) < MEASUREMENT_MAX_QUOTA)
- measure ((current_quota_p1) * 2, (current_quota_p2) * 2);
- else
- measure (MEASUREMENT_MAX_QUOTA, MEASUREMENT_MAX_QUOTA);
- }
+ {
+ if ((quota_allowed * 2) < MEASUREMENT_MAX_QUOTA)
+ measure ((current_quota_p1) * 2, (current_quota_p2) * 2);
+ else
+ measure (MEASUREMENT_MAX_QUOTA, MEASUREMENT_MAX_QUOTA);
+ }
}
-static void measure (unsigned long long quota_p1, unsigned long long quota_p2 )
+static void
+measure (unsigned long long quota_p1, unsigned long long quota_p2)
{
- current_quota_p1 = quota_p1;
- current_quota_p2 = quota_p2;
+ current_quota_p1 = quota_p1;
+ current_quota_p2 = quota_p2;
#if VERBOSE
if ((is_asymmetric_send_constant == GNUNET_YES) || (is_asymmetric_recv_constant == GNUNET_YES))
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "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);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "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);
else
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Starting transport level measurement for %u seconds, symmetric quota %llu kB/s\n", MEASUREMENT_INTERVALL.rel_value / 1000 , current_quota_p2 / 1024);
-
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Starting transport level measurement for %u seconds, symmetric quota %llu kB/s\n",
+ MEASUREMENT_INTERVALL.rel_value / 1000,
+ current_quota_p2 / 1024);
+
#endif
- GNUNET_TRANSPORT_set_quota (p1.th,
- &p2.id,
- GNUNET_BANDWIDTH_value_init (current_quota_p1),
- GNUNET_BANDWIDTH_value_init (current_quota_p1));
- GNUNET_TRANSPORT_set_quota (p2.th,
- &p1.id,
- GNUNET_BANDWIDTH_value_init (current_quota_p2),
- GNUNET_BANDWIDTH_value_init (current_quota_p2));
- GNUNET_SCHEDULER_cancel (die_task);
- die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT,
- &end_badly,
- NULL);
- if (measurement_counter_task != GNUNET_SCHEDULER_NO_TASK)
- GNUNET_SCHEDULER_cancel (measurement_counter_task);
- measurement_counter_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
- &measurement_counter,
- NULL);
- measurement_task = GNUNET_SCHEDULER_add_delayed (MEASUREMENT_INTERVALL,
+ GNUNET_TRANSPORT_set_quota (p1.th,
+ &p2.id,
+ GNUNET_BANDWIDTH_value_init (current_quota_p1),
+ GNUNET_BANDWIDTH_value_init (current_quota_p1));
+ GNUNET_TRANSPORT_set_quota (p2.th,
+ &p1.id,
+ GNUNET_BANDWIDTH_value_init (current_quota_p2),
+ GNUNET_BANDWIDTH_value_init (current_quota_p2));
+ GNUNET_SCHEDULER_cancel (die_task);
+ die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT,
+ &end_badly,
+ NULL);
+ if (measurement_counter_task != GNUNET_SCHEDULER_NO_TASK)
+ GNUNET_SCHEDULER_cancel (measurement_counter_task);
+ measurement_counter_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
+ &measurement_counter,
+ NULL);
+ measurement_task = GNUNET_SCHEDULER_add_delayed (MEASUREMENT_INTERVALL,
&measurement_end,
NULL);
- total_bytes_sent = 0;
- last_msg_sent = 0;
- last_msg_recv = 0;
- measurement_running = GNUNET_YES;
- start_time = GNUNET_TIME_absolute_get ();
-
- if (transmit_handle != NULL)
- GNUNET_TRANSPORT_notify_transmit_ready_cancel(transmit_handle);
- transmit_handle = GNUNET_TRANSPORT_notify_transmit_ready (p2.th,
- &p1.id,
- get_size (), 0, SEND_TIMEOUT,
- ¬ify_ready,
- NULL);
+ total_bytes_sent = 0;
+ last_msg_sent = 0;
+ last_msg_recv = 0;
+ measurement_running = GNUNET_YES;
+ start_time = GNUNET_TIME_absolute_get ();
+
+ if (transmit_handle != NULL)
+ GNUNET_TRANSPORT_notify_transmit_ready_cancel(transmit_handle);
+ transmit_handle = GNUNET_TRANSPORT_notify_transmit_ready (p2.th,
+ &p1.id,
+ get_size (), 0, SEND_TIMEOUT,
+ ¬ify_ready,
+ NULL);
+}
+
+
+static void
+exchange_hello_last (void *cls,
+ const struct GNUNET_MessageHeader *message)
+{
+ struct PeerContext *me = cls;
+
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Exchanging HELLO of size %d with peer (%s)!\n",
+ (int) GNUNET_HELLO_size((const struct GNUNET_HELLO_Message *)message),
+ GNUNET_i2s (&me->id));
+ GNUNET_assert (message != NULL);
+ GNUNET_assert (GNUNET_OK ==
+ GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *)
+ message, &me->id));
+ GNUNET_TRANSPORT_offer_hello (p1.th, message, NULL, NULL);
+}
+
+
+
+static void
+exchange_hello (void *cls,
+ const struct GNUNET_MessageHeader *message)
+{
+ struct PeerContext *me = cls;
+
+ GNUNET_assert (message != NULL);
+ GNUNET_assert (GNUNET_OK ==
+ GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *)
+ message, &me->id));
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Exchanging HELLO of size %d from peer %s!\n",
+ (int) GNUNET_HELLO_size((const struct GNUNET_HELLO_Message *)message),
+ GNUNET_i2s (&me->id));
+ GNUNET_TRANSPORT_offer_hello (p2.th, message, NULL, NULL);
}
+
static void
notify_connect (void *cls,
const struct GNUNET_PeerIdentity *peer,
const struct GNUNET_TRANSPORT_ATS_Information *ats, uint32_t ats_count)
-{
- if (cls == &p1)
+{
+ connected++;
+ if (cls == &p1)
{
#if DEBUG_CONNECTIONS
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Peer 1 `%4s' connected to us (%p)!\n", GNUNET_i2s (peer), cls);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Peer 1 `%4s' connected to us (%p)!\n",
+ GNUNET_i2s (peer),
+ cls);
#endif
- connected++;
}
else
{
#if DEBUG_CONNECTIONS
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Peer 2 `%4s' connected to us (%p)!\n", GNUNET_i2s (peer), cls);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Peer 2 `%4s' connected to us (%p)!\n",
+ GNUNET_i2s (peer),
+ cls);
#endif
- connected++;
}
if (connected == 2)
{
- if (is_asymmetric_send_constant == GNUNET_YES)
- measure (MEASUREMENT_MIN_QUOTA, MEASUREMENT_MAX_QUOTA);
- else if (is_asymmetric_recv_constant == GNUNET_YES)
- measure (MEASUREMENT_MAX_QUOTA, MEASUREMENT_MIN_QUOTA);
- else
- measure (MEASUREMENT_MIN_QUOTA, MEASUREMENT_MIN_QUOTA);
+ GNUNET_SCHEDULER_cancel (tct);
+ tct = GNUNET_SCHEDULER_NO_TASK;
+ GNUNET_TRANSPORT_get_hello_cancel (p2.th, &exchange_hello_last, &p2);
+ GNUNET_TRANSPORT_get_hello_cancel (p1.th, &exchange_hello, &p1);
+ if (is_asymmetric_send_constant == GNUNET_YES)
+ measure (MEASUREMENT_MIN_QUOTA, MEASUREMENT_MAX_QUOTA);
+ else if (is_asymmetric_recv_constant == GNUNET_YES)
+ measure (MEASUREMENT_MAX_QUOTA, MEASUREMENT_MIN_QUOTA);
+ else
+ measure (MEASUREMENT_MIN_QUOTA, MEASUREMENT_MIN_QUOTA);
}
}
static void
notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
{
+ connected--;
#if DEBUG_CONNECTIONS
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Peer `%4s' disconnected (%p)!\n",
GNUNET_assert (p->th != NULL);
}
-static size_t
-notify_ready_connect (void *cls, size_t size, void *buf)
-{
- return 0;
-}
static void
-exchange_hello_last (void *cls,
- const struct GNUNET_MessageHeader *message)
+try_connect (void *cls,
+ const struct GNUNET_SCHEDULER_TaskContext *tc)
{
- struct PeerContext *me = cls;
-
- GNUNET_TRANSPORT_get_hello_cancel (p2.th, &exchange_hello_last, me);
-
- GNUNET_assert (ok >= 3);
- OKPP;
- GNUNET_assert (message != NULL);
- GNUNET_assert (GNUNET_OK ==
- GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *)
- message, &me->id));
-
- GNUNET_assert(NULL != (transmit_handle = GNUNET_TRANSPORT_notify_transmit_ready (p2.th,
- &p1.id,
- sizeof (struct GNUNET_MessageHeader), 0,
- TIMEOUT,
- ¬ify_ready_connect,
- NULL)));
-
- /* both HELLOs exchanged, get ready to test transmission! */
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Asking peers to connect...\n");
+ GNUNET_TRANSPORT_try_connect (p2.th,
+ &p1.id);
+ GNUNET_TRANSPORT_try_connect (p1.th,
+ &p2.id);
+ tct = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
+ &try_connect,
+ NULL);
}
-static void
-exchange_hello (void *cls,
- const struct GNUNET_MessageHeader *message)
-{
- struct PeerContext *me = cls;
-
- GNUNET_TRANSPORT_get_hello_cancel (p1.th, &exchange_hello, me);
- GNUNET_assert (ok >= 2);
- OKPP;
- GNUNET_assert (message != NULL);
- GNUNET_assert (GNUNET_OK ==
- GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *)
- message, &me->id));
- GNUNET_TRANSPORT_offer_hello (p2.th, message, NULL, NULL);
- GNUNET_TRANSPORT_get_hello (p2.th, &exchange_hello_last, &p2);
-}
-
static void
run (void *cls,
char *const *args,
if (is_tcp)
{
- if (is_asymmetric_recv_constant == GNUNET_YES)
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Testing asymmetric quota compliance (receiver quota constant) for TCP transport plugin\n");
- else if (is_asymmetric_send_constant == GNUNET_YES)
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Testing asymmetric quota compliance (sender quota constant) for TCP transport plugin\n");
- else
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Testing symmetric quota compliance for TCP transport plugin\n");
+ if (is_asymmetric_recv_constant == GNUNET_YES)
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Testing asymmetric quota compliance (receiver quota constant) for TCP transport plugin\n");
+ else if (is_asymmetric_send_constant == GNUNET_YES)
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Testing asymmetric quota compliance (sender quota constant) for TCP transport plugin\n");
+ else
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Testing symmetric quota compliance for TCP transport plugin\n");
setup_peer (&p1, "test_quota_compliance_tcp_peer1.conf");
setup_peer (&p2, "test_quota_compliance_tcp_peer2.conf");
}
else if (is_http)
{
- if (is_asymmetric_recv_constant == GNUNET_YES)
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Testing asymmetric quota compliance (receiver quota constant) for HTTP transport plugin\n");
- else if (is_asymmetric_send_constant == GNUNET_YES)
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Testing asymmetric quota compliance (sender quota constant) for HTTP transport plugin\n");
- else
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Testing symmetric quota compliance for HTTP transport plugin\n");
+ if (is_asymmetric_recv_constant == GNUNET_YES)
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Testing asymmetric quota compliance (receiver quota constant) for HTTP transport plugin\n");
+ else if (is_asymmetric_send_constant == GNUNET_YES)
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Testing asymmetric quota compliance (sender quota constant) for HTTP transport plugin\n");
+ else
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Testing symmetric quota compliance for HTTP transport plugin\n");
setup_peer (&p1, "test_quota_compliance_http_peer1.conf");
setup_peer (&p2, "test_quota_compliance_http_peer2.conf");
}
else if (is_https)
{
- if (is_asymmetric_recv_constant == GNUNET_YES)
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Testing asymmetric quota compliance (receiver quota constant) for HTTPS transport plugin\n");
- else if (is_asymmetric_send_constant == GNUNET_YES)
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Testing asymmetric quota compliance (sender quota constant) for HTTPS transport plugin\n");
- else
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Testing symmetric quota compliance for HTTPS transport plugin\n");
+ if (is_asymmetric_recv_constant == GNUNET_YES)
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Testing asymmetric quota compliance (receiver quota constant) for HTTPS transport plugin\n");
+ else if (is_asymmetric_send_constant == GNUNET_YES)
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Testing asymmetric quota compliance (sender quota constant) for HTTPS transport plugin\n");
+ else
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Testing symmetric quota compliance for HTTPS transport plugin\n");
setup_peer (&p1, "test_quota_compliance_https_peer1.conf");
setup_peer (&p2, "test_quota_compliance_https_peer2.conf");
}
else if (is_udp)
{
- if (is_asymmetric_recv_constant == GNUNET_YES)
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Testing asymmetric quota compliance (receiver quota constant) for UDP transport plugin\n");
- else if (is_asymmetric_send_constant == GNUNET_YES)
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Testing asymmetric quota compliance (sender quota constant) for UDP transport plugin\n");
- else
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Testing symmetric quota compliance for UDP transport plugin\n");
+ if (is_asymmetric_recv_constant == GNUNET_YES)
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Testing asymmetric quota compliance (receiver quota constant) for UDP transport plugin\n");
+ else if (is_asymmetric_send_constant == GNUNET_YES)
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Testing asymmetric quota compliance (sender quota constant) for UDP transport plugin\n");
+ else
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Testing symmetric quota compliance for UDP transport plugin\n");
setup_peer (&p1, "test_quota_compliance_udp_peer1.conf");
setup_peer (&p2, "test_quota_compliance_udp_peer2.conf");
}
else if (is_unix)
{
- if (is_asymmetric_recv_constant == GNUNET_YES)
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Testing asymmetric quota compliance (receiver quota constant) for UNIX transport plugin\n");
- else if (is_asymmetric_send_constant == GNUNET_YES)
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Testing asymmetric quota compliance (sender quota constant) for UNIX transport plugin\n");
- else
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Testing symmetric quota compliance for UNIX transport plugin\n");
+ if (is_asymmetric_recv_constant == GNUNET_YES)
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Testing asymmetric quota compliance (receiver quota constant) for UNIX transport plugin\n");
+ else if (is_asymmetric_send_constant == GNUNET_YES)
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Testing asymmetric quota compliance (sender quota constant) for UNIX transport plugin\n");
+ else
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Testing symmetric quota compliance for UNIX transport plugin\n");
setup_peer (&p1, "test_quota_compliance_unix_peer1.conf");
setup_peer (&p2, "test_quota_compliance_unix_peer2.conf");
}
else if (is_tcp_nat)
{
- if (is_asymmetric_recv_constant == GNUNET_YES)
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Testing asymmetric quota compliance (receiver quota constant) for TCP NAT transport plugin\n");
- else if (is_asymmetric_send_constant == GNUNET_YES)
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Testing asymmetric quota compliance (sender quota constant) for TCP NAT transport plugin\n");
- else
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Testing symmetric quota compliance for TCP NAT transport plugin\n");
+ if (is_asymmetric_recv_constant == GNUNET_YES)
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Testing asymmetric quota compliance (receiver quota constant) for TCP NAT transport plugin\n");
+ else if (is_asymmetric_send_constant == GNUNET_YES)
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Testing asymmetric quota compliance (sender quota constant) for TCP NAT transport plugin\n");
+ else
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Testing symmetric quota compliance for TCP NAT transport plugin\n");
setup_peer (&p1, "test_quota_compliance_tcp_peer1.conf");
setup_peer (&p2, "test_quota_compliance_tcp_peer2.conf");
}
GNUNET_assert(p1.th != NULL);
GNUNET_assert(p2.th != NULL);
GNUNET_TRANSPORT_get_hello (p1.th, &exchange_hello, &p1);
+ GNUNET_TRANSPORT_get_hello (p2.th, &exchange_hello_last, &p2);
+ tct = GNUNET_SCHEDULER_add_now (&try_connect, NULL);
}
+
int
main (int argc, char *argv[])
{
if (strstr(argv[0], "asymmetric_recv") != NULL)
{
- is_asymmetric_recv_constant = GNUNET_YES;
+ is_asymmetric_recv_constant = GNUNET_YES;
}
else
- is_asymmetric_recv_constant = GNUNET_NO;
+ is_asymmetric_recv_constant = GNUNET_NO;
if (strstr(argv[0], "asymmetric_send") != NULL)
- {
+ {
is_asymmetric_send_constant = GNUNET_YES;
- }
+ }
else
- is_asymmetric_send_constant = GNUNET_NO;
-
+ is_asymmetric_send_constant = GNUNET_NO;
+
char * logger;
if (is_tcp == GNUNET_YES)
- {
- if (is_asymmetric_recv_constant == GNUNET_YES)
- GNUNET_asprintf(&logger, "test-quota-compliance-%s-%s","tcp","asymmetric_recv_constant");
- else if (is_asymmetric_send_constant == GNUNET_YES)
- GNUNET_asprintf(&logger, "test-quota-compliance-%s-%s","tcp","asymmetric_send_constant");
- else
- GNUNET_asprintf(&logger, "test-quota-compliance-%s-%s","tcp","symmetric");
- }
+ {
+ if (is_asymmetric_recv_constant == GNUNET_YES)
+ GNUNET_asprintf(&logger, "test-quota-compliance-%s-%s","tcp","asymmetric_recv_constant");
+ else if (is_asymmetric_send_constant == GNUNET_YES)
+ GNUNET_asprintf(&logger, "test-quota-compliance-%s-%s","tcp","asymmetric_send_constant");
+ else
+ GNUNET_asprintf(&logger, "test-quota-compliance-%s-%s","tcp","symmetric");
+ }
else if (is_udp == GNUNET_YES)
- {
- if (is_asymmetric_recv_constant == GNUNET_YES)
- GNUNET_asprintf(&logger, "test-quota-compliance-%s-%s","udp","asymmetric_recv_constant");
- else if (is_asymmetric_send_constant == GNUNET_YES)
- GNUNET_asprintf(&logger, "test-quota-compliance-%s-%s","udp","asymmetric_send_constant");
- else
- GNUNET_asprintf(&logger, "test-quota-compliance-%s-%s","udp","symmetric");
- }
+ {
+ if (is_asymmetric_recv_constant == GNUNET_YES)
+ GNUNET_asprintf(&logger, "test-quota-compliance-%s-%s","udp","asymmetric_recv_constant");
+ else if (is_asymmetric_send_constant == GNUNET_YES)
+ GNUNET_asprintf(&logger, "test-quota-compliance-%s-%s","udp","asymmetric_send_constant");
+ else
+ GNUNET_asprintf(&logger, "test-quota-compliance-%s-%s","udp","symmetric");
+ }
else if (is_unix == GNUNET_YES)
- {
- if (is_asymmetric_recv_constant == GNUNET_YES)
- GNUNET_asprintf(&logger, "test-quota-compliance-%s-%s","unix","asymmetric_recv_constant");
- else if (is_asymmetric_send_constant == GNUNET_YES)
- GNUNET_asprintf(&logger, "test-quota-compliance-%s-%s","unix","asymmetric_send_constant");
- else
- GNUNET_asprintf(&logger, "test-quota-compliance-%s-%s","unix","symmetric");
- }
+ {
+ if (is_asymmetric_recv_constant == GNUNET_YES)
+ GNUNET_asprintf(&logger, "test-quota-compliance-%s-%s","unix","asymmetric_recv_constant");
+ else if (is_asymmetric_send_constant == GNUNET_YES)
+ GNUNET_asprintf(&logger, "test-quota-compliance-%s-%s","unix","asymmetric_send_constant");
+ else
+ GNUNET_asprintf(&logger, "test-quota-compliance-%s-%s","unix","symmetric");
+ }
else if (is_http == GNUNET_YES)
- {
- if (is_asymmetric_recv_constant == GNUNET_YES)
- GNUNET_asprintf(&logger, "test-quota-compliance-%s-%s","http","asymmetric_recv_constant");
- else if (is_asymmetric_send_constant == GNUNET_YES)
- GNUNET_asprintf(&logger, "test-quota-compliance-%s-%s","http","asymmetric_send_constant");
- else
- GNUNET_asprintf(&logger, "test-quota-compliance-%s-%s","http","symmetric");
- }
+ {
+ if (is_asymmetric_recv_constant == GNUNET_YES)
+ GNUNET_asprintf(&logger, "test-quota-compliance-%s-%s","http","asymmetric_recv_constant");
+ else if (is_asymmetric_send_constant == GNUNET_YES)
+ GNUNET_asprintf(&logger, "test-quota-compliance-%s-%s","http","asymmetric_send_constant");
+ else
+ GNUNET_asprintf(&logger, "test-quota-compliance-%s-%s","http","symmetric");
+ }
else if (is_https == GNUNET_YES)
- {
- if (is_asymmetric_recv_constant == GNUNET_YES)
- GNUNET_asprintf(&logger, "test-quota-compliance-%s-%s","https","asymmetric_recv_constant");
- else if (is_asymmetric_send_constant == GNUNET_YES)
- GNUNET_asprintf(&logger, "test-quota-compliance-%s-%s","https","asymmetric_send_constant");
- else
- GNUNET_asprintf(&logger, "test-quota-compliance-%s-%s","https","symmetric");
- }
+ {
+ if (is_asymmetric_recv_constant == GNUNET_YES)
+ GNUNET_asprintf(&logger, "test-quota-compliance-%s-%s","https","asymmetric_recv_constant");
+ else if (is_asymmetric_send_constant == GNUNET_YES)
+ GNUNET_asprintf(&logger, "test-quota-compliance-%s-%s","https","asymmetric_send_constant");
+ else
+ GNUNET_asprintf(&logger, "test-quota-compliance-%s-%s","https","symmetric");
+ }
else
- {
- GNUNET_asprintf(&logger, "test-quota-compliance-%s-%s","noplugin","none");
- }
+ {
+ GNUNET_asprintf(&logger, "test-quota-compliance-%s-%s","noplugin","none");
+ }
GNUNET_DISK_directory_remove ("/tmp/test_quota_compliance_peer1");
GNUNET_DISK_directory_remove ("/tmp/test_quota_compliance_peer2");
static GNUNET_SCHEDULER_TaskIdentifier die_task;
+static GNUNET_SCHEDULER_TaskIdentifier tct;
+
static char * key_file_p1;
static char * cert_file_p1;
static int msg_sent;
static int msg_recv_expected;
static int msg_recv;
-static struct GNUNET_TRANSPORT_TransmitHandle * transmit_handle;
#if VERBOSE
#define OKPP do { ok++; fprintf (stderr, "Now at stage %u at %s:%u\n", ok, __FILE__, __LINE__); } while (0)
const struct GNUNET_SCHEDULER_TaskContext *tc)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "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);
+ "Reliability failed: Last message sent %u, Next message scheduled %u, Last message received %u, Message expected %u\n",
+ msg_sent,
+ msg_scheduled,
+ msg_recv,
+ msg_recv_expected);
GNUNET_break (0);
GNUNET_TRANSPORT_disconnect (p1.th);
GNUNET_TRANSPORT_disconnect (p2.th);
+ if (GNUNET_SCHEDULER_NO_TASK != tct)
+ {
+ GNUNET_SCHEDULER_cancel (tct);
+ tct = GNUNET_SCHEDULER_NO_TASK;
+ }
ok = 1;
}
}
+static void
+notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
+{
+ connected--;
+#if VERBOSE
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Peer `%4s' disconnected (%p)!\n",
+ GNUNET_i2s (peer), cls);
+#endif
+}
+
+
+static void
+exchange_hello_last (void *cls,
+ const struct GNUNET_MessageHeader *message)
+{
+ struct PeerContext *me = cls;
+
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Exchanging HELLO of size %d with peer (%s)!\n",
+ (int) GNUNET_HELLO_size((const struct GNUNET_HELLO_Message *)message),
+ GNUNET_i2s (&me->id));
+ GNUNET_assert (message != NULL);
+ GNUNET_assert (GNUNET_OK ==
+ GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *)
+ message, &me->id));
+ GNUNET_TRANSPORT_offer_hello (p1.th, message, NULL, NULL);
+}
+
+
+
+static void
+exchange_hello (void *cls,
+ const struct GNUNET_MessageHeader *message)
+{
+ struct PeerContext *me = cls;
+
+ GNUNET_assert (message != NULL);
+ GNUNET_assert (GNUNET_OK ==
+ GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *)
+ message, &me->id));
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Exchanging HELLO of size %d from peer %s!\n",
+ (int) GNUNET_HELLO_size((const struct GNUNET_HELLO_Message *)message),
+ GNUNET_i2s (&me->id));
+ GNUNET_TRANSPORT_offer_hello (p2.th, message, NULL, NULL);
+}
+
+
static void
notify_connect (void *cls,
const struct GNUNET_PeerIdentity *peer,
const struct GNUNET_TRANSPORT_ATS_Information *ats,
uint32_t ats_count)
{
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Peer `%4s' connected to us (%p)!\n",
+ GNUNET_i2s (peer),
+ cls);
+ connected++;
if (cls == &p1)
{
GNUNET_TRANSPORT_set_quota (p1.th,
GNUNET_BANDWIDTH_value_init (1024 * 1024 * 1024),
GNUNET_BANDWIDTH_value_init (1024 * 1024 * 1024));
start_time = GNUNET_TIME_absolute_get ();
- connected++;
}
else
{
&p1.id,
GNUNET_BANDWIDTH_value_init (1024 * 1024 * 1024),
GNUNET_BANDWIDTH_value_init (1024 * 1024 * 1024));
- connected++;
}
-
- if (connected == 2)
+ if (2 == connected)
{
-
- if ((transmit_handle!=NULL) && (cls == NULL))
- GNUNET_TRANSPORT_notify_transmit_ready_cancel(transmit_handle);
- if ((transmit_handle!=NULL) && (cls == &transmit_handle))
- transmit_handle=NULL;
+ GNUNET_SCHEDULER_cancel (die_task);
+ GNUNET_SCHEDULER_cancel (tct);
+ tct = GNUNET_SCHEDULER_NO_TASK;
+ GNUNET_TRANSPORT_get_hello_cancel (p2.th, &exchange_hello_last, &p2);
+ GNUNET_TRANSPORT_get_hello_cancel (p1.th, &exchange_hello, &p1);
+ die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT,
+ &end_badly, NULL);
GNUNET_TRANSPORT_notify_transmit_ready (p2.th,
&p1.id,
get_size (0), 0, TIMEOUT,
¬ify_ready,
NULL);
+
}
-#if VERBOSE
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Peer `%4s' connected to us (%p)!\n", GNUNET_i2s (peer), cls);
-#endif
-}
-
-
-static void
-notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
-{
-#if VERBOSE
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Peer `%4s' disconnected (%p)!\n",
- GNUNET_i2s (peer), cls);
-#endif
}
GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname));
if (is_https)
- {
- struct stat sbuf;
- if (p==&p1)
- {
- if (GNUNET_CONFIGURATION_have_value (p->cfg,
- "transport-https", "KEY_FILE"))
- GNUNET_CONFIGURATION_get_value_string (p->cfg, "transport-https", "KEY_FILE", &key_file_p1);
- if (key_file_p1 == NULL)
- GNUNET_asprintf(&key_file_p1,"https_p1.key");
- if (0 == stat (key_file_p1, &sbuf ))
- {
- if (0 == remove(key_file_p1))
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Successfully removed existing private key file `%s'\n",key_file_p1);
- else
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to remove private key file `%s'\n",key_file_p1);
- }
- if (GNUNET_CONFIGURATION_have_value (p->cfg,"transport-https", "CERT_FILE"))
- GNUNET_CONFIGURATION_get_value_string (p->cfg, "transport-https", "CERT_FILE", &cert_file_p1);
- if (cert_file_p1 == NULL)
- GNUNET_asprintf(&cert_file_p1,"https_p1.cert");
- if (0 == stat (cert_file_p1, &sbuf ))
- {
- if (0 == remove(cert_file_p1))
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Successfully removed existing certificate file `%s'\n",cert_file_p1);
- else
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to remove existing certificate file `%s'\n",cert_file_p1);
- }
- }
- else if (p==&p2)
- {
- if (GNUNET_CONFIGURATION_have_value (p->cfg,
- "transport-https", "KEY_FILE"))
- GNUNET_CONFIGURATION_get_value_string (p->cfg, "transport-https", "KEY_FILE", &key_file_p2);
- if (key_file_p2 == NULL)
- GNUNET_asprintf(&key_file_p2,"https_p2.key");
- if (0 == stat (key_file_p2, &sbuf ))
- {
- if (0 == remove(key_file_p2))
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Successfully removed existing private key file `%s'\n",key_file_p2);
- else
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to remove private key file `%s'\n",key_file_p2);
- }
- if (GNUNET_CONFIGURATION_have_value (p->cfg,"transport-https", "CERT_FILE"))
- GNUNET_CONFIGURATION_get_value_string (p->cfg, "transport-https", "CERT_FILE", &cert_file_p2);
- if (cert_file_p2 == NULL)
- GNUNET_asprintf(&cert_file_p2,"https_p2.cert");
- if (0 == stat (cert_file_p2, &sbuf ))
- {
- if (0 == remove(cert_file_p2))
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Successfully removed existing certificate file `%s'\n",cert_file_p2);
- else
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to remove existing certificate file `%s'\n",cert_file_p2);
- }
- }
- }
-
+ {
+ struct stat sbuf;
+ if (p==&p1)
+ {
+ if (GNUNET_CONFIGURATION_have_value (p->cfg,
+ "transport-https", "KEY_FILE"))
+ GNUNET_CONFIGURATION_get_value_string (p->cfg, "transport-https", "KEY_FILE", &key_file_p1);
+ if (key_file_p1 == NULL)
+ GNUNET_asprintf(&key_file_p1,"https_p1.key");
+ if (0 == stat (key_file_p1, &sbuf ))
+ {
+ if (0 == remove(key_file_p1))
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Successfully removed existing private key file `%s'\n",
+ key_file_p1);
+ else
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Failed to remove private key file `%s'\n",
+ key_file_p1);
+ }
+ if (GNUNET_CONFIGURATION_have_value (p->cfg,"transport-https", "CERT_FILE"))
+ GNUNET_CONFIGURATION_get_value_string (p->cfg, "transport-https", "CERT_FILE", &cert_file_p1);
+ if (cert_file_p1 == NULL)
+ GNUNET_asprintf(&cert_file_p1,"https_p1.cert");
+ if (0 == stat (cert_file_p1, &sbuf ))
+ {
+ if (0 == remove(cert_file_p1))
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Successfully removed existing certificate file `%s'\n",
+ cert_file_p1);
+ else
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Failed to remove existing certificate file `%s'\n",
+ cert_file_p1);
+ }
+ }
+ else if (p==&p2)
+ {
+ if (GNUNET_CONFIGURATION_have_value (p->cfg,
+ "transport-https", "KEY_FILE"))
+ GNUNET_CONFIGURATION_get_value_string (p->cfg, "transport-https", "KEY_FILE", &key_file_p2);
+ if (key_file_p2 == NULL)
+ GNUNET_asprintf(&key_file_p2,"https_p2.key");
+ if (0 == stat (key_file_p2, &sbuf ))
+ {
+ if (0 == remove(key_file_p2))
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Successfully removed existing private key file `%s'\n",
+ key_file_p2);
+ else
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Failed to remove private key file `%s'\n",
+ key_file_p2);
+ }
+ if (GNUNET_CONFIGURATION_have_value (p->cfg,"transport-https", "CERT_FILE"))
+ GNUNET_CONFIGURATION_get_value_string (p->cfg, "transport-https", "CERT_FILE", &cert_file_p2);
+ if (cert_file_p2 == NULL)
+ GNUNET_asprintf(&cert_file_p2,"https_p2.cert");
+ if (0 == stat (cert_file_p2, &sbuf ))
+ {
+ if (0 == remove(cert_file_p2))
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Successfully removed existing certificate file `%s'\n",
+ cert_file_p2);
+ else
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Failed to remove existing certificate file `%s'\n",
+ cert_file_p2);
+ }
+ }
+ }
p->th = GNUNET_TRANSPORT_connect (p->cfg, NULL,
p,
¬ify_receive,
GNUNET_assert (p->th != NULL);
}
-static size_t
-notify_ready_connect (void *cls, size_t size, void *buf)
-{
- return 0;
-}
-
-static void
-exchange_hello_last (void *cls,
- const struct GNUNET_MessageHeader *message)
-{
- struct PeerContext *me = cls;
- transmit_handle = NULL;
- GNUNET_TRANSPORT_get_hello_cancel (p2.th, &exchange_hello_last, me);
-#if VERBOSE
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Exchanging HELLO with peer (%p)!\n", cls);
-#endif
- GNUNET_assert (ok >= 3);
- OKPP;
- GNUNET_assert (message != NULL);
- GNUNET_assert (GNUNET_OK ==
- GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *)
- message, &me->id));
-
- GNUNET_assert(NULL != (transmit_handle = GNUNET_TRANSPORT_notify_transmit_ready (p2.th,
- &p1.id,
- sizeof (struct GNUNET_MessageHeader), 0,
- TIMEOUT,
- ¬ify_ready_connect,
- &transmit_handle)));
-
- /* both HELLOs exchanged, get ready to test transmission! */
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Finished exchanging HELLOs, now waiting for transmission!\n");
-}
-
-
-static void
-exchange_hello (void *cls,
- const struct GNUNET_MessageHeader *message)
-{
- struct PeerContext *me = cls;
-
- GNUNET_TRANSPORT_get_hello_cancel (p1.th, &exchange_hello, me);
-#if VERBOSE
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Exchanging HELLO with peer (%p)!\n", cls);
-#endif
- GNUNET_assert (ok >= 2);
- OKPP;
- GNUNET_assert (message != NULL);
- GNUNET_assert (GNUNET_OK ==
- GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *)
- message, &me->id));
-
-#if VERBOSE
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Received HELLO size %d\n",
- GNUNET_HELLO_size((const struct GNUNET_HELLO_Message *)message));
-#endif
- GNUNET_TRANSPORT_offer_hello (p2.th, message, NULL, NULL);
- GNUNET_TRANSPORT_get_hello (p2.th, &exchange_hello_last, &p2);
-}
/**
* Return the actual path to a file found in the current
#endif
}
+
+static void
+try_connect (void *cls,
+ const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Asking peers to connect...\n");
+ GNUNET_TRANSPORT_try_connect (p2.th,
+ &p1.id);
+ GNUNET_TRANSPORT_try_connect (p1.th,
+ &p2.id);
+ tct = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
+ &try_connect,
+ NULL);
+}
+
+
static void
run (void *cls,
char *const *args,
GNUNET_assert(p1.th != NULL);
GNUNET_assert(p2.th != NULL);
GNUNET_TRANSPORT_get_hello (p1.th, &exchange_hello, &p1);
+ GNUNET_TRANSPORT_get_hello (p2.th, &exchange_hello_last, &p2);
+ tct = GNUNET_SCHEDULER_add_now (&try_connect, NULL);
}
if ((GNUNET_YES == is_tcp_nat) && (check_gnunet_nat_binary("gnunet-nat-server") != GNUNET_YES))
{
- GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Not running NAT test case, binaries not properly installed.\n");
+ GNUNET_log(GNUNET_ERROR_TYPE_WARNING,
+ "Not running NAT test case, binaries not properly installed.\n");
return 0;
}
if (0 == stat (cert_file_p1, &sbuf ))
{
if (0 == remove(cert_file_p1))
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Successfully removed existing certificate file `%s'\n",cert_file_p1);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Successfully removed existing certificate file `%s'\n",
+ cert_file_p1);
else
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to remove certfile `%s'\n",cert_file_p1);
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Failed to remove certfile `%s'\n",
+ cert_file_p1);
}
if (0 == stat (key_file_p1, &sbuf ))
{
if (0 == remove(key_file_p1))
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Successfully removed private key file `%s'\n",key_file_p1);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Successfully removed private key file `%s'\n",
+ key_file_p1);
else
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to private key file `%s'\n",key_file_p1);
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Failed to private key file `%s'\n",key_file_p1);
}
if (0 == stat (cert_file_p2, &sbuf ))
{
if (0 == remove(cert_file_p2))
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Successfully removed existing certificate file `%s'\n",cert_file_p2);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Successfully removed existing certificate file `%s'\n",
+ cert_file_p2);
else
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to remove certfile `%s'\n",cert_file_p2);
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Failed to remove certfile `%s'\n",cert_file_p2);
}
if (0 == stat (key_file_p2, &sbuf ))
{
if (0 == remove(key_file_p2))
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Successfully removed private key file `%s'\n",key_file_p2);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Successfully removed private key file `%s'\n",
+ key_file_p2);
else
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to private key file `%s'\n",key_file_p2);
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Failed to private key file `%s'\n",
+ key_file_p2);
}
GNUNET_free(key_file_p1);
GNUNET_free(key_file_p2);
static GNUNET_SCHEDULER_TaskIdentifier die_task;
+static GNUNET_SCHEDULER_TaskIdentifier tct;
+
static char *key_file_p1;
static char *cert_file_p1;
static int msg_sent;
static int msg_recv_expected;
static int msg_recv;
-static struct GNUNET_TRANSPORT_TransmitHandle * transmit_handle;
-
-#if VERBOSE
-#define OKPP do { ok++; fprintf (stderr, "Now at stage %u at %s:%u\n", ok, __FILE__, __LINE__); } while (0)
-#else
-#define OKPP do { ok++; } while (0)
-#endif
/**
* Sets a bit active in the bitmap.
const struct GNUNET_SCHEDULER_TaskContext *tc)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "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);
+ "Reliability failed: Last message sent %u Next message scheduled %u Last message received %u Message expected %u\n",
+ msg_sent,
+ msg_scheduled,
+ msg_recv,
+ msg_recv_expected);
GNUNET_break (0);
GNUNET_TRANSPORT_disconnect (p1.th);
GNUNET_TRANSPORT_disconnect (p2.th);
+
+ if (GNUNET_SCHEDULER_NO_TASK != tct)
+ {
+ GNUNET_SCHEDULER_cancel (tct);
+ tct = GNUNET_SCHEDULER_NO_TASK;
+ }
ok = 1;
}
}
+
+static void
+notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
+{
+ connected--;
+#if VERBOSE
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Peer `%4s' disconnected (%p)!\n",
+ GNUNET_i2s (peer), cls);
+#endif
+}
+
+
+
+static void
+exchange_hello_last (void *cls,
+ const struct GNUNET_MessageHeader *message)
+{
+ struct PeerContext *me = cls;
+
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Exchanging HELLO of size %d with peer (%s)!\n",
+ (int) GNUNET_HELLO_size((const struct GNUNET_HELLO_Message *)message),
+ GNUNET_i2s (&me->id));
+ GNUNET_assert (message != NULL);
+ GNUNET_assert (GNUNET_OK ==
+ GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *)
+ message, &me->id));
+ GNUNET_TRANSPORT_offer_hello (p1.th, message, NULL, NULL);
+}
+
+
+
+static void
+exchange_hello (void *cls,
+ const struct GNUNET_MessageHeader *message)
+{
+ struct PeerContext *me = cls;
+
+ GNUNET_assert (message != NULL);
+ GNUNET_assert (GNUNET_OK ==
+ GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *)
+ message, &me->id));
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Exchanging HELLO of size %d from peer %s!\n",
+ (int) GNUNET_HELLO_size((const struct GNUNET_HELLO_Message *)message),
+ GNUNET_i2s (&me->id));
+ GNUNET_TRANSPORT_offer_hello (p2.th, message, NULL, NULL);
+}
+
+
static void
notify_connect (void *cls,
const struct GNUNET_PeerIdentity *peer,
const struct GNUNET_TRANSPORT_ATS_Information *ats,
uint32_t ats_count)
{
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Peer `%4s' connected to us (%p)!\n",
+ GNUNET_i2s (peer),
+ cls);
if (cls == &p1)
{
GNUNET_TRANSPORT_set_quota (p1.th,
GNUNET_BANDWIDTH_value_init (1024 * 1024 * 1024));
connected++;
}
-
- if (connected == 2)
+ if (2 == connected)
{
-
- if ((transmit_handle!=NULL) && (cls == NULL))
- GNUNET_TRANSPORT_notify_transmit_ready_cancel(transmit_handle);
- if ((transmit_handle!=NULL) && (cls == &transmit_handle))
- transmit_handle=NULL;
+ GNUNET_SCHEDULER_cancel (die_task);
+ GNUNET_SCHEDULER_cancel (tct);
+ tct = GNUNET_SCHEDULER_NO_TASK;
+ GNUNET_TRANSPORT_get_hello_cancel (p2.th, &exchange_hello_last, &p2);
+ GNUNET_TRANSPORT_get_hello_cancel (p1.th, &exchange_hello, &p1);
+ die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT,
+ &end_badly, NULL);
GNUNET_TRANSPORT_notify_transmit_ready (p2.th,
&p1.id,
get_size (0), 0, TIMEOUT,
¬ify_ready,
NULL);
+
}
-#if VERBOSE
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Peer `%4s' connected to us (%p)!\n", GNUNET_i2s (peer), cls);
-#endif
-}
-
-
-static void
-notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
-{
-#if VERBOSE
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Peer `%4s' disconnected (%p)!\n",
- GNUNET_i2s (peer), cls);
-#endif
}
GNUNET_assert (p->th != NULL);
}
-static size_t
-notify_ready_connect (void *cls, size_t size, void *buf)
-{
- return 0;
-}
-
-static void
-exchange_hello_last (void *cls,
- const struct GNUNET_MessageHeader *message)
-{
- struct PeerContext *me = cls;
- transmit_handle = NULL;
- GNUNET_TRANSPORT_get_hello_cancel (p2.th, &exchange_hello_last, me);
-#if VERBOSE
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Exchanging HELLO with peer (%p)!\n", cls);
-#endif
- GNUNET_assert (ok >= 3);
- OKPP;
- GNUNET_assert (message != NULL);
- GNUNET_assert (GNUNET_OK ==
- GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *)
- message, &me->id));
-
- GNUNET_assert(NULL != (transmit_handle = GNUNET_TRANSPORT_notify_transmit_ready (p2.th,
- &p1.id,
- sizeof (struct GNUNET_MessageHeader), 0,
- TIMEOUT,
- ¬ify_ready_connect,
- &transmit_handle)));
-
- /* both HELLOs exchanged, get ready to test transmission! */
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Finished exchanging HELLOs, now waiting for transmission!\n");
-}
-
-
-static void
-exchange_hello (void *cls,
- const struct GNUNET_MessageHeader *message)
-{
- struct PeerContext *me = cls;
-
- GNUNET_TRANSPORT_get_hello_cancel (p1.th, &exchange_hello, me);
-#if VERBOSE
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Exchanging HELLO with peer (%p)!\n", cls);
-#endif
- GNUNET_assert (ok >= 2);
- OKPP;
- GNUNET_assert (message != NULL);
- GNUNET_assert (GNUNET_OK ==
- GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *)
- message, &me->id));
-
-#if VERBOSE
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Received HELLO size %d\n",
- GNUNET_HELLO_size((const struct GNUNET_HELLO_Message *)message));
-#endif
- GNUNET_TRANSPORT_offer_hello (p2.th, message, NULL, NULL);
- GNUNET_TRANSPORT_get_hello (p2.th, &exchange_hello_last, &p2);
-}
/**
* Return the actual path to a file found in the current
#endif
}
+
+static void
+try_connect (void *cls,
+ const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Asking peers to connect...\n");
+ GNUNET_TRANSPORT_try_connect (p2.th,
+ &p1.id);
+ GNUNET_TRANSPORT_try_connect (p1.th,
+ &p2.id);
+ tct = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
+ &try_connect,
+ NULL);
+}
+
+
+
static void
run (void *cls,
char *const *args,
const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
{
- GNUNET_assert (ok == 1);
- OKPP;
die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT,
&end_badly,
NULL);
GNUNET_assert(p1.th != NULL);
GNUNET_assert(p2.th != NULL);
GNUNET_TRANSPORT_get_hello (p1.th, &exchange_hello, &p1);
+ GNUNET_TRANSPORT_get_hello (p2.th, &exchange_hello_last, &p2);
+ tct = GNUNET_SCHEDULER_add_now (&try_connect, NULL);
}
struct TEST_result
{
- uint64_t timestamp;
- uint64_t duration;
- uint64_t mechs;
- uint64_t peers;
- uint64_t solution;
- uint64_t state;
+ uint64_t timestamp;
+ uint64_t duration;
+ uint64_t mechs;
+ uint64_t peers;
+ uint64_t solution;
+ uint64_t state;
};
struct TestMessage
/**
* Check whether peers successfully shut down.
*/
-void
+static void
shutdown_callback (void *cls, const char *emsg)
{
if (emsg != NULL)
{
#if VERBOSE
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Shutdown of peers failed!\n");
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Shutdown of peers failed!\n");
#endif
if (ok == 0)
ok = 666;
}
}
-static void shutdown_peers()
+static void
+shutdown_peers()
{
- if (shutdown_task != GNUNET_SCHEDULER_NO_TASK)
- {
- GNUNET_SCHEDULER_cancel(shutdown_task);
- shutdown_task = GNUNET_SCHEDULER_NO_TASK;
- }
- if (stats_task != GNUNET_SCHEDULER_NO_TASK)
- {
- GNUNET_SCHEDULER_cancel(stats_task);
- stats_task = GNUNET_SCHEDULER_NO_TASK;
- }
- if (send_task != GNUNET_SCHEDULER_NO_TASK)
- {
- GNUNET_SCHEDULER_cancel(send_task);
- send_task = GNUNET_SCHEDULER_NO_TASK;
- }
-
- if (t!=NULL)
- {
- GNUNET_TRANSPORT_notify_transmit_ready_cancel(t);
- t = NULL;
- }
-
- GNUNET_TRANSPORT_disconnect(th);
-
- if (s_time != NULL)
- {
- GNUNET_STATISTICS_get_cancel(s_time);
- s_time = NULL;
- }
- if (s_peers != NULL)
- {
- GNUNET_STATISTICS_get_cancel(s_peers);
- s_peers = NULL;
- }
- if (s_mechs != NULL)
- {
- GNUNET_STATISTICS_get_cancel(s_mechs);
- s_mechs = NULL;
- }
- if (s_solution != NULL)
- {
- GNUNET_STATISTICS_get_cancel(s_solution);
- s_solution = NULL;
- }
- if (s_duration != NULL)
- {
- GNUNET_STATISTICS_get_cancel(s_duration);
- s_duration = NULL;
- }
- if (s_invalid != NULL)
- {
- GNUNET_STATISTICS_get_cancel(s_invalid);
- s_invalid = NULL;
- }
- if (s_state != NULL)
- {
- GNUNET_STATISTICS_get_cancel(s_state);
- s_state = NULL;
- }
-
- GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL);
+ if (shutdown_task != GNUNET_SCHEDULER_NO_TASK)
+ {
+ GNUNET_SCHEDULER_cancel(shutdown_task);
+ shutdown_task = GNUNET_SCHEDULER_NO_TASK;
+ }
+ if (stats_task != GNUNET_SCHEDULER_NO_TASK)
+ {
+ GNUNET_SCHEDULER_cancel(stats_task);
+ stats_task = GNUNET_SCHEDULER_NO_TASK;
+ }
+ if (send_task != GNUNET_SCHEDULER_NO_TASK)
+ {
+ GNUNET_SCHEDULER_cancel(send_task);
+ send_task = GNUNET_SCHEDULER_NO_TASK;
+ }
+
+ if (t != NULL)
+ {
+ GNUNET_TRANSPORT_notify_transmit_ready_cancel(t);
+ t = NULL;
+ }
+ GNUNET_TRANSPORT_disconnect(th);
+ if (s_time != NULL)
+ {
+ GNUNET_STATISTICS_get_cancel(s_time);
+ s_time = NULL;
+ }
+ if (s_peers != NULL)
+ {
+ GNUNET_STATISTICS_get_cancel(s_peers);
+ s_peers = NULL;
+ }
+ if (s_mechs != NULL)
+ {
+ GNUNET_STATISTICS_get_cancel(s_mechs);
+ s_mechs = NULL;
+ }
+ if (s_solution != NULL)
+ {
+ GNUNET_STATISTICS_get_cancel(s_solution);
+ s_solution = NULL;
+ }
+ if (s_duration != NULL)
+ {
+ GNUNET_STATISTICS_get_cancel(s_duration);
+ s_duration = NULL;
+ }
+ if (s_invalid != NULL)
+ {
+ GNUNET_STATISTICS_get_cancel(s_invalid);
+ s_invalid = NULL;
+ }
+ if (s_state != NULL)
+ {
+ GNUNET_STATISTICS_get_cancel(s_state);
+ s_state = NULL;
+ }
+ GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL);
}
-static void evaluate_measurements()
+static void
+evaluate_measurements()
{
- int c;
- //int mechs = 0;
- double average[3];
- double stddev[3];
- //char * output;
- c = 1;
-
- //GNUNET_asprintf(&output, "p,%i,m,%i,",peers, MEASUREMENTS, results_modified[0].mechs,
-
- average[0] = 0.0;
- for (c=0; c<c_new;c++)
- {
- average[0] += (double) results_new[c].duration;
- }
- average[0] /= c_new;
-
- stddev[0] = 0.0;
- for (c=0; c<c_new;c++)
- {
- stddev[0] += (results_new[c].duration - average[0]) * (results_new[c].duration - average[0]);
- }
- stddev[0] /= c_new;
- stddev[0] = sqrt (stddev[0]);
- if (!machine_parsable)
- fprintf (stderr,
- "new, %i measurements, average: %f stddev: %f\n",
- c_new, average[0], stddev[0]);
-
- average[1] = 0.0;
- for (c=0; c<c_modified;c++)
- {
- average[1] += (double) results_modified[c].duration;
- }
- average[1] /= c_modified;
-
- stddev[1] = 0.0;
- for (c=0; c<c_modified;c++)
- {
- stddev[1] += (results_modified[c].duration - average[1]) * (results_modified[c].duration - average[1]);
- }
- stddev[1] /= c_modified;
- stddev[1] = sqrt (stddev[1]);
- if (!machine_parsable)
- fprintf (stderr,
- "modified, %i measurements, average: %f stddev: %f\n",
- c_modified, average[1], stddev[1]);
-
- average[2] = 0.0;
- for (c=0; c<c_unmodified;c++)
- {
- average[2] += (double) results_unmodified[c].duration;
- }
- average[2] /= c_unmodified;
- stddev[2] = 0.0;
- for (c=0; c<c_unmodified;c++)
- {
- stddev[2] += (results_unmodified[c].duration - average[2]) * (results_unmodified[c].duration - average[2]);
- }
- stddev[2] /= c_unmodified;
- stddev[2] = sqrt (stddev[2]);
-
- if (!machine_parsable)
- fprintf (stderr,
- "unmodified, %i measurements, average: %f stddev: %f\n",
- c_unmodified, average[2], stddev[2]);
-
- if (machine_parsable)
- fprintf (stderr,
- "peers,%i,mechs,%llu,"
- "new,%i,%f,%f,"
- "mod,%i,%f,%f,"
- "unmod,%i,%f,%f\n",
- peers-1, (unsigned long long) results_unmodified[0].mechs,
- c_new, average[0], stddev[0],
- c_modified, average[1], stddev[1],
- c_unmodified, average[2], stddev[2]);
- shutdown_peers();
+ int c;
+ //int mechs = 0;
+ double average[3];
+ double stddev[3];
+ //char * output;
+ c = 1;
+
+ //GNUNET_asprintf(&output, "p,%i,m,%i,",peers, MEASUREMENTS, results_modified[0].mechs,
+
+ average[0] = 0.0;
+ for (c=0; c<c_new;c++)
+ {
+ average[0] += (double) results_new[c].duration;
+ }
+ average[0] /= c_new;
+
+ stddev[0] = 0.0;
+ for (c=0; c<c_new;c++)
+ {
+ stddev[0] += (results_new[c].duration - average[0]) * (results_new[c].duration - average[0]);
+ }
+ stddev[0] /= c_new;
+ stddev[0] = sqrt (stddev[0]);
+ if (!machine_parsable)
+ fprintf (stderr,
+ "new, %i measurements, average: %f stddev: %f\n",
+ c_new, average[0], stddev[0]);
+
+ average[1] = 0.0;
+ for (c=0; c<c_modified;c++)
+ {
+ average[1] += (double) results_modified[c].duration;
+ }
+ average[1] /= c_modified;
+
+ stddev[1] = 0.0;
+ for (c=0; c<c_modified;c++)
+ {
+ stddev[1] += (results_modified[c].duration - average[1]) * (results_modified[c].duration - average[1]);
+ }
+ stddev[1] /= c_modified;
+ stddev[1] = sqrt (stddev[1]);
+ if (!machine_parsable)
+ fprintf (stderr,
+ "modified, %i measurements, average: %f stddev: %f\n",
+ c_modified, average[1], stddev[1]);
+
+ average[2] = 0.0;
+ for (c=0; c<c_unmodified;c++)
+ {
+ average[2] += (double) results_unmodified[c].duration;
+ }
+ average[2] /= c_unmodified;
+ stddev[2] = 0.0;
+ for (c=0; c<c_unmodified;c++)
+ {
+ stddev[2] += (results_unmodified[c].duration - average[2]) * (results_unmodified[c].duration - average[2]);
+ }
+ stddev[2] /= c_unmodified;
+ stddev[2] = sqrt (stddev[2]);
+
+ if (!machine_parsable)
+ fprintf (stderr,
+ "unmodified, %i measurements, average: %f stddev: %f\n",
+ c_unmodified, average[2], stddev[2]);
+
+ if (machine_parsable)
+ fprintf (stderr,
+ "peers,%i,mechs,%llu,"
+ "new,%i,%f,%f,"
+ "mod,%i,%f,%f,"
+ "unmod,%i,%f,%f\n",
+ peers-1, (unsigned long long) results_unmodified[0].mechs,
+ c_new, average[0], stddev[0],
+ c_modified, average[1], stddev[1],
+ c_unmodified, average[2], stddev[2]);
+ shutdown_peers();
}
-int stats_cb (void *cls,
- const char *subsystem,
- const char *name,
- uint64_t value,
- int is_persistent)
-{
- static int printed = GNUNET_NO;
- //GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%s = %llu\n", name ,value);
- if (0 == strcmp (name,"ATS invalid solutions"))
- {
- if (stats_task != GNUNET_SCHEDULER_NO_TASK)
- {
- GNUNET_SCHEDULER_cancel(stats_task);
- stats_task = GNUNET_SCHEDULER_NO_TASK;
- }
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"MLP produced invalid %llu result(s)!\n", value);
- shutdown_peers();
- return GNUNET_SYSERR;
- }
-
- if (0 == strcmp (name,"ATS solution"))
- {
- s_solution = NULL;
- }
-
- if (0 == strcmp (name,"ATS peers"))
- {
- s_peers = NULL;
- }
-
- if (0 == strcmp (name,"ATS mechanisms"))
- {
- s_mechs = NULL;
- }
- if (0 == strcmp (name,"ATS duration"))
- {
- s_duration = NULL;
- }
- if (0 == strcmp (name,"ATS timestamp"))
- {
- s_time = NULL;
- }
- if (0 == strcmp (name,"ATS state"))
+static int
+stats_cb (void *cls,
+ const char *subsystem,
+ const char *name,
+ uint64_t value,
+ int is_persistent)
+{
+ static int printed = GNUNET_NO;
+ //GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%s = %llu\n", name ,value);
+ if (0 == strcmp (name,"ATS invalid solutions"))
+ {
+ if (stats_task != GNUNET_SCHEDULER_NO_TASK)
{
- s_state = NULL;
+ GNUNET_SCHEDULER_cancel(stats_task);
+ stats_task = GNUNET_SCHEDULER_NO_TASK;
}
-
- if ((measurement_started == GNUNET_NO) && (0 == strcmp (name, "ATS peers")) && (value == peers-1))
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"MLP produced invalid %llu result(s)!\n", value);
+ shutdown_peers();
+ return GNUNET_SYSERR;
+ }
+
+ if (0 == strcmp (name,"ATS solution"))
{
- measurement_started = GNUNET_YES;
- count = 1;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "All %llu peers connected\n", value);
-#if !VERBOSE
- if (!machine_parsable) fprintf(stderr, "%i", count);
-#endif
+ s_solution = NULL;
}
-
- if (measurement_started == GNUNET_YES)
+
+ if (0 == strcmp (name,"ATS peers"))
{
- // GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%s == %llu\n", name ,value);
- if (0 == strcmp (name,"ATS timestamp"))
- {
- if (current.timestamp == 0)
- {
- printed = GNUNET_NO;
- current.timestamp = value;
- }
- if (current.timestamp == value)
- {
- printed = GNUNET_YES;
- }
- if (current.timestamp != value)
- {
- if (current.state == ATS_NEW)
- {
- if (c_new < MEASUREMENTS)
- {
- results_new[c_new] = current;
- c_new++;
- }
- else
- {
- force_rebuild = GNUNET_NO;
- force_q_updates = GNUNET_NO;
- send_msg = GNUNET_NO;
- }
- }
- if (current.state == ATS_UNMODIFIED)
- {
- if (c_unmodified < MEASUREMENTS)
- {
- results_unmodified[c_unmodified] = current;
- c_unmodified++;
- }
-
- }
- if (current.state == ATS_Q_UPDATED)
- {
- if (c_modified < MEASUREMENTS)
- {
- results_modified[c_modified] = current;
- c_modified++;
- }
- else
- {
- force_q_updates = GNUNET_NO;
- force_rebuild = GNUNET_YES;
- }
- }
- count ++;
-#if VERBOSE
- fprintf (stderr,
- "(new: %i / modified: %i / unmodified: %i) of %i \n",
- c_new, c_modified, c_unmodified , MEASUREMENTS);
-#endif
- if ((c_modified >= MEASUREMENTS) && (c_new >= MEASUREMENTS) && (c_unmodified >= MEASUREMENTS))
- {
-#if !VERBOSE
- if (!machine_parsable) fprintf(stdout, "\n");
-#endif
- if (stats_task != GNUNET_SCHEDULER_NO_TASK)
- {
- GNUNET_SCHEDULER_cancel(stats_task);
- stats_task = GNUNET_SCHEDULER_NO_TASK;
- }
- evaluate_measurements();
- return GNUNET_SYSERR;
- }
-
- printed = GNUNET_NO;
- current.timestamp = value;
+ s_peers = NULL;
+ }
+
+ if (0 == strcmp (name,"ATS mechanisms"))
+ {
+ s_mechs = NULL;
+ }
+
+ if (0 == strcmp (name,"ATS duration"))
+ {
+ s_duration = NULL;
+ }
+ if (0 == strcmp (name,"ATS timestamp"))
+ {
+ s_time = NULL;
+ }
+ if (0 == strcmp (name,"ATS state"))
+ {
+ s_state = NULL;
+ }
+
+ if ( (measurement_started == GNUNET_NO) &&
+ (0 == strcmp (name, "ATS peers")) &&
+ (value == peers-1) )
+ {
+ measurement_started = GNUNET_YES;
+ count = 1;
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "All %llu peers connected\n",
+ value);
#if !VERBOSE
- if (!machine_parsable) fprintf(stderr, "..%i", count);
+ if (! machine_parsable)
+ fprintf(stderr, "%i", count);
#endif
- return GNUNET_OK;
- }
- }
-
- if (0 == strcmp (name,"ATS solution"))
- {
- current.solution = value;
- if (printed == GNUNET_NO)
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "[%i] %s: %llu \n", count, name, value);
- }
-
- if (0 == strcmp (name,"ATS peers"))
+ }
+
+ if (measurement_started == GNUNET_YES)
+ {
+ // GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%s == %llu\n", name ,value);
+ if (0 == strcmp (name,"ATS timestamp"))
+ {
+ if (current.timestamp == 0)
+ {
+ printed = GNUNET_NO;
+ current.timestamp = value;
+ }
+ if (current.timestamp == value)
+ {
+ printed = GNUNET_YES;
+ }
+ if (current.timestamp != value)
+ {
+ if (current.state == ATS_NEW)
{
- current.peers = value;
- if (printed == GNUNET_NO)
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "[%i] %s: %llu \n", count, name, value);
+ if (c_new < MEASUREMENTS)
+ {
+ results_new[c_new] = current;
+ c_new++;
+ }
+ else
+ {
+ force_rebuild = GNUNET_NO;
+ force_q_updates = GNUNET_NO;
+ send_msg = GNUNET_NO;
+ }
}
-
- if (0 == strcmp (name,"ATS mechanisms"))
+ if (current.state == ATS_UNMODIFIED)
{
- current.mechs = value;
- if (printed == GNUNET_NO)
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "[%i] %s: %llu \n", count, name, value);
+ if (c_unmodified < MEASUREMENTS)
+ {
+ results_unmodified[c_unmodified] = current;
+ c_unmodified++;
+ }
+
}
-
- if (0 == strcmp (name,"ATS duration"))
+ if (current.state == ATS_Q_UPDATED)
{
- current.duration = value;
- if (printed == GNUNET_NO)
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "[%i] %s: %llu \n", count, name, value);
+ if (c_modified < MEASUREMENTS)
+ {
+ results_modified[c_modified] = current;
+ c_modified++;
+ }
+ else
+ {
+ force_q_updates = GNUNET_NO;
+ force_rebuild = GNUNET_YES;
+ }
}
- if (0 == strcmp (name,"ATS state"))
+ count ++;
+#if VERBOSE
+ fprintf (stderr,
+ "(new: %i / modified: %i / unmodified: %i) of %i \n",
+ c_new, c_modified, c_unmodified , MEASUREMENTS);
+#endif
+ if ((c_modified >= MEASUREMENTS) && (c_new >= MEASUREMENTS) && (c_unmodified >= MEASUREMENTS))
{
- current.state = value;
- char * cont;
- if (value == ATS_NEW)
- cont = "NEW";
- if (value == ATS_C_UPDATED)
- cont = "C_UPDATED";
- if (value == ATS_Q_UPDATED)
- cont = "Q_UPDATED";
- if (value == ATS_QC_UPDATED)
- cont = "QC_UPDATED";
- if (value == ATS_UNMODIFIED)
- cont = "UNMODIFIED";
- if (printed == GNUNET_NO)
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "[%i] ATS state: %s\n", count, cont);
+#if !VERBOSE
+ if (!machine_parsable)
+ fprintf(stdout, "\n");
+#endif
+ if (stats_task != GNUNET_SCHEDULER_NO_TASK)
+ {
+ GNUNET_SCHEDULER_cancel(stats_task);
+ stats_task = GNUNET_SCHEDULER_NO_TASK;
+ }
+ evaluate_measurements();
+ return GNUNET_SYSERR;
}
+
+ printed = GNUNET_NO;
+ current.timestamp = value;
+#if !VERBOSE
+ if (! machine_parsable)
+ fprintf(stderr, "..%i", count);
+#endif
+ return GNUNET_OK;
+ }
+ }
+
+ if (0 == strcmp (name,"ATS solution"))
+ {
+ current.solution = value;
+ if (printed == GNUNET_NO)
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "[%i] %s: %llu \n", count, name, value);
+ }
+
+ if (0 == strcmp (name,"ATS peers"))
+ {
+ current.peers = value;
+ if (printed == GNUNET_NO)
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "[%i] %s: %llu \n", count, name, value);
+ }
+
+ if (0 == strcmp (name,"ATS mechanisms"))
+ {
+ current.mechs = value;
+ if (printed == GNUNET_NO)
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "[%i] %s: %llu \n", count, name, value);
+ }
+
+ if (0 == strcmp (name,"ATS duration"))
+ {
+ current.duration = value;
+ if (printed == GNUNET_NO)
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "[%i] %s: %llu \n", count, name, value);
+ }
+ if (0 == strcmp (name,"ATS state"))
+ {
+ current.state = value;
+ char * cont;
+ if (value == ATS_NEW)
+ cont = "NEW";
+ if (value == ATS_C_UPDATED)
+ cont = "C_UPDATED";
+ if (value == ATS_Q_UPDATED)
+ cont = "Q_UPDATED";
+ if (value == ATS_QC_UPDATED)
+ cont = "QC_UPDATED";
+ if (value == ATS_UNMODIFIED)
+ cont = "UNMODIFIED";
+ if (printed == GNUNET_NO)
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "[%i] ATS state: %s\n", count, cont);
+ }
}
- return GNUNET_OK;
+ return GNUNET_OK;
}
-void
+static void
stats_get_task (void *cls,
- const struct GNUNET_SCHEDULER_TaskContext *tc)
+ const struct GNUNET_SCHEDULER_TaskContext *tc)
{
- stats_task = GNUNET_SCHEDULER_NO_TASK;
- if ( (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0)
- return;
-
- s_time = GNUNET_STATISTICS_get (stats, "transport", "ATS timestamp", TIMEOUT, NULL, &stats_cb, NULL);
- s_solution = GNUNET_STATISTICS_get (stats, "transport", "ATS solution", TIMEOUT, NULL, &stats_cb, NULL);
- s_duration = GNUNET_STATISTICS_get (stats, "transport","ATS duration", TIMEOUT, NULL, &stats_cb, NULL);
- s_peers = GNUNET_STATISTICS_get (stats, "transport", "ATS peers", TIMEOUT, NULL, &stats_cb, NULL);
- s_mechs = GNUNET_STATISTICS_get (stats, "transport", "ATS mechanisms", TIMEOUT, NULL, &stats_cb, NULL);
- s_invalid = GNUNET_STATISTICS_get (stats, "transport", "ATS invalid solutions", TIMEOUT, NULL, &stats_cb, NULL);
- s_state = GNUNET_STATISTICS_get (stats, "transport", "ATS state", TIMEOUT, NULL, &stats_cb, NULL);
-
- stats_task = GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 100), &stats_get_task, NULL);
+ stats_task = GNUNET_SCHEDULER_NO_TASK;
+ if ( (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0)
+ return;
+
+ s_time = GNUNET_STATISTICS_get (stats, "transport", "ATS timestamp", TIMEOUT, NULL, &stats_cb, NULL);
+ s_solution = GNUNET_STATISTICS_get (stats, "transport", "ATS solution", TIMEOUT, NULL, &stats_cb, NULL);
+ s_duration = GNUNET_STATISTICS_get (stats, "transport","ATS duration", TIMEOUT, NULL, &stats_cb, NULL);
+ s_peers = GNUNET_STATISTICS_get (stats, "transport", "ATS peers", TIMEOUT, NULL, &stats_cb, NULL);
+ s_mechs = GNUNET_STATISTICS_get (stats, "transport", "ATS mechanisms", TIMEOUT, NULL, &stats_cb, NULL);
+ s_invalid = GNUNET_STATISTICS_get (stats, "transport", "ATS invalid solutions", TIMEOUT, NULL, &stats_cb, NULL);
+ s_state = GNUNET_STATISTICS_get (stats, "transport", "ATS state", TIMEOUT, NULL, &stats_cb, NULL);
+
+ stats_task = GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 100),
+ &stats_get_task, NULL);
}
-void
+
+static void
delay (void *cls,
- const struct GNUNET_SCHEDULER_TaskContext *tc)
+ const struct GNUNET_SCHEDULER_TaskContext *tc)
{
- shutdown_task = GNUNET_SCHEDULER_NO_TASK;
- if ( (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0)
- return;
-
+ shutdown_task = GNUNET_SCHEDULER_NO_TASK;
+ if ( (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0)
+ return;
#if VERBOSE
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Delay over\n");
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Delay over\n");
#endif
- shutdown_peers ();
+ shutdown_peers ();
}
-static void connect_peers()
+static void
+connect_peers()
{
- shutdown_task = GNUNET_SCHEDULER_add_delayed(DELAY, &delay, NULL);
-
+ shutdown_task = GNUNET_SCHEDULER_add_delayed(DELAY, &delay, NULL);
}
-size_t send_dummy_data_task (void *cls, size_t size, void *buf)
+static size_t
+send_dummy_data_task (void *cls, size_t size, void *buf)
{
-
- int s = sizeof (struct TestMessage);
- struct TestMessage hdr;
-
- hdr.header.size = htons (s);
- hdr.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_ATS);
- if (force_rebuild)
- hdr.num = htonl (1);
- if (force_q_updates)
- hdr.num = htonl (2);
+ int s = sizeof (struct TestMessage);
+ struct TestMessage hdr;
+
+ hdr.header.size = htons (s);
+ hdr.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_ATS);
+ if (force_rebuild)
+ hdr.num = htonl (1);
+ if (force_q_updates)
+ hdr.num = htonl (2);
+ memcpy (buf,&hdr, s);
+ // GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Sent bytes: %i of %i\n", s, s);
+ t = NULL;
+ return s;
+}
- memcpy (buf,&hdr, s);
- // GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Sent bytes: %i of %i\n", s, s);
- t = NULL;
- return s;
+static void
+send_task_f (void *cls,
+ const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+ send_task = GNUNET_SCHEDULER_NO_TASK;
+ if ( (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0)
+ return;
+
+ if (t!=NULL)
+ {
+ GNUNET_TRANSPORT_notify_transmit_ready_cancel(t);
+ t = NULL;
+ }
+ // GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Sent bytes: %i to %s\n", size, GNUNET_i2s(&master_deamon->id));
+ if (send_msg == GNUNET_YES)
+ t = GNUNET_TRANSPORT_notify_transmit_ready(th,
+ &master_deamon->id,
+ sizeof (struct TestMessage), 0,
+ SEND_TIMEOUT,
+ &send_dummy_data_task, NULL);
+ send_task = GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS,1000),
+ &send_task_f, NULL);
}
-void send_task_f (void *cls,
- const struct GNUNET_SCHEDULER_TaskContext *tc)
+static void
+notify_connect (void *cls,
+ const struct GNUNET_PeerIdentity *peer,
+ const struct GNUNET_TRANSPORT_ATS_Information *ats,
+ uint32_t ats_count)
{
- send_task = GNUNET_SCHEDULER_NO_TASK;
- if ( (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0)
- return;
-
- if (t!=NULL)
- {
- GNUNET_TRANSPORT_notify_transmit_ready_cancel(t);
- t = NULL;
- }
- // GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Sent bytes: %i to %s\n", size, GNUNET_i2s(&master_deamon->id));
- if (send_msg == GNUNET_YES)
- t = GNUNET_TRANSPORT_notify_transmit_ready(th, &master_deamon->id, sizeof (struct TestMessage), 0, SEND_TIMEOUT, &send_dummy_data_task, NULL);
- send_task = GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS,1000), &send_task_f, NULL);
+ send_task = GNUNET_SCHEDULER_add_now(&send_task_f, NULL);
}
-
-
-void daemon_connect_cb(void *cls,
- const struct GNUNET_PeerIdentity *first,
- const struct GNUNET_PeerIdentity *second,
- uint32_t distance,
- const struct GNUNET_CONFIGURATION_Handle *first_cfg,
- const struct GNUNET_CONFIGURATION_Handle *second_cfg,
- struct GNUNET_TESTING_Daemon *first_daemon,
- struct GNUNET_TESTING_Daemon *second_daemon,
- const char *emsg)
+static void
+notify_disconnect (void *cls,
+ const struct GNUNET_PeerIdentity *peer)
{
- char * firstc = strdup(GNUNET_i2s(first));
- char * secondc = strdup(GNUNET_i2s(second));
- connected++;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Connected peers `%s'<->`%s' (%i/%i)\n", firstc, secondc, connected, peers-1);
- GNUNET_free(firstc);
- GNUNET_free(secondc);
-
- if (((first_daemon == ping_deamon) || (second_daemon == ping_deamon)) && (master_deamon != NULL) && (ping_deamon != NULL))
- {
- th = GNUNET_TRANSPORT_connect (ping_deamon->cfg,&ping_deamon->id, NULL, NULL,NULL, NULL);
- t = NULL;
- force_q_updates = GNUNET_YES;
- send_msg = GNUNET_YES;
- send_task = GNUNET_SCHEDULER_add_now(&send_task_f, NULL);
- }
+ if (GNUNET_SCHEDULER_NO_TASK != send_task)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Disconnect event before transmission request could be scheduled!\n");
+ GNUNET_SCHEDULER_cancel (send_task);
+ send_task = GNUNET_SCHEDULER_NO_TASK;
+ }
+ if (NULL != t)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Disconnect event before transmission request could be completed!\n");
+ GNUNET_TRANSPORT_notify_transmit_ready_cancel (t);
+ t = NULL;
+ }
}
-void cont_cb (void *cls, int success)
+static void
+daemon_connect_cb(void *cls,
+ const struct GNUNET_PeerIdentity *first,
+ const struct GNUNET_PeerIdentity *second,
+ uint32_t distance,
+ const struct GNUNET_CONFIGURATION_Handle *first_cfg,
+ const struct GNUNET_CONFIGURATION_Handle *second_cfg,
+ struct GNUNET_TESTING_Daemon *first_daemon,
+ struct GNUNET_TESTING_Daemon *second_daemon,
+ const char *emsg)
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "STATS cont_cb: %i\n", success);
+ char * firstc = strdup(GNUNET_i2s(first));
+ char * secondc = strdup(GNUNET_i2s(second));
+ connected++;
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Connected peers `%s'<->`%s' (%i/%i)\n",
+ firstc, secondc, connected, peers-1);
+ GNUNET_free(firstc);
+ GNUNET_free(secondc);
+
+ if ( ( (first_daemon == ping_deamon) ||
+ (second_daemon == ping_deamon) ) &&
+ (master_deamon != NULL) &&
+ (ping_deamon != NULL) )
+ {
+ th = GNUNET_TRANSPORT_connect (ping_deamon->cfg,
+ &ping_deamon->id,
+ NULL, NULL,
+ ¬ify_connect,
+ ¬ify_disconnect);
+ force_q_updates = GNUNET_YES;
+ send_msg = GNUNET_YES;
+ }
}
+
+
static void
daemon_start_cb (void *cls,
- const struct GNUNET_PeerIdentity *id,
- const struct GNUNET_CONFIGURATION_Handle *cfg,
- struct GNUNET_TESTING_Daemon *d, const char *emsg)
+ const struct GNUNET_PeerIdentity *id,
+ const struct GNUNET_CONFIGURATION_Handle *cfg,
+ struct GNUNET_TESTING_Daemon *d, const char *emsg)
{
if (id == NULL)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Start callback called with error (too long starting peers), aborting test!\n");
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Error from testing: `%s'\n");
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Error from testing: `%s'\n");
failed_peers++;
if (failed_peers == peers_left)
{
peers_left--;
if (master_deamon == NULL)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Master peer `%s' '%s'\n", GNUNET_i2s(id), d->cfgfile);
-
- master_deamon = d;
- stats = GNUNET_STATISTICS_create("transport", master_deamon->cfg);
- GNUNET_assert (stats != NULL);
- stats_task = GNUNET_SCHEDULER_add_now(&stats_get_task, NULL);
- }
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Master peer `%s' '%s'\n",
+ GNUNET_i2s(id), d->cfgfile);
+ master_deamon = d;
+ stats = GNUNET_STATISTICS_create("transport", master_deamon->cfg);
+ GNUNET_assert (stats != NULL);
+ stats_task = GNUNET_SCHEDULER_add_now(&stats_get_task, NULL);
+ }
else
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connecting peer `%s'\n", GNUNET_i2s(id), GNUNET_i2s(&master_deamon->id));
- GNUNET_TESTING_daemons_connect(d, master_deamon, TIMEOUT, 0, GNUNET_YES,&daemon_connect_cb, NULL);
- }
-
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Connecting peer `%s'\n",
+ GNUNET_i2s(id), GNUNET_i2s(&master_deamon->id));
+ GNUNET_TESTING_daemons_connect(d, master_deamon, TIMEOUT, 0, GNUNET_YES,&daemon_connect_cb, NULL);
+ }
+
if (peers_left == 0)
{
- if (ping_deamon == NULL)
- {
- ping_deamon = d;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Ping peer `%s' '%s'\n", GNUNET_i2s(id), d->cfgfile);
- }
-
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ if (ping_deamon == NULL)
+ {
+ ping_deamon = d;
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Ping peer `%s' '%s'\n", GNUNET_i2s(id), d->cfgfile);
+ }
+
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"All peers started successfully!\n");
connect_peers();
ok = 0;
GNUNET_assert (pg != NULL);
}
+
static int
check ()
{
return ok;
}
+
int
main (int argc, char *argv[])
{
-
int ret;
GNUNET_log_setup ("test-transport-ats",
NULL);
#if !HAVE_LIBGLPK
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "GLPK not installed, exiting testcase\n");
- return 0;
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "GLPK not installed, exiting testcase\n");
+ return 0;
#endif
-
GNUNET_DISK_directory_remove ("/tmp/test-gnunet-testing");
-
-
machine_parsable = GNUNET_NO;
peers = NUM_PEERS;
config_file = "test_transport_ats_4addr.conf";
int c = 0;
if (argc >= 2)
- {
- for (c=0; c<argc; c++)
- {
- /* set peers */
- if ((strcmp(argv[c], "-p") == 0) && c < (argc-1))
- {
- peers = atoi(argv[c+1]);
- peers++;
- }
- /* set machine parsable */
- if (strcmp(argv[c], "-m") == 0)
- {
- machine_parsable = GNUNET_YES;
- }
- /* set config file */
- if ((strcmp(argv[c], "-c") == 0) && c < (argc-1))
- {
- config_file = argv[c+1];
- }
+ {
+ for (c=0; c<argc; c++)
+ {
+ /* set peers */
+ if ((strcmp(argv[c], "-p") == 0) && c < (argc-1))
+ {
+ peers = atoi(argv[c+1]);
+ peers++;
+ }
+ /* set machine parsable */
+ if (strcmp(argv[c], "-m") == 0)
+ {
+ machine_parsable = GNUNET_YES;
+ }
+ /* set config file */
+ if ((strcmp(argv[c], "-c") == 0) && c < (argc-1))
+ {
+ config_file = argv[c+1];
+ }
}
- }
+ }