diff options
author | Christian Grothoff <christian@grothoff.org> | 2021-08-24 15:21:32 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2021-08-24 15:21:32 +0200 |
commit | 5bb46d9a3ab568145f594c5a3cfa31ead3df38eb (patch) | |
tree | 021dd56b9a4fd7d349139a844635bb1675b80167 /src | |
parent | 5ddaa3f8eb5e01882540f21ddf237f3a41311e8a (diff) | |
download | gnunet-5bb46d9a3ab568145f594c5a3cfa31ead3df38eb.tar.gz gnunet-5bb46d9a3ab568145f594c5a3cfa31ead3df38eb.zip |
-remove dead ats-tests, fix strange Debian build issues
Diffstat (limited to 'src')
38 files changed, 29 insertions, 7749 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index 5df85f9db..ef8c5b110 100644 --- a/src/Makefile.am +++ b/src/Makefile.am | |||
@@ -3,7 +3,6 @@ | |||
3 | if HAVE_TESTING | 3 | if HAVE_TESTING |
4 | TESTING = testing | 4 | TESTING = testing |
5 | TESTBED = testbed-logger testbed | 5 | TESTBED = testbed-logger testbed |
6 | ATS_TESTS = ats-tests | ||
7 | endif | 6 | endif |
8 | 7 | ||
9 | if HAVE_EXPERIMENTAL | 8 | if HAVE_EXPERIMENTAL |
@@ -72,7 +71,6 @@ SUBDIRS = \ | |||
72 | ats-tool \ | 71 | ats-tool \ |
73 | core \ | 72 | core \ |
74 | $(TESTBED) \ | 73 | $(TESTBED) \ |
75 | $(ATS_TESTS) \ | ||
76 | nse \ | 74 | nse \ |
77 | dhtu \ | 75 | dhtu \ |
78 | dht \ | 76 | dht \ |
diff --git a/src/ats-tests/.gitignore b/src/ats-tests/.gitignore deleted file mode 100644 index 5e15db496..000000000 --- a/src/ats-tests/.gitignore +++ /dev/null | |||
@@ -1,14 +0,0 @@ | |||
1 | gnunet-solver-eval | ||
2 | gnunet-ats-sim | ||
3 | perf_ats_proportional_core_bandwidth | ||
4 | perf_ats_proportional_core_latency | ||
5 | perf_ats_proportional_core_none | ||
6 | perf_ats_proportional_transport_bandwidth | ||
7 | perf_ats_proportional_transport_latency | ||
8 | perf_ats_proportional_transport_none | ||
9 | perf_ats_mlp_core_bandwidth | ||
10 | perf_ats_mlp_core_latency | ||
11 | perf_ats_mlp_core_none | ||
12 | perf_ats_mlp_transport_bandwidth | ||
13 | perf_ats_mlp_transport_latency | ||
14 | perf_ats_mlp_transport_none | ||
diff --git a/src/ats-tests/Makefile.am b/src/ats-tests/Makefile.am deleted file mode 100644 index d515d3e17..000000000 --- a/src/ats-tests/Makefile.am +++ /dev/null | |||
@@ -1,170 +0,0 @@ | |||
1 | #t This Makefile.am is in the public domain | ||
2 | AM_CPPFLAGS = -I$(top_srcdir)/src/include | ||
3 | |||
4 | pkgcfgdir= $(pkgdatadir)/config.d/ | ||
5 | |||
6 | libexecdir= $(pkglibdir)/libexec/ | ||
7 | |||
8 | if USE_COVERAGE | ||
9 | AM_CFLAGS = -fprofile-arcs -ftest-coverage | ||
10 | endif | ||
11 | |||
12 | if HAVE_TESTING | ||
13 | TESTING_TESTS = \ | ||
14 | perf_ats_proportional_transport_none \ | ||
15 | perf_ats_proportional_transport_bandwidth \ | ||
16 | perf_ats_proportional_transport_latency \ | ||
17 | perf_ats_proportional_core_none \ | ||
18 | perf_ats_proportional_core_bandwidth \ | ||
19 | perf_ats_proportional_core_latency \ | ||
20 | $(PERF_MLP) | ||
21 | |||
22 | endif | ||
23 | |||
24 | lib_LTLIBRARIES = \ | ||
25 | libgnunetatstesting.la | ||
26 | |||
27 | check_PROGRAMS = \ | ||
28 | $(TESTING_TESTS) | ||
29 | |||
30 | if ENABLE_TEST_RUN | ||
31 | AM_TESTS_ENVIRONMENT=export GNUNET_PREFIX=$${GNUNET_PREFIX:-@libdir@};export PATH=$${GNUNET_PREFIX:-@prefix@}/bin:$$PATH;unset XDG_DATA_HOME;unset XDG_CONFIG_HOME; | ||
32 | TESTS = $(check_PROGRAMS) | ||
33 | endif | ||
34 | |||
35 | noinst_PROGRAMS = \ | ||
36 | gnunet-ats-sim gnunet-solver-eval | ||
37 | |||
38 | libgnunetatstesting_la_SOURCES = \ | ||
39 | ats-testing.c ats-testing.h \ | ||
40 | ats-testing-log.c ats-testing-traffic.c \ | ||
41 | ats-testing-experiment.c ats-testing-preferences.c | ||
42 | libgnunetatstesting_la_LIBADD = \ | ||
43 | $(top_builddir)/src/testbed/libgnunettestbed.la \ | ||
44 | $(top_builddir)/src/testing/libgnunettesting.la \ | ||
45 | $(top_builddir)/src/statistics/libgnunetstatistics.la \ | ||
46 | $(top_builddir)/src/core/libgnunetcore.la \ | ||
47 | $(top_builddir)/src/transport/libgnunettransport.la \ | ||
48 | $(top_builddir)/src/hello/libgnunethello.la \ | ||
49 | $(top_builddir)/src/ats/libgnunetats.la \ | ||
50 | $(top_builddir)/src/arm/libgnunetarm.la \ | ||
51 | $(top_builddir)/src/util/libgnunetutil.la \ | ||
52 | $(GN_LIBINTL) | ||
53 | libgnunetatstesting_la_DEPENDENCIES = \ | ||
54 | $(top_builddir)/src/testbed/libgnunettestbed.la \ | ||
55 | $(top_builddir)/src/ats/libgnunetats.la | ||
56 | libgnunetatstesting_la_LDFLAGS = \ | ||
57 | $(GN_LIB_LDFLAGS) | ||
58 | |||
59 | gnunet_ats_sim_SOURCES = \ | ||
60 | gnunet-ats-sim.c | ||
61 | gnunet_ats_sim_LDADD = \ | ||
62 | $(top_builddir)/src/util/libgnunetutil.la \ | ||
63 | $(top_builddir)/src/ats-tests/libgnunetatstesting.la \ | ||
64 | $(top_builddir)/src/testing/libgnunettesting.la \ | ||
65 | $(top_builddir)/src/testbed/libgnunettestbed.la \ | ||
66 | $(top_builddir)/src/ats/libgnunetats.la \ | ||
67 | $(top_builddir)/src/core/libgnunetcore.la \ | ||
68 | $(top_builddir)/src/transport/libgnunettransport.la | ||
69 | gnunet_ats_sim_DEPENDENCIES = \ | ||
70 | libgnunetatstesting.la \ | ||
71 | $(top_builddir)/src/util/libgnunetutil.la | ||
72 | gnunet_ats_sim_LDFLAGS = \ | ||
73 | $(GN_LIBINTL) | ||
74 | |||
75 | |||
76 | gnunet_solver_eval_SOURCES = \ | ||
77 | gnunet-solver-eval.c | ||
78 | gnunet_solver_eval_LDADD = \ | ||
79 | $(top_builddir)/src/util/libgnunetutil.la \ | ||
80 | $(top_builddir)/src/ats/libgnunetats.la \ | ||
81 | $(top_builddir)/src/core/libgnunetcore.la \ | ||
82 | $(top_builddir)/src/transport/libgnunettransport.la | ||
83 | gnunet_solver_eval_DEPENDENCIES = \ | ||
84 | $(top_builddir)/src/util/libgnunetutil.la | ||
85 | gnunet_solver_eval_LDFLAGS = \ | ||
86 | $(GN_LIBINTL) | ||
87 | |||
88 | perf_ats_proportional_core_none_SOURCES = \ | ||
89 | perf_ats.c | ||
90 | perf_ats_proportional_core_none_LDADD = \ | ||
91 | $(top_builddir)/src/util/libgnunetutil.la \ | ||
92 | $(top_builddir)/src/ats-tests/libgnunetatstesting.la \ | ||
93 | $(top_builddir)/src/testbed/libgnunettestbed.la \ | ||
94 | $(top_builddir)/src/ats/libgnunetats.la \ | ||
95 | $(top_builddir)/src/core/libgnunetcore.la \ | ||
96 | $(top_builddir)/src/transport/libgnunettransport.la | ||
97 | perf_ats_proportional_core_none_DEPENDENCIES = \ | ||
98 | libgnunetatstesting.la \ | ||
99 | $(top_builddir)/src/util/libgnunetutil.la | ||
100 | |||
101 | perf_ats_proportional_transport_none_SOURCES = \ | ||
102 | perf_ats.c | ||
103 | perf_ats_proportional_transport_none_LDADD = \ | ||
104 | $(top_builddir)/src/util/libgnunetutil.la \ | ||
105 | $(top_builddir)/src/ats-tests/libgnunetatstesting.la \ | ||
106 | $(top_builddir)/src/testbed/libgnunettestbed.la \ | ||
107 | $(top_builddir)/src/ats/libgnunetats.la \ | ||
108 | $(top_builddir)/src/core/libgnunetcore.la \ | ||
109 | $(top_builddir)/src/transport/libgnunettransport.la | ||
110 | perf_ats_proportional_transport_none_DEPENDENCIES = \ | ||
111 | libgnunetatstesting.la \ | ||
112 | $(top_builddir)/src/util/libgnunetutil.la | ||
113 | |||
114 | perf_ats_proportional_core_bandwidth_SOURCES = \ | ||
115 | perf_ats.c | ||
116 | perf_ats_proportional_core_bandwidth_LDADD = \ | ||
117 | $(top_builddir)/src/util/libgnunetutil.la \ | ||
118 | $(top_builddir)/src/ats-tests/libgnunetatstesting.la \ | ||
119 | $(top_builddir)/src/testbed/libgnunettestbed.la \ | ||
120 | $(top_builddir)/src/ats/libgnunetats.la \ | ||
121 | $(top_builddir)/src/core/libgnunetcore.la \ | ||
122 | $(top_builddir)/src/transport/libgnunettransport.la | ||
123 | perf_ats_proportional_core_bandwidth_DEPENDENCIES = \ | ||
124 | libgnunetatstesting.la \ | ||
125 | $(top_builddir)/src/util/libgnunetutil.la | ||
126 | |||
127 | perf_ats_proportional_transport_bandwidth_SOURCES = \ | ||
128 | perf_ats.c | ||
129 | perf_ats_proportional_transport_bandwidth_LDADD = \ | ||
130 | $(top_builddir)/src/util/libgnunetutil.la \ | ||
131 | $(top_builddir)/src/ats-tests/libgnunetatstesting.la \ | ||
132 | $(top_builddir)/src/testbed/libgnunettestbed.la \ | ||
133 | $(top_builddir)/src/ats/libgnunetats.la \ | ||
134 | $(top_builddir)/src/core/libgnunetcore.la \ | ||
135 | $(top_builddir)/src/transport/libgnunettransport.la | ||
136 | perf_ats_proportional_transport_bandwidth_DEPENDENCIES = \ | ||
137 | libgnunetatstesting.la \ | ||
138 | $(top_builddir)/src/util/libgnunetutil.la | ||
139 | |||
140 | perf_ats_proportional_core_latency_SOURCES = \ | ||
141 | perf_ats.c | ||
142 | perf_ats_proportional_core_latency_LDADD = \ | ||
143 | $(top_builddir)/src/util/libgnunetutil.la \ | ||
144 | $(top_builddir)/src/ats-tests/libgnunetatstesting.la \ | ||
145 | $(top_builddir)/src/testbed/libgnunettestbed.la \ | ||
146 | $(top_builddir)/src/ats/libgnunetats.la \ | ||
147 | $(top_builddir)/src/core/libgnunetcore.la \ | ||
148 | $(top_builddir)/src/transport/libgnunettransport.la | ||
149 | perf_ats_proportional_core_latency_DEPENDENCIES = \ | ||
150 | libgnunetatstesting.la \ | ||
151 | $(top_builddir)/src/util/libgnunetutil.la | ||
152 | |||
153 | perf_ats_proportional_transport_latency_SOURCES = \ | ||
154 | perf_ats.c | ||
155 | perf_ats_proportional_transport_latency_LDADD = \ | ||
156 | $(top_builddir)/src/util/libgnunetutil.la \ | ||
157 | $(top_builddir)/src/ats-tests/libgnunetatstesting.la \ | ||
158 | $(top_builddir)/src/testbed/libgnunettestbed.la \ | ||
159 | $(top_builddir)/src/ats/libgnunetats.la \ | ||
160 | $(top_builddir)/src/core/libgnunetcore.la \ | ||
161 | $(top_builddir)/src/transport/libgnunettransport.la | ||
162 | perf_ats_proportional_transport_latency_DEPENDENCIES = \ | ||
163 | libgnunetatstesting.la \ | ||
164 | $(top_builddir)/src/util/libgnunetutil.la | ||
165 | |||
166 | EXTRA_DIST = \ | ||
167 | gnunet_ats_sim_default.conf \ | ||
168 | perf_ats_proportional_none.conf \ | ||
169 | perf_ats_proportional_bandwidth.conf \ | ||
170 | perf_ats_proportional_latency.conf | ||
diff --git a/src/ats-tests/ats-testing-experiment.c b/src/ats-tests/ats-testing-experiment.c deleted file mode 100644 index 9f8db1be4..000000000 --- a/src/ats-tests/ats-testing-experiment.c +++ /dev/null | |||
@@ -1,820 +0,0 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet. | ||
3 | Copyright (C) 2010-2013 GNUnet e.V. | ||
4 | |||
5 | GNUnet is free software: you can redistribute it and/or modify it | ||
6 | under the terms of the GNU Affero General Public License as published | ||
7 | by the Free Software Foundation, either version 3 of the License, | ||
8 | or (at your option) any later version. | ||
9 | |||
10 | GNUnet is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Affero General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Affero General Public License | ||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | ||
19 | */ | ||
20 | /** | ||
21 | * @file ats-tests/ats-testing-experiment.c | ||
22 | * @brief ats benchmark: controlled experiment execution | ||
23 | * @author Christian Grothoff | ||
24 | * @author Matthias Wachs | ||
25 | */ | ||
26 | #include "platform.h" | ||
27 | #include "gnunet_util_lib.h" | ||
28 | #include "ats-testing.h" | ||
29 | |||
30 | const char * | ||
31 | print_op (enum OperationType op) | ||
32 | { | ||
33 | switch (op) | ||
34 | { | ||
35 | case START_SEND: | ||
36 | return "START_SEND"; | ||
37 | |||
38 | case STOP_SEND: | ||
39 | return "STOP_SEND"; | ||
40 | |||
41 | case START_PREFERENCE: | ||
42 | return "START_PREFERENCE"; | ||
43 | |||
44 | case STOP_PREFERENCE: | ||
45 | return "STOP_PREFERENCE"; | ||
46 | |||
47 | default: | ||
48 | break; | ||
49 | } | ||
50 | return ""; | ||
51 | } | ||
52 | |||
53 | |||
54 | static struct Experiment * | ||
55 | create_experiment () | ||
56 | { | ||
57 | struct Experiment *e; | ||
58 | |||
59 | e = GNUNET_new (struct Experiment); | ||
60 | e->name = NULL; | ||
61 | e->num_masters = 0; | ||
62 | e->num_slaves = 0; | ||
63 | e->start = NULL; | ||
64 | e->total_duration = GNUNET_TIME_UNIT_ZERO; | ||
65 | return e; | ||
66 | } | ||
67 | |||
68 | |||
69 | static void | ||
70 | free_experiment (struct Experiment *e) | ||
71 | { | ||
72 | struct Episode *cur; | ||
73 | struct Episode *next; | ||
74 | struct GNUNET_ATS_TEST_Operation *cur_o; | ||
75 | struct GNUNET_ATS_TEST_Operation *next_o; | ||
76 | |||
77 | next = e->start; | ||
78 | for (cur = next; NULL != cur; cur = next) | ||
79 | { | ||
80 | next = cur->next; | ||
81 | |||
82 | next_o = cur->head; | ||
83 | for (cur_o = next_o; NULL != cur_o; cur_o = next_o) | ||
84 | { | ||
85 | next_o = cur_o->next; | ||
86 | GNUNET_free (cur_o); | ||
87 | } | ||
88 | GNUNET_free (cur); | ||
89 | } | ||
90 | |||
91 | GNUNET_free (e->name); | ||
92 | GNUNET_free (e->cfg_file); | ||
93 | GNUNET_free (e); | ||
94 | } | ||
95 | |||
96 | |||
97 | static int | ||
98 | load_episode (struct Experiment *e, | ||
99 | struct Episode *cur, | ||
100 | struct GNUNET_CONFIGURATION_Handle *cfg) | ||
101 | { | ||
102 | struct GNUNET_ATS_TEST_Operation *o; | ||
103 | char *sec_name; | ||
104 | char *op_name; | ||
105 | char *op; | ||
106 | char *type; | ||
107 | char *pref; | ||
108 | int op_counter = 0; | ||
109 | |||
110 | fprintf (stderr, "Parsing episode %u\n", cur->id); | ||
111 | GNUNET_asprintf (&sec_name, "episode-%u", cur->id); | ||
112 | |||
113 | while (1) | ||
114 | { | ||
115 | /* Load operation */ | ||
116 | GNUNET_asprintf (&op_name, "op-%u-operation", op_counter); | ||
117 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string (cfg, | ||
118 | sec_name, | ||
119 | op_name, &op)) | ||
120 | { | ||
121 | GNUNET_free (op_name); | ||
122 | break; | ||
123 | } | ||
124 | o = GNUNET_new (struct GNUNET_ATS_TEST_Operation); | ||
125 | /* operations = set_rate, start_send, stop_send, set_preference */ | ||
126 | if (0 == strcmp (op, "start_send")) | ||
127 | { | ||
128 | o->type = START_SEND; | ||
129 | } | ||
130 | else if (0 == strcmp (op, "stop_send")) | ||
131 | { | ||
132 | o->type = STOP_SEND; | ||
133 | } | ||
134 | else if (0 == strcmp (op, "start_preference")) | ||
135 | { | ||
136 | o->type = START_PREFERENCE; | ||
137 | } | ||
138 | else if (0 == strcmp (op, "stop_preference")) | ||
139 | { | ||
140 | o->type = STOP_PREFERENCE; | ||
141 | } | ||
142 | else | ||
143 | { | ||
144 | fprintf (stderr, "Invalid operation %u `%s' in episode %u\n", | ||
145 | op_counter, op, cur->id); | ||
146 | GNUNET_free (op); | ||
147 | GNUNET_free (op_name); | ||
148 | GNUNET_free (o); | ||
149 | GNUNET_free (sec_name); | ||
150 | return GNUNET_SYSERR; | ||
151 | } | ||
152 | GNUNET_free (op_name); | ||
153 | |||
154 | /* Get source */ | ||
155 | GNUNET_asprintf (&op_name, "op-%u-src", op_counter); | ||
156 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (cfg, | ||
157 | sec_name, | ||
158 | op_name, | ||
159 | &o->src_id)) | ||
160 | { | ||
161 | fprintf (stderr, "Missing src in operation %u `%s' in episode %u\n", | ||
162 | op_counter, op, cur->id); | ||
163 | GNUNET_free (op); | ||
164 | GNUNET_free (op_name); | ||
165 | GNUNET_free (o); | ||
166 | GNUNET_free (sec_name); | ||
167 | return GNUNET_SYSERR; | ||
168 | } | ||
169 | if (o->src_id > (e->num_masters - 1)) | ||
170 | { | ||
171 | fprintf (stderr, "Invalid src %llu in operation %u `%s' in episode %u\n", | ||
172 | o->src_id, op_counter, op, cur->id); | ||
173 | GNUNET_free (op); | ||
174 | GNUNET_free (op_name); | ||
175 | GNUNET_free (o); | ||
176 | GNUNET_free (sec_name); | ||
177 | return GNUNET_SYSERR; | ||
178 | } | ||
179 | GNUNET_free (op_name); | ||
180 | |||
181 | /* Get destination */ | ||
182 | GNUNET_asprintf (&op_name, "op-%u-dest", op_counter); | ||
183 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (cfg, | ||
184 | sec_name, | ||
185 | op_name, | ||
186 | &o->dest_id)) | ||
187 | { | ||
188 | fprintf (stderr, "Missing src in operation %u `%s' in episode %u\n", | ||
189 | op_counter, op, cur->id); | ||
190 | GNUNET_free (op); | ||
191 | GNUNET_free (op_name); | ||
192 | GNUNET_free (o); | ||
193 | GNUNET_free (sec_name); | ||
194 | return GNUNET_SYSERR; | ||
195 | } | ||
196 | if (o->dest_id > (e->num_slaves - 1)) | ||
197 | { | ||
198 | fprintf (stderr, | ||
199 | "Invalid destination %llu in operation %u `%s' in episode %u\n", | ||
200 | o->dest_id, op_counter, op, cur->id); | ||
201 | GNUNET_free (op); | ||
202 | GNUNET_free (op_name); | ||
203 | GNUNET_free (o); | ||
204 | GNUNET_free (sec_name); | ||
205 | return GNUNET_SYSERR; | ||
206 | } | ||
207 | GNUNET_free (op_name); | ||
208 | |||
209 | GNUNET_asprintf (&op_name, "op-%u-type", op_counter); | ||
210 | if ((GNUNET_SYSERR != GNUNET_CONFIGURATION_get_value_string (cfg, | ||
211 | sec_name, | ||
212 | op_name, | ||
213 | &type)) && | ||
214 | (STOP_SEND != o->type) && | ||
215 | (STOP_PREFERENCE != o->type)) | ||
216 | { | ||
217 | /* Load arguments for set_rate, start_send, set_preference */ | ||
218 | if (0 == strcmp (type, "constant")) | ||
219 | { | ||
220 | o->gen_type = GNUNET_ATS_TEST_TG_CONSTANT; | ||
221 | } | ||
222 | else if (0 == strcmp (type, "linear")) | ||
223 | { | ||
224 | o->gen_type = GNUNET_ATS_TEST_TG_LINEAR; | ||
225 | } | ||
226 | else if (0 == strcmp (type, "sinus")) | ||
227 | { | ||
228 | o->gen_type = GNUNET_ATS_TEST_TG_SINUS; | ||
229 | } | ||
230 | else if (0 == strcmp (type, "random")) | ||
231 | { | ||
232 | o->gen_type = GNUNET_ATS_TEST_TG_RANDOM; | ||
233 | } | ||
234 | else | ||
235 | { | ||
236 | fprintf (stderr, "Invalid type %u `%s' in episode %u\n", | ||
237 | op_counter, op, cur->id); | ||
238 | GNUNET_free (type); | ||
239 | GNUNET_free (op); | ||
240 | GNUNET_free (op_name); | ||
241 | GNUNET_free (sec_name); | ||
242 | GNUNET_free (o); | ||
243 | return GNUNET_SYSERR; | ||
244 | } | ||
245 | GNUNET_free (op_name); | ||
246 | |||
247 | /* Get base rate */ | ||
248 | GNUNET_asprintf (&op_name, "op-%u-base-rate", op_counter); | ||
249 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (cfg, | ||
250 | sec_name, | ||
251 | op_name, | ||
252 | &o->base_rate)) | ||
253 | { | ||
254 | fprintf (stderr, | ||
255 | "Missing base rate in operation %u `%s' in episode %u\n", | ||
256 | op_counter, op, cur->id); | ||
257 | GNUNET_free (type); | ||
258 | GNUNET_free (op); | ||
259 | GNUNET_free (op_name); | ||
260 | GNUNET_free (sec_name); | ||
261 | GNUNET_free (o); | ||
262 | return GNUNET_SYSERR; | ||
263 | } | ||
264 | GNUNET_free (op_name); | ||
265 | |||
266 | /* Get max rate */ | ||
267 | GNUNET_asprintf (&op_name, "op-%u-max-rate", op_counter); | ||
268 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (cfg, | ||
269 | sec_name, | ||
270 | op_name, | ||
271 | &o->max_rate)) | ||
272 | { | ||
273 | if ((GNUNET_ATS_TEST_TG_LINEAR == o->gen_type) || | ||
274 | (GNUNET_ATS_TEST_TG_RANDOM == o->gen_type) || | ||
275 | (GNUNET_ATS_TEST_TG_SINUS == o->gen_type)) | ||
276 | { | ||
277 | fprintf (stderr, | ||
278 | "Missing max rate in operation %u `%s' in episode %u\n", | ||
279 | op_counter, op, cur->id); | ||
280 | GNUNET_free (type); | ||
281 | GNUNET_free (op_name); | ||
282 | GNUNET_free (op); | ||
283 | GNUNET_free (o); | ||
284 | GNUNET_free (sec_name); | ||
285 | return GNUNET_SYSERR; | ||
286 | } | ||
287 | } | ||
288 | GNUNET_free (op_name); | ||
289 | |||
290 | /* Get period */ | ||
291 | GNUNET_asprintf (&op_name, "op-%u-period", op_counter); | ||
292 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_time (cfg, | ||
293 | sec_name, | ||
294 | op_name, | ||
295 | &o->period)) | ||
296 | { | ||
297 | o->period = cur->duration; | ||
298 | } | ||
299 | GNUNET_free (op_name); | ||
300 | |||
301 | if (START_PREFERENCE == o->type) | ||
302 | { | ||
303 | /* Get frequency */ | ||
304 | GNUNET_asprintf (&op_name, "op-%u-frequency", op_counter); | ||
305 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_time (cfg, | ||
306 | sec_name, | ||
307 | op_name, | ||
308 | &o->frequency)) | ||
309 | { | ||
310 | fprintf (stderr, | ||
311 | "Missing frequency in operation %u `%s' in episode %u\n", | ||
312 | op_counter, op, cur->id); | ||
313 | GNUNET_free (type); | ||
314 | GNUNET_free (op_name); | ||
315 | GNUNET_free (op); | ||
316 | GNUNET_free (o); | ||
317 | GNUNET_free (sec_name); | ||
318 | return GNUNET_SYSERR; | ||
319 | } | ||
320 | GNUNET_free (op_name); | ||
321 | |||
322 | /* Get preference */ | ||
323 | GNUNET_asprintf (&op_name, "op-%u-pref", op_counter); | ||
324 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string (cfg, | ||
325 | sec_name, | ||
326 | op_name, | ||
327 | &pref)) | ||
328 | { | ||
329 | fprintf (stderr, | ||
330 | "Missing preference in operation %u `%s' in episode %u\n", | ||
331 | op_counter, op, cur->id); | ||
332 | GNUNET_free (type); | ||
333 | GNUNET_free (op_name); | ||
334 | GNUNET_free (op); | ||
335 | GNUNET_free (pref); | ||
336 | GNUNET_free (o); | ||
337 | GNUNET_free (sec_name); | ||
338 | return GNUNET_SYSERR; | ||
339 | } | ||
340 | |||
341 | if (0 == strcmp (pref, "bandwidth")) | ||
342 | o->pref_type = GNUNET_ATS_PREFERENCE_BANDWIDTH; | ||
343 | else if (0 == strcmp (pref, "latency")) | ||
344 | o->pref_type = GNUNET_ATS_PREFERENCE_LATENCY; | ||
345 | else | ||
346 | { | ||
347 | fprintf (stderr, | ||
348 | "Invalid preference in operation %u `%s' in episode %u\n", | ||
349 | op_counter, op, cur->id); | ||
350 | GNUNET_free (type); | ||
351 | GNUNET_free (op_name); | ||
352 | GNUNET_free (op); | ||
353 | GNUNET_free (pref); | ||
354 | GNUNET_free (o); | ||
355 | GNUNET_free (sec_name); | ||
356 | return GNUNET_SYSERR; | ||
357 | } | ||
358 | GNUNET_free (pref); | ||
359 | GNUNET_free (op_name); | ||
360 | } | ||
361 | } | ||
362 | |||
363 | /* Safety checks */ | ||
364 | if ((GNUNET_ATS_TEST_TG_LINEAR == o->gen_type) || | ||
365 | (GNUNET_ATS_TEST_TG_SINUS == o->gen_type)) | ||
366 | { | ||
367 | if ((o->max_rate - o->base_rate) > o->base_rate) | ||
368 | { | ||
369 | /* This will cause an underflow */ | ||
370 | GNUNET_break (0); | ||
371 | } | ||
372 | fprintf (stderr, | ||
373 | "Selected max rate and base rate cannot be used for desired traffic form!\n"); | ||
374 | } | ||
375 | |||
376 | if ((START_SEND == o->type) || (START_PREFERENCE == o->type)) | ||
377 | fprintf (stderr, | ||
378 | "Found operation %u in episode %u: %s [%llu]->[%llu] == %s, %llu -> %llu in %s\n", | ||
379 | op_counter, cur->id, print_op (o->type), o->src_id, | ||
380 | o->dest_id, (NULL != type) ? type : "", | ||
381 | o->base_rate, o->max_rate, | ||
382 | GNUNET_STRINGS_relative_time_to_string (o->period, GNUNET_YES)); | ||
383 | else | ||
384 | fprintf (stderr, "Found operation %u in episode %u: %s [%llu]->[%llu]\n", | ||
385 | op_counter, cur->id, print_op (o->type), o->src_id, o->dest_id); | ||
386 | |||
387 | GNUNET_free (type); | ||
388 | GNUNET_free (op); | ||
389 | |||
390 | GNUNET_CONTAINER_DLL_insert (cur->head, cur->tail, o); | ||
391 | op_counter++; | ||
392 | } | ||
393 | GNUNET_free (sec_name); | ||
394 | |||
395 | return GNUNET_OK; | ||
396 | } | ||
397 | |||
398 | |||
399 | static int | ||
400 | load_episodes (struct Experiment *e, struct GNUNET_CONFIGURATION_Handle *cfg) | ||
401 | { | ||
402 | int e_counter = 0; | ||
403 | char *sec_name; | ||
404 | struct GNUNET_TIME_Relative e_duration; | ||
405 | struct Episode *cur; | ||
406 | struct Episode *last; | ||
407 | |||
408 | e_counter = 0; | ||
409 | last = NULL; | ||
410 | while (1) | ||
411 | { | ||
412 | GNUNET_asprintf (&sec_name, "episode-%u", e_counter); | ||
413 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_time (cfg, | ||
414 | sec_name, | ||
415 | "duration", | ||
416 | &e_duration)) | ||
417 | { | ||
418 | GNUNET_free (sec_name); | ||
419 | break; | ||
420 | } | ||
421 | |||
422 | cur = GNUNET_new (struct Episode); | ||
423 | cur->duration = e_duration; | ||
424 | cur->id = e_counter; | ||
425 | |||
426 | if (GNUNET_OK != load_episode (e, cur, cfg)) | ||
427 | { | ||
428 | GNUNET_free (sec_name); | ||
429 | GNUNET_free (cur); | ||
430 | return GNUNET_SYSERR; | ||
431 | } | ||
432 | |||
433 | fprintf (stderr, "Found episode %u with duration %s \n", | ||
434 | e_counter, | ||
435 | GNUNET_STRINGS_relative_time_to_string (cur->duration, | ||
436 | GNUNET_YES)); | ||
437 | |||
438 | /* Update experiment */ | ||
439 | e->num_episodes++; | ||
440 | e->total_duration = GNUNET_TIME_relative_add (e->total_duration, | ||
441 | cur->duration); | ||
442 | /* Put in linked list */ | ||
443 | if (NULL == last) | ||
444 | e->start = cur; | ||
445 | else | ||
446 | last->next = cur; | ||
447 | |||
448 | GNUNET_free (sec_name); | ||
449 | e_counter++; | ||
450 | last = cur; | ||
451 | } | ||
452 | return e_counter; | ||
453 | } | ||
454 | |||
455 | |||
456 | static void | ||
457 | timeout_experiment (void *cls) | ||
458 | { | ||
459 | struct Experiment *e = cls; | ||
460 | |||
461 | e->experiment_timeout_task = NULL; | ||
462 | fprintf (stderr, "Experiment timeout!\n"); | ||
463 | |||
464 | if (NULL != e->episode_timeout_task) | ||
465 | { | ||
466 | GNUNET_SCHEDULER_cancel (e->episode_timeout_task); | ||
467 | e->episode_timeout_task = NULL; | ||
468 | } | ||
469 | |||
470 | e->e_done_cb (e, GNUNET_TIME_absolute_get_duration (e->start_time), | ||
471 | GNUNET_SYSERR); | ||
472 | } | ||
473 | |||
474 | |||
475 | static void | ||
476 | enforce_start_send (struct GNUNET_ATS_TEST_Operation *op) | ||
477 | { | ||
478 | struct BenchmarkPeer *peer; | ||
479 | struct BenchmarkPartner *partner; | ||
480 | |||
481 | peer = GNUNET_ATS_TEST_get_peer (op->src_id); | ||
482 | if (NULL == peer) | ||
483 | { | ||
484 | GNUNET_break (0); | ||
485 | return; | ||
486 | } | ||
487 | |||
488 | partner = GNUNET_ATS_TEST_get_partner (op->src_id, op->dest_id); | ||
489 | if (NULL == partner) | ||
490 | { | ||
491 | GNUNET_break (0); | ||
492 | return; | ||
493 | } | ||
494 | |||
495 | fprintf (stderr, "Found master %llu slave %llu\n", op->src_id, op->dest_id); | ||
496 | |||
497 | if (NULL != partner->tg) | ||
498 | { | ||
499 | fprintf (stderr, "Stopping traffic between master %llu slave %llu\n", | ||
500 | op->src_id, op->dest_id); | ||
501 | GNUNET_ATS_TEST_generate_traffic_stop (partner->tg); | ||
502 | partner->tg = NULL; | ||
503 | } | ||
504 | |||
505 | partner->tg = GNUNET_ATS_TEST_generate_traffic_start (peer, partner, | ||
506 | op->gen_type, | ||
507 | op->base_rate, | ||
508 | op->max_rate, | ||
509 | op->period, | ||
510 | GNUNET_TIME_UNIT_FOREVER_REL); | ||
511 | } | ||
512 | |||
513 | |||
514 | static void | ||
515 | enforce_stop_send (struct GNUNET_ATS_TEST_Operation *op) | ||
516 | { | ||
517 | struct BenchmarkPartner *p; | ||
518 | |||
519 | p = GNUNET_ATS_TEST_get_partner (op->src_id, op->dest_id); | ||
520 | if (NULL == p) | ||
521 | { | ||
522 | GNUNET_break (0); | ||
523 | return; | ||
524 | } | ||
525 | |||
526 | fprintf (stderr, "Found master %llu slave %llu\n", op->src_id, op->dest_id); | ||
527 | |||
528 | if (NULL != p->tg) | ||
529 | { | ||
530 | fprintf (stderr, "Stopping traffic between master %llu slave %llu\n", | ||
531 | op->src_id, op->dest_id); | ||
532 | GNUNET_ATS_TEST_generate_traffic_stop (p->tg); | ||
533 | p->tg = NULL; | ||
534 | } | ||
535 | } | ||
536 | |||
537 | |||
538 | static void | ||
539 | enforce_start_preference (struct GNUNET_ATS_TEST_Operation *op) | ||
540 | { | ||
541 | struct BenchmarkPeer *peer; | ||
542 | struct BenchmarkPartner *partner; | ||
543 | |||
544 | peer = GNUNET_ATS_TEST_get_peer (op->src_id); | ||
545 | if (NULL == peer) | ||
546 | { | ||
547 | GNUNET_break (0); | ||
548 | return; | ||
549 | } | ||
550 | |||
551 | partner = GNUNET_ATS_TEST_get_partner (op->src_id, op->dest_id); | ||
552 | if (NULL == partner) | ||
553 | { | ||
554 | GNUNET_break (0); | ||
555 | return; | ||
556 | } | ||
557 | |||
558 | fprintf (stderr, "Found master %llu slave %llu\n", op->src_id, op->dest_id); | ||
559 | |||
560 | if (NULL != partner->pg) | ||
561 | { | ||
562 | fprintf (stderr, "Stopping traffic between master %llu slave %llu\n", | ||
563 | op->src_id, op->dest_id); | ||
564 | GNUNET_ATS_TEST_generate_preferences_stop (partner->pg); | ||
565 | partner->pg = NULL; | ||
566 | } | ||
567 | |||
568 | partner->pg = GNUNET_ATS_TEST_generate_preferences_start (peer, partner, | ||
569 | op->gen_type, | ||
570 | op->base_rate, | ||
571 | op->max_rate, | ||
572 | op->period, | ||
573 | op->frequency, | ||
574 | op->pref_type); | ||
575 | } | ||
576 | |||
577 | |||
578 | static void | ||
579 | enforce_stop_preference (struct GNUNET_ATS_TEST_Operation *op) | ||
580 | { | ||
581 | struct BenchmarkPartner *p; | ||
582 | |||
583 | p = GNUNET_ATS_TEST_get_partner (op->src_id, op->dest_id); | ||
584 | if (NULL == p) | ||
585 | { | ||
586 | GNUNET_break (0); | ||
587 | return; | ||
588 | } | ||
589 | |||
590 | fprintf (stderr, "Found master %llu slave %llu\n", op->src_id, op->dest_id); | ||
591 | |||
592 | if (NULL != p->pg) | ||
593 | { | ||
594 | fprintf (stderr, "Stopping preference between master %llu slave %llu\n", | ||
595 | op->src_id, op->dest_id); | ||
596 | GNUNET_ATS_TEST_generate_preferences_stop (p->pg); | ||
597 | p->pg = NULL; | ||
598 | } | ||
599 | } | ||
600 | |||
601 | |||
602 | static void | ||
603 | enforce_episode (struct Episode *ep) | ||
604 | { | ||
605 | struct GNUNET_ATS_TEST_Operation *cur; | ||
606 | |||
607 | for (cur = ep->head; NULL != cur; cur = cur->next) | ||
608 | { | ||
609 | fprintf (stderr, "Enforcing operation: %s [%llu]->[%llu] == %llu\n", | ||
610 | print_op (cur->type), cur->src_id, cur->dest_id, cur->base_rate); | ||
611 | switch (cur->type) | ||
612 | { | ||
613 | case START_SEND: | ||
614 | enforce_start_send (cur); | ||
615 | break; | ||
616 | |||
617 | case STOP_SEND: | ||
618 | enforce_stop_send (cur); | ||
619 | break; | ||
620 | |||
621 | case START_PREFERENCE: | ||
622 | enforce_start_preference (cur); | ||
623 | break; | ||
624 | |||
625 | case STOP_PREFERENCE: | ||
626 | enforce_stop_preference (cur); | ||
627 | break; | ||
628 | |||
629 | default: | ||
630 | break; | ||
631 | } | ||
632 | } | ||
633 | } | ||
634 | |||
635 | |||
636 | static void | ||
637 | timeout_episode (void *cls) | ||
638 | { | ||
639 | struct Experiment *e = cls; | ||
640 | |||
641 | e->episode_timeout_task = NULL; | ||
642 | if (NULL != e->ep_done_cb) | ||
643 | e->ep_done_cb (e->cur); | ||
644 | |||
645 | /* Scheduling next */ | ||
646 | e->cur = e->cur->next; | ||
647 | if (NULL == e->cur) | ||
648 | { | ||
649 | /* done */ | ||
650 | fprintf (stderr, "Last episode done!\n"); | ||
651 | if (NULL != e->experiment_timeout_task) | ||
652 | { | ||
653 | GNUNET_SCHEDULER_cancel (e->experiment_timeout_task); | ||
654 | e->experiment_timeout_task = NULL; | ||
655 | } | ||
656 | e->e_done_cb (e, GNUNET_TIME_absolute_get_duration (e->start_time), | ||
657 | GNUNET_OK); | ||
658 | return; | ||
659 | } | ||
660 | |||
661 | fprintf (stderr, "Running episode %u with timeout %s\n", | ||
662 | e->cur->id, | ||
663 | GNUNET_STRINGS_relative_time_to_string (e->cur->duration, | ||
664 | GNUNET_YES)); | ||
665 | enforce_episode (e->cur); | ||
666 | |||
667 | e->episode_timeout_task = GNUNET_SCHEDULER_add_delayed (e->cur->duration, | ||
668 | &timeout_episode, e); | ||
669 | } | ||
670 | |||
671 | |||
672 | void | ||
673 | GNUNET_ATS_TEST_experimentation_run (struct Experiment *e, | ||
674 | GNUNET_ATS_TESTING_EpisodeDoneCallback | ||
675 | ep_done_cb, | ||
676 | GNUNET_ATS_TESTING_ExperimentDoneCallback | ||
677 | e_done_cb) | ||
678 | { | ||
679 | fprintf (stderr, "Running experiment `%s' with timeout %s\n", e->name, | ||
680 | GNUNET_STRINGS_relative_time_to_string (e->max_duration, | ||
681 | GNUNET_YES)); | ||
682 | e->e_done_cb = e_done_cb; | ||
683 | e->ep_done_cb = ep_done_cb; | ||
684 | e->start_time = GNUNET_TIME_absolute_get (); | ||
685 | |||
686 | /* Start total time out */ | ||
687 | e->experiment_timeout_task = GNUNET_SCHEDULER_add_delayed (e->max_duration, | ||
688 | &timeout_experiment, | ||
689 | e); | ||
690 | |||
691 | /* Start */ | ||
692 | e->cur = e->start; | ||
693 | fprintf (stderr, "Running episode %u with timeout %s\n", | ||
694 | e->cur->id, | ||
695 | GNUNET_STRINGS_relative_time_to_string (e->cur->duration, | ||
696 | GNUNET_YES)); | ||
697 | enforce_episode (e->cur); | ||
698 | e->episode_timeout_task = GNUNET_SCHEDULER_add_delayed (e->cur->duration, | ||
699 | &timeout_episode, e); | ||
700 | } | ||
701 | |||
702 | |||
703 | struct Experiment * | ||
704 | GNUNET_ATS_TEST_experimentation_load (const char *filename) | ||
705 | { | ||
706 | struct Experiment *e; | ||
707 | struct GNUNET_CONFIGURATION_Handle *cfg; | ||
708 | |||
709 | e = NULL; | ||
710 | |||
711 | cfg = GNUNET_CONFIGURATION_create (); | ||
712 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_load (cfg, filename)) | ||
713 | { | ||
714 | fprintf (stderr, "Failed to load `%s'\n", filename); | ||
715 | GNUNET_CONFIGURATION_destroy (cfg); | ||
716 | return NULL; | ||
717 | } | ||
718 | |||
719 | e = create_experiment (); | ||
720 | |||
721 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string (cfg, "experiment", | ||
722 | "name", &e->name)) | ||
723 | { | ||
724 | fprintf (stderr, "Invalid %s", "name"); | ||
725 | free_experiment (e); | ||
726 | return NULL; | ||
727 | } | ||
728 | else | ||
729 | fprintf (stderr, "Experiment name: `%s'\n", e->name); | ||
730 | |||
731 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_filename (cfg, | ||
732 | "experiment", | ||
733 | "cfg_file", | ||
734 | &e->cfg_file)) | ||
735 | { | ||
736 | fprintf (stderr, "Invalid %s", "cfg_file"); | ||
737 | free_experiment (e); | ||
738 | return NULL; | ||
739 | } | ||
740 | else | ||
741 | fprintf (stderr, "Experiment name: `%s'\n", e->cfg_file); | ||
742 | |||
743 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (cfg, "experiment", | ||
744 | "masters", | ||
745 | &e->num_masters)) | ||
746 | { | ||
747 | fprintf (stderr, "Invalid %s", "masters"); | ||
748 | free_experiment (e); | ||
749 | return NULL; | ||
750 | } | ||
751 | else | ||
752 | fprintf (stderr, "Experiment masters: `%llu'\n", | ||
753 | e->num_masters); | ||
754 | |||
755 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (cfg, "experiment", | ||
756 | "slaves", | ||
757 | &e->num_slaves)) | ||
758 | { | ||
759 | fprintf (stderr, "Invalid %s", "slaves"); | ||
760 | free_experiment (e); | ||
761 | return NULL; | ||
762 | } | ||
763 | else | ||
764 | fprintf (stderr, "Experiment slaves: `%llu'\n", | ||
765 | e->num_slaves); | ||
766 | |||
767 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_time (cfg, "experiment", | ||
768 | "log_freq", | ||
769 | &e->log_freq)) | ||
770 | { | ||
771 | fprintf (stderr, "Invalid %s", "log_freq"); | ||
772 | free_experiment (e); | ||
773 | return NULL; | ||
774 | } | ||
775 | else | ||
776 | fprintf (stderr, "Experiment logging frequency: `%s'\n", | ||
777 | GNUNET_STRINGS_relative_time_to_string (e->log_freq, GNUNET_YES)); | ||
778 | |||
779 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_time (cfg, "experiment", | ||
780 | "max_duration", | ||
781 | &e->max_duration)) | ||
782 | { | ||
783 | fprintf (stderr, "Invalid %s", "max_duration"); | ||
784 | free_experiment (e); | ||
785 | return NULL; | ||
786 | } | ||
787 | else | ||
788 | fprintf (stderr, "Experiment duration: `%s'\n", | ||
789 | GNUNET_STRINGS_relative_time_to_string (e->max_duration, | ||
790 | GNUNET_YES)); | ||
791 | |||
792 | load_episodes (e, cfg); | ||
793 | fprintf (stderr, "Loaded %u episodes with total duration %s\n", | ||
794 | e->num_episodes, | ||
795 | GNUNET_STRINGS_relative_time_to_string (e->total_duration, | ||
796 | GNUNET_YES)); | ||
797 | |||
798 | GNUNET_CONFIGURATION_destroy (cfg); | ||
799 | return e; | ||
800 | } | ||
801 | |||
802 | |||
803 | void | ||
804 | GNUNET_ATS_TEST_experimentation_stop (struct Experiment *e) | ||
805 | { | ||
806 | if (NULL != e->experiment_timeout_task) | ||
807 | { | ||
808 | GNUNET_SCHEDULER_cancel (e->experiment_timeout_task); | ||
809 | e->experiment_timeout_task = NULL; | ||
810 | } | ||
811 | if (NULL != e->episode_timeout_task) | ||
812 | { | ||
813 | GNUNET_SCHEDULER_cancel (e->episode_timeout_task); | ||
814 | e->episode_timeout_task = NULL; | ||
815 | } | ||
816 | free_experiment (e); | ||
817 | } | ||
818 | |||
819 | |||
820 | /* end of file ats-testing-experiment.c*/ | ||
diff --git a/src/ats-tests/ats-testing-log.c b/src/ats-tests/ats-testing-log.c deleted file mode 100644 index dfdfa8a80..000000000 --- a/src/ats-tests/ats-testing-log.c +++ /dev/null | |||
@@ -1,979 +0,0 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet. | ||
3 | Copyright (C) 2010-2013 GNUnet e.V. | ||
4 | |||
5 | GNUnet is free software: you can redistribute it and/or modify it | ||
6 | under the terms of the GNU Affero General Public License as published | ||
7 | by the Free Software Foundation, either version 3 of the License, | ||
8 | or (at your option) any later version. | ||
9 | |||
10 | GNUnet is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Affero General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Affero General Public License | ||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | ||
19 | */ | ||
20 | /** | ||
21 | * @file ats-tests/ats-testing-log.c | ||
22 | * @brief ats benchmark: logging for performance tests | ||
23 | * @author Christian Grothoff | ||
24 | * @author Matthias Wachs | ||
25 | */ | ||
26 | #include "platform.h" | ||
27 | #include "gnunet_util_lib.h" | ||
28 | #include "ats-testing.h" | ||
29 | |||
30 | #define THROUGHPUT_TEMPLATE "#!/usr/bin/gnuplot \n" \ | ||
31 | "set datafile separator ';' \n" \ | ||
32 | "set title \"Throughput between Master and Slaves\" \n" \ | ||
33 | "set xlabel \"Time in ms\" \n" \ | ||
34 | "set ylabel \"Bytes/s\" \n" \ | ||
35 | "set grid \n" | ||
36 | |||
37 | #define RTT_TEMPLATE "#!/usr/bin/gnuplot \n" \ | ||
38 | "set datafile separator ';' \n" \ | ||
39 | "set title \"Application level roundtrip time between Master and Slaves\" \n" \ | ||
40 | "set xlabel \"Time in ms\" \n" \ | ||
41 | "set ylabel \"ms\" \n" \ | ||
42 | "set grid \n" | ||
43 | |||
44 | #define BW_TEMPLATE "#!/usr/bin/gnuplot \n" \ | ||
45 | "set datafile separator ';' \n" \ | ||
46 | "set title \"Bandwidth inbound and outbound between Master and Slaves\" \n" \ | ||
47 | "set xlabel \"Time in ms\" \n" \ | ||
48 | "set ylabel \"Bytes / s \" \n" \ | ||
49 | "set grid \n" | ||
50 | |||
51 | #define LOG_ITEMS_TIME 2 | ||
52 | #define LOG_ITEMS_PER_PEER 17 | ||
53 | |||
54 | #define LOG_ITEM_BYTES_SENT 1 | ||
55 | #define LOG_ITEM_MSGS_SENT 2 | ||
56 | #define LOG_ITEM_THROUGHPUT_SENT 3 | ||
57 | #define LOG_ITEM_BYTES_RECV 4 | ||
58 | #define LOG_ITEM_MSGS_RECV 5 | ||
59 | #define LOG_ITEM_THROUGHPUT_RECV 6 | ||
60 | #define LOG_ITEM_APP_RTT 7 | ||
61 | #define LOG_ITEM_ATS_BW_IN 8 | ||
62 | #define LOG_ITEM_ATS_BW_OUT 9 | ||
63 | #define LOG_ITEM_ATS_COSTS_LAN 10 | ||
64 | #define LOG_ITEM_ATS_WAN 11 | ||
65 | #define LOG_ITEM_ATS_WLAN 12 | ||
66 | #define LOG_ITEM_ATS_DELAY 13 | ||
67 | #define LOG_ITEM_ATS_DISTANCE 14 | ||
68 | #define LOG_ITEM_ATS_NETWORKTYPE 15 | ||
69 | #define LOG_ITEM_ATS_UTIL_UP 16 | ||
70 | #define LOG_ITEM_ATS_UTIL_DOWN 17 | ||
71 | |||
72 | /** | ||
73 | * A single logging time step for a partner | ||
74 | */ | ||
75 | struct PartnerLoggingTimestep | ||
76 | { | ||
77 | /** | ||
78 | * Peer | ||
79 | */ | ||
80 | struct BenchmarkPeer *slave; | ||
81 | |||
82 | /** | ||
83 | * Total number of messages this peer has sent | ||
84 | */ | ||
85 | unsigned int total_messages_sent; | ||
86 | |||
87 | /** | ||
88 | * Total number of bytes this peer has sent | ||
89 | */ | ||
90 | unsigned int total_bytes_sent; | ||
91 | |||
92 | /** | ||
93 | * Total number of messages this peer has received | ||
94 | */ | ||
95 | unsigned int total_messages_received; | ||
96 | |||
97 | /** | ||
98 | * Total number of bytes this peer has received | ||
99 | */ | ||
100 | unsigned int total_bytes_received; | ||
101 | |||
102 | /** | ||
103 | * Total outbound throughput for master in Bytes / s | ||
104 | */ | ||
105 | unsigned int throughput_sent; | ||
106 | |||
107 | /** | ||
108 | * Total inbound throughput for master in Bytes / s | ||
109 | */ | ||
110 | unsigned int throughput_recv; | ||
111 | |||
112 | /** | ||
113 | * Accumulated RTT for all messages | ||
114 | */ | ||
115 | unsigned int total_app_rtt; | ||
116 | |||
117 | /** | ||
118 | * Current application level delay | ||
119 | */ | ||
120 | unsigned int app_rtt; | ||
121 | |||
122 | /* Current ATS properties */ | ||
123 | |||
124 | unsigned int ats_distance; | ||
125 | |||
126 | struct GNUNET_TIME_Relative ats_delay; | ||
127 | |||
128 | uint32_t bandwidth_in; | ||
129 | |||
130 | uint32_t bandwidth_out; | ||
131 | |||
132 | uint32_t ats_utilization_out; | ||
133 | |||
134 | uint32_t ats_utilization_in; | ||
135 | |||
136 | enum GNUNET_NetworkType ats_network_type; | ||
137 | |||
138 | double pref_bandwidth; | ||
139 | double pref_delay; | ||
140 | }; | ||
141 | |||
142 | |||
143 | /** | ||
144 | * A single logging time step for a peer | ||
145 | */ | ||
146 | struct PeerLoggingTimestep | ||
147 | { | ||
148 | /** | ||
149 | * Next in DLL | ||
150 | */ | ||
151 | struct PeerLoggingTimestep *next; | ||
152 | |||
153 | /** | ||
154 | * Prev in DLL | ||
155 | */ | ||
156 | struct PeerLoggingTimestep *prev; | ||
157 | |||
158 | /** | ||
159 | * Logging timestamp | ||
160 | */ | ||
161 | struct GNUNET_TIME_Absolute timestamp; | ||
162 | |||
163 | /** | ||
164 | * Total number of messages this peer has sent | ||
165 | */ | ||
166 | unsigned int total_messages_sent; | ||
167 | |||
168 | /** | ||
169 | * Total number of bytes this peer has sent | ||
170 | */ | ||
171 | unsigned int total_bytes_sent; | ||
172 | |||
173 | /** | ||
174 | * Total number of messages this peer has received | ||
175 | */ | ||
176 | unsigned int total_messages_received; | ||
177 | |||
178 | /** | ||
179 | * Total number of bytes this peer has received | ||
180 | */ | ||
181 | unsigned int total_bytes_received; | ||
182 | |||
183 | /** | ||
184 | * Total outbound throughput for master in Bytes / s | ||
185 | */ | ||
186 | unsigned int total_throughput_send; | ||
187 | |||
188 | /** | ||
189 | * Total inbound throughput for master in Bytes / s | ||
190 | */ | ||
191 | unsigned int total_throughput_recv; | ||
192 | |||
193 | /** | ||
194 | * Logs for slaves | ||
195 | */ | ||
196 | struct PartnerLoggingTimestep *slaves_log; | ||
197 | }; | ||
198 | |||
199 | /** | ||
200 | * Entry for a benchmark peer | ||
201 | */ | ||
202 | struct LoggingPeer | ||
203 | { | ||
204 | /** | ||
205 | * Peer | ||
206 | */ | ||
207 | struct BenchmarkPeer *peer; | ||
208 | |||
209 | /** | ||
210 | * Start time | ||
211 | */ | ||
212 | struct GNUNET_TIME_Absolute start; | ||
213 | |||
214 | /** | ||
215 | * DLL for logging entries: head | ||
216 | */ | ||
217 | struct PeerLoggingTimestep *head; | ||
218 | |||
219 | /** | ||
220 | * DLL for logging entries: tail | ||
221 | */ | ||
222 | struct PeerLoggingTimestep *tail; | ||
223 | }; | ||
224 | |||
225 | struct LoggingHandle | ||
226 | { | ||
227 | /** | ||
228 | * Logging task | ||
229 | */ | ||
230 | struct GNUNET_SCHEDULER_Task *log_task; | ||
231 | |||
232 | /** | ||
233 | * Reference to perf_ats' masters | ||
234 | */ | ||
235 | int num_masters; | ||
236 | int num_slaves; | ||
237 | int running; | ||
238 | int verbose; | ||
239 | const char *name; | ||
240 | struct GNUNET_TIME_Relative frequency; | ||
241 | |||
242 | /** | ||
243 | * Log structure of length num_peers | ||
244 | */ | ||
245 | struct LoggingPeer *lp; | ||
246 | }; | ||
247 | |||
248 | |||
249 | static void | ||
250 | write_throughput_gnuplot_script (char *fn, struct LoggingPeer *lp, char **fs, | ||
251 | int slaves) | ||
252 | { | ||
253 | struct GNUNET_DISK_FileHandle *f; | ||
254 | char *gfn; | ||
255 | char *data; | ||
256 | int c_s; | ||
257 | |||
258 | GNUNET_asprintf (&gfn, "gnuplot_throughput_%s", fn); | ||
259 | fprintf (stderr, | ||
260 | "Writing throughput plot for master %u and %u slaves to `%s'\n", | ||
261 | lp->peer->no, slaves, gfn); | ||
262 | |||
263 | f = GNUNET_DISK_file_open (gfn, | ||
264 | GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE, | ||
265 | GNUNET_DISK_PERM_USER_EXEC | ||
266 | | GNUNET_DISK_PERM_USER_READ | ||
267 | | GNUNET_DISK_PERM_USER_WRITE); | ||
268 | if (NULL == f) | ||
269 | { | ||
270 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot open gnuplot file `%s'\n", | ||
271 | gfn); | ||
272 | GNUNET_free (gfn); | ||
273 | return; | ||
274 | } | ||
275 | |||
276 | /* Write header */ | ||
277 | if (GNUNET_SYSERR == GNUNET_DISK_file_write (f, THROUGHPUT_TEMPLATE, | ||
278 | strlen (THROUGHPUT_TEMPLATE))) | ||
279 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
280 | "Cannot write data to plot file `%s'\n", gfn); | ||
281 | |||
282 | /* Write master data */ | ||
283 | GNUNET_asprintf (&data, | ||
284 | "plot '%s' using 2:%u with lines title 'Master %u send total', \\\n" \ | ||
285 | "'%s' using 2:%u with lines title 'Master %u receive total', \\\n", | ||
286 | fn, LOG_ITEMS_TIME + LOG_ITEM_THROUGHPUT_SENT, lp->peer->no, | ||
287 | fn, LOG_ITEMS_TIME + LOG_ITEM_THROUGHPUT_RECV, lp->peer->no); | ||
288 | if (GNUNET_SYSERR == GNUNET_DISK_file_write (f, data, strlen (data))) | ||
289 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
290 | "Cannot write data to plot file `%s'\n", gfn); | ||
291 | GNUNET_free (data); | ||
292 | |||
293 | for (c_s = 0; c_s < slaves; c_s++) | ||
294 | { | ||
295 | GNUNET_asprintf (&data, | ||
296 | "'%s' using 2:%u with lines title 'Master %u - Slave %u send', \\\n" \ | ||
297 | "'%s' using 2:%u with lines title 'Master %u - Slave %u receive'%s\n", | ||
298 | fs[c_s], | ||
299 | LOG_ITEMS_TIME + LOG_ITEM_THROUGHPUT_SENT, | ||
300 | lp->peer->no, | ||
301 | lp->peer->partners[c_s].dest->no, | ||
302 | fs[c_s], | ||
303 | LOG_ITEMS_TIME + LOG_ITEM_THROUGHPUT_RECV, | ||
304 | lp->peer->no, | ||
305 | lp->peer->partners[c_s].dest->no, | ||
306 | (c_s < lp->peer->num_partners - 1) ? ", \\" : | ||
307 | "\n pause -1"); | ||
308 | if (GNUNET_SYSERR == GNUNET_DISK_file_write (f, data, strlen (data))) | ||
309 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
310 | "Cannot write data to plot file `%s'\n", gfn); | ||
311 | GNUNET_free (data); | ||
312 | } | ||
313 | |||
314 | if (GNUNET_SYSERR == GNUNET_DISK_file_close (f)) | ||
315 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
316 | "Cannot close gnuplot file `%s'\n", gfn); | ||
317 | else | ||
318 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
319 | "Data successfully written to plot file `%s'\n", gfn); | ||
320 | GNUNET_free (gfn); | ||
321 | } | ||
322 | |||
323 | |||
324 | static void | ||
325 | write_rtt_gnuplot_script (char *fn, struct LoggingPeer *lp, char **fs, int | ||
326 | slaves) | ||
327 | { | ||
328 | struct GNUNET_DISK_FileHandle *f; | ||
329 | char *gfn; | ||
330 | char *data; | ||
331 | int c_s; | ||
332 | |||
333 | GNUNET_asprintf (&gfn, "gnuplot_rtt_%s", fn); | ||
334 | fprintf (stderr, "Writing rtt plot for master %u to `%s'\n", | ||
335 | lp->peer->no, gfn); | ||
336 | |||
337 | f = GNUNET_DISK_file_open (gfn, | ||
338 | GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE, | ||
339 | GNUNET_DISK_PERM_USER_EXEC | ||
340 | | GNUNET_DISK_PERM_USER_READ | ||
341 | | GNUNET_DISK_PERM_USER_WRITE); | ||
342 | if (NULL == f) | ||
343 | { | ||
344 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot open gnuplot file `%s'\n", | ||
345 | gfn); | ||
346 | GNUNET_free (gfn); | ||
347 | return; | ||
348 | } | ||
349 | |||
350 | /* Write header */ | ||
351 | if (GNUNET_SYSERR == GNUNET_DISK_file_write (f, RTT_TEMPLATE, strlen ( | ||
352 | RTT_TEMPLATE))) | ||
353 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
354 | "Cannot write data to plot file `%s'\n", gfn); | ||
355 | |||
356 | for (c_s = 0; c_s < slaves; c_s++) | ||
357 | { | ||
358 | GNUNET_asprintf (&data, | ||
359 | "%s'%s' using 2:%u with lines title 'Master %u - Slave %u '%s\n", | ||
360 | (0 == c_s) ? "plot " : "", | ||
361 | fs[c_s], | ||
362 | LOG_ITEMS_TIME + LOG_ITEM_APP_RTT, | ||
363 | lp->peer->no, | ||
364 | lp->peer->partners[c_s].dest->no, | ||
365 | (c_s < lp->peer->num_partners - 1) ? ", \\" : | ||
366 | "\n pause -1"); | ||
367 | if (GNUNET_SYSERR == GNUNET_DISK_file_write (f, data, strlen (data))) | ||
368 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
369 | "Cannot write data to plot file `%s'\n", gfn); | ||
370 | GNUNET_free (data); | ||
371 | } | ||
372 | |||
373 | if (GNUNET_SYSERR == GNUNET_DISK_file_close (f)) | ||
374 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot close gnuplot file `%s'\n", | ||
375 | gfn); | ||
376 | else | ||
377 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
378 | "Data successfully written to plot file `%s'\n", gfn); | ||
379 | GNUNET_free (gfn); | ||
380 | } | ||
381 | |||
382 | |||
383 | static void | ||
384 | write_bw_gnuplot_script (char *fn, struct LoggingPeer *lp, char **fs, int | ||
385 | slaves) | ||
386 | { | ||
387 | struct GNUNET_DISK_FileHandle *f; | ||
388 | char *gfn; | ||
389 | char *data; | ||
390 | int c_s; | ||
391 | |||
392 | GNUNET_asprintf (&gfn, "gnuplot_bw_%s", fn); | ||
393 | fprintf (stderr, "Writing bandwidth plot for master %u to `%s'\n", | ||
394 | lp->peer->no, gfn); | ||
395 | |||
396 | f = GNUNET_DISK_file_open (gfn, | ||
397 | GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE, | ||
398 | GNUNET_DISK_PERM_USER_EXEC | ||
399 | | GNUNET_DISK_PERM_USER_READ | ||
400 | | GNUNET_DISK_PERM_USER_WRITE); | ||
401 | if (NULL == f) | ||
402 | { | ||
403 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot open gnuplot file `%s'\n", | ||
404 | gfn); | ||
405 | GNUNET_free (gfn); | ||
406 | return; | ||
407 | } | ||
408 | |||
409 | /* Write header */ | ||
410 | if (GNUNET_SYSERR == GNUNET_DISK_file_write (f, BW_TEMPLATE, strlen ( | ||
411 | BW_TEMPLATE))) | ||
412 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
413 | "Cannot write data to plot file `%s'\n", gfn); | ||
414 | |||
415 | for (c_s = 0; c_s < slaves; c_s++) | ||
416 | { | ||
417 | GNUNET_asprintf (&data, "%s" \ | ||
418 | "'%s' using 2:%u with lines title 'BW out master %u - Slave %u ', \\\n" \ | ||
419 | "'%s' using 2:%u with lines title 'BW in master %u - Slave %u '" \ | ||
420 | "%s\n", | ||
421 | (0 == c_s) ? "plot " : "", | ||
422 | fs[c_s], | ||
423 | LOG_ITEMS_TIME + LOG_ITEM_ATS_BW_OUT, | ||
424 | lp->peer->no, c_s, | ||
425 | fs[c_s], | ||
426 | LOG_ITEMS_TIME + LOG_ITEM_ATS_BW_IN, | ||
427 | lp->peer->no, c_s, | ||
428 | (c_s < lp->peer->num_partners - 1) ? ", \\" : | ||
429 | "\n pause -1"); | ||
430 | if (GNUNET_SYSERR == GNUNET_DISK_file_write (f, data, strlen (data))) | ||
431 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
432 | "Cannot write data to plot file `%s'\n", gfn); | ||
433 | GNUNET_free (data); | ||
434 | } | ||
435 | |||
436 | if (GNUNET_SYSERR == GNUNET_DISK_file_close (f)) | ||
437 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot close gnuplot file `%s'\n", | ||
438 | gfn); | ||
439 | else | ||
440 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
441 | "Data successfully written to plot file `%s'\n", gfn); | ||
442 | GNUNET_free (gfn); | ||
443 | } | ||
444 | |||
445 | |||
446 | void | ||
447 | GNUNET_ATS_TEST_logging_write_to_file (struct LoggingHandle *l, | ||
448 | const char *experiment_name, | ||
449 | int plots) | ||
450 | { | ||
451 | struct GNUNET_DISK_FileHandle *f[l->num_slaves]; | ||
452 | struct GNUNET_DISK_FileHandle *f_m; | ||
453 | const char *tmp_exp_name; | ||
454 | char *filename_master; | ||
455 | char *filename_slaves[l->num_slaves]; | ||
456 | char *data; | ||
457 | struct PeerLoggingTimestep *cur_lt; | ||
458 | struct PartnerLoggingTimestep *plt; | ||
459 | struct GNUNET_TIME_Absolute timestamp; | ||
460 | int c_m; | ||
461 | int c_s; | ||
462 | |||
463 | |||
464 | timestamp = GNUNET_TIME_absolute_get (); | ||
465 | |||
466 | tmp_exp_name = experiment_name; | ||
467 | for (c_m = 0; c_m < l->num_masters; c_m++) | ||
468 | { | ||
469 | GNUNET_asprintf (&filename_master, "%s_%llu_master%u_%s", | ||
470 | experiment_name, | ||
471 | (unsigned long long) timestamp.abs_value_us, c_m, l->name); | ||
472 | fprintf (stderr, "Writing data for master %u to file `%s'\n", | ||
473 | c_m, filename_master); | ||
474 | |||
475 | f_m = GNUNET_DISK_file_open (filename_master, | ||
476 | GNUNET_DISK_OPEN_WRITE | ||
477 | | GNUNET_DISK_OPEN_CREATE, | ||
478 | GNUNET_DISK_PERM_USER_READ | ||
479 | | GNUNET_DISK_PERM_USER_WRITE); | ||
480 | if (NULL == f_m) | ||
481 | { | ||
482 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot open log file `%s'\n", | ||
483 | filename_master); | ||
484 | GNUNET_free (filename_master); | ||
485 | return; | ||
486 | } | ||
487 | |||
488 | GNUNET_asprintf (&data, "# master %u; experiment : %s\n" | ||
489 | "timestamp; timestamp delta; #messages sent; #bytes sent; #throughput sent; #messages received; #bytes received; #throughput received; \n", | ||
490 | c_m, experiment_name); | ||
491 | if (GNUNET_SYSERR == GNUNET_DISK_file_write (f_m, data, strlen (data))) | ||
492 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
493 | "Cannot write data to log file `%s'\n", filename_master); | ||
494 | GNUNET_free (data); | ||
495 | |||
496 | for (c_s = 0; c_s < l->lp[c_m].peer->num_partners; c_s++) | ||
497 | { | ||
498 | GNUNET_asprintf (&filename_slaves[c_s], "%s_%llu_master%u_slave_%u_%s", | ||
499 | tmp_exp_name, | ||
500 | (unsigned long long) timestamp.abs_value_us, | ||
501 | c_m, c_s, l->name); | ||
502 | |||
503 | fprintf (stderr, "Writing data for master %u slave %u to file `%s'\n", | ||
504 | c_m, c_s, filename_slaves[c_s]); | ||
505 | |||
506 | f[c_s] = GNUNET_DISK_file_open (filename_slaves[c_s], | ||
507 | GNUNET_DISK_OPEN_WRITE | ||
508 | | GNUNET_DISK_OPEN_CREATE, | ||
509 | GNUNET_DISK_PERM_USER_READ | ||
510 | | GNUNET_DISK_PERM_USER_WRITE); | ||
511 | if (NULL == f[c_s]) | ||
512 | { | ||
513 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot open log file `%s'\n", | ||
514 | filename_slaves[c_s]); | ||
515 | GNUNET_free (filename_slaves[c_s]); | ||
516 | GNUNET_break (GNUNET_OK == GNUNET_DISK_file_close (f_m)); | ||
517 | GNUNET_free (filename_master); | ||
518 | return; | ||
519 | } | ||
520 | |||
521 | /* Header */ | ||
522 | GNUNET_asprintf (&data, "# master %u; slave %u ; experiment : %s\n" | ||
523 | "timestamp; timestamp delta; #messages sent; #bytes sent; #throughput sent; #messages received; #bytes received; #throughput received; " \ | ||
524 | "rtt; bw in; bw out; ats_cost_lan; ats_cost_wlan; ats_delay; ats_distance; ats_network_type; ats_utilization_up ;ats_utilization_down;" \ | ||
525 | "pref bandwidth; pref delay\n", | ||
526 | c_m, c_s, experiment_name); | ||
527 | if (GNUNET_SYSERR == GNUNET_DISK_file_write (f[c_s], data, strlen (data))) | ||
528 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
529 | "Cannot write data to log file `%s'\n", | ||
530 | filename_slaves[c_s]); | ||
531 | GNUNET_free (data); | ||
532 | } | ||
533 | |||
534 | for (cur_lt = l->lp[c_m].head; NULL != cur_lt; cur_lt = cur_lt->next) | ||
535 | { | ||
536 | if (l->verbose) | ||
537 | fprintf (stderr, | ||
538 | "Master [%u]: timestamp %llu %llu ; %u %u %u ; %u %u %u\n", | ||
539 | l->lp[c_m].peer->no, | ||
540 | (long long unsigned int) cur_lt->timestamp.abs_value_us, | ||
541 | (long long unsigned int) GNUNET_TIME_absolute_get_difference ( | ||
542 | l->lp[c_m].start, | ||
543 | cur_lt | ||
544 | ->timestamp).rel_value_us / 1000, | ||
545 | cur_lt->total_messages_sent, | ||
546 | cur_lt->total_bytes_sent, | ||
547 | cur_lt->total_throughput_send, | ||
548 | cur_lt->total_messages_received, | ||
549 | cur_lt->total_bytes_received, | ||
550 | cur_lt->total_throughput_recv); | ||
551 | |||
552 | /* Assembling master string */ | ||
553 | GNUNET_asprintf (&data, "%llu;%llu;%u;%u;%u;%u;%u;%u;\n", | ||
554 | (long long unsigned int) cur_lt->timestamp.abs_value_us, | ||
555 | (long long unsigned | ||
556 | int) GNUNET_TIME_absolute_get_difference ( | ||
557 | l->lp[c_m].start, | ||
558 | cur_lt | ||
559 | ->timestamp). | ||
560 | rel_value_us / 1000, | ||
561 | cur_lt->total_messages_sent, | ||
562 | cur_lt->total_bytes_sent, | ||
563 | cur_lt->total_throughput_send, | ||
564 | cur_lt->total_messages_received, | ||
565 | cur_lt->total_bytes_received, | ||
566 | cur_lt->total_throughput_recv); | ||
567 | |||
568 | if (GNUNET_SYSERR == GNUNET_DISK_file_write (f_m, data, strlen (data))) | ||
569 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
570 | "Cannot write data to master file %u\n", c_m); | ||
571 | GNUNET_free (data); | ||
572 | |||
573 | |||
574 | for (c_s = 0; c_s < l->lp[c_m].peer->num_partners; c_s++) | ||
575 | { | ||
576 | plt = &cur_lt->slaves_log[c_s]; | ||
577 | /* Log partners */ | ||
578 | |||
579 | /* Assembling slave string */ | ||
580 | GNUNET_asprintf (&data, | ||
581 | "%llu;%llu;%u;%u;%u;%u;%u;%u;%.3f;%u;%u;%llu;%u;%u;%u;%u;%.3f;%.3f\n", | ||
582 | (long long unsigned | ||
583 | int) cur_lt->timestamp.abs_value_us, | ||
584 | (long long unsigned | ||
585 | int) GNUNET_TIME_absolute_get_difference ( | ||
586 | l->lp[c_m].start, | ||
587 | cur_lt | ||
588 | ->timestamp) | ||
589 | .rel_value_us / 1000, | ||
590 | plt->total_messages_sent, | ||
591 | plt->total_bytes_sent, | ||
592 | plt->throughput_sent, | ||
593 | plt->total_messages_received, | ||
594 | plt->total_bytes_received, | ||
595 | plt->throughput_recv, | ||
596 | (double) plt->app_rtt / 1000, | ||
597 | plt->bandwidth_in, | ||
598 | plt->bandwidth_out, | ||
599 | (unsigned long long) plt->ats_delay.rel_value_us, | ||
600 | plt->ats_distance, | ||
601 | plt->ats_network_type, | ||
602 | plt->ats_utilization_out, | ||
603 | plt->ats_utilization_in, | ||
604 | plt->pref_bandwidth, | ||
605 | plt->pref_delay); | ||
606 | |||
607 | if (l->verbose) | ||
608 | fprintf (stderr, | ||
609 | "\t Slave [%u]: %u %u %u ; %u %u %u rtt %u delay %llu bw_in %u bw_out %u \n", | ||
610 | plt->slave->no, | ||
611 | plt->total_messages_sent, | ||
612 | plt->total_bytes_sent, | ||
613 | plt->throughput_sent, | ||
614 | plt->total_messages_received, | ||
615 | plt->total_bytes_received, | ||
616 | plt->throughput_recv, | ||
617 | plt->app_rtt, | ||
618 | (long long unsigned int) plt->ats_delay.rel_value_us, | ||
619 | plt->bandwidth_in, | ||
620 | plt->bandwidth_out); | ||
621 | |||
622 | if (GNUNET_SYSERR == GNUNET_DISK_file_write (f[c_s], data, strlen ( | ||
623 | data))) | ||
624 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
625 | "Cannot write data to log file `%s'\n", | ||
626 | filename_slaves[c_s]); | ||
627 | GNUNET_free (data); | ||
628 | } | ||
629 | } | ||
630 | |||
631 | for (c_s = 0; c_s < l->lp[c_m].peer->num_partners; c_s++) | ||
632 | { | ||
633 | if (GNUNET_SYSERR == GNUNET_DISK_file_close (f[c_s])) | ||
634 | { | ||
635 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
636 | "Cannot close log file for master[%u] slave[%u]\n", c_m, | ||
637 | c_s); | ||
638 | continue; | ||
639 | } | ||
640 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
641 | "Data file successfully written to log file for `%s'\n", | ||
642 | filename_slaves[c_s]); | ||
643 | } | ||
644 | |||
645 | if (GNUNET_SYSERR == GNUNET_DISK_file_close (f_m)) | ||
646 | { | ||
647 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, | ||
648 | "close", | ||
649 | filename_master); | ||
650 | GNUNET_free (filename_master); | ||
651 | return; | ||
652 | } | ||
653 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
654 | "Data file successfully written to log file for master `%s'\n", | ||
655 | filename_master); | ||
656 | |||
657 | if (GNUNET_YES == plots) | ||
658 | { | ||
659 | write_throughput_gnuplot_script (filename_master, &l->lp[c_m], | ||
660 | filename_slaves, l->num_slaves); | ||
661 | write_rtt_gnuplot_script (filename_master, &l->lp[c_m], filename_slaves, | ||
662 | l->num_slaves); | ||
663 | write_bw_gnuplot_script (filename_master, &l->lp[c_m], filename_slaves, | ||
664 | l->num_slaves); | ||
665 | } | ||
666 | } | ||
667 | GNUNET_free (filename_master); | ||
668 | } | ||
669 | |||
670 | |||
671 | /** | ||
672 | * Log all data now | ||
673 | * | ||
674 | * @param l logging handle to use | ||
675 | */ | ||
676 | void | ||
677 | GNUNET_ATS_TEST_logging_now (struct LoggingHandle *l) | ||
678 | { | ||
679 | struct LoggingPeer *bp; | ||
680 | struct PeerLoggingTimestep *mlt; | ||
681 | struct PeerLoggingTimestep *prev_log_mlt; | ||
682 | struct PartnerLoggingTimestep *slt; | ||
683 | struct PartnerLoggingTimestep *prev_log_slt; | ||
684 | struct BenchmarkPartner *p; | ||
685 | struct GNUNET_TIME_Relative delta; | ||
686 | int c_s; | ||
687 | int c_m; | ||
688 | unsigned int app_rtt; | ||
689 | double mult; | ||
690 | |||
691 | if (GNUNET_YES != l->running) | ||
692 | return; | ||
693 | |||
694 | for (c_m = 0; c_m < l->num_masters; c_m++) | ||
695 | { | ||
696 | bp = &l->lp[c_m]; | ||
697 | mlt = GNUNET_new (struct PeerLoggingTimestep); | ||
698 | GNUNET_CONTAINER_DLL_insert_tail (l->lp[c_m].head, l->lp[c_m].tail, mlt); | ||
699 | prev_log_mlt = mlt->prev; | ||
700 | |||
701 | /* Collect data */ | ||
702 | /* Current master state */ | ||
703 | mlt->timestamp = GNUNET_TIME_absolute_get (); | ||
704 | mlt->total_bytes_sent = bp->peer->total_bytes_sent; | ||
705 | mlt->total_messages_sent = bp->peer->total_messages_sent; | ||
706 | mlt->total_bytes_received = bp->peer->total_bytes_received; | ||
707 | mlt->total_messages_received = bp->peer->total_messages_received; | ||
708 | |||
709 | /* Throughput */ | ||
710 | if (NULL == prev_log_mlt) | ||
711 | { | ||
712 | /* Get difference to start */ | ||
713 | delta = GNUNET_TIME_absolute_get_difference (l->lp[c_m].start, | ||
714 | mlt->timestamp); | ||
715 | } | ||
716 | else | ||
717 | { | ||
718 | /* Get difference to last timestep */ | ||
719 | delta = GNUNET_TIME_absolute_get_difference (mlt->prev->timestamp, | ||
720 | mlt->timestamp); | ||
721 | } | ||
722 | |||
723 | /* Multiplication factor for throughput calculation */ | ||
724 | mult = (double) GNUNET_TIME_UNIT_SECONDS.rel_value_us | ||
725 | / (delta.rel_value_us); | ||
726 | |||
727 | /* Total throughput */ | ||
728 | if (NULL != prev_log_mlt) | ||
729 | { | ||
730 | if (mlt->total_bytes_sent - mlt->prev->total_bytes_sent > 0) | ||
731 | { | ||
732 | mlt->total_throughput_send = mult * (mlt->total_bytes_sent | ||
733 | - mlt->prev->total_bytes_sent); | ||
734 | } | ||
735 | else | ||
736 | { | ||
737 | mlt->total_throughput_send = 0; | ||
738 | // mlt->total_throughput_send = prev_log_mlt->total_throughput_send; /* no msgs send */ | ||
739 | } | ||
740 | |||
741 | if (mlt->total_bytes_received - mlt->prev->total_bytes_received > 0) | ||
742 | { | ||
743 | mlt->total_throughput_recv = mult * (mlt->total_bytes_received | ||
744 | - mlt->prev->total_bytes_received); | ||
745 | } | ||
746 | else | ||
747 | { | ||
748 | mlt->total_throughput_recv = 0; | ||
749 | // mlt->total_throughput_recv = prev_log_mlt->total_throughput_recv; /* no msgs received */ | ||
750 | } | ||
751 | } | ||
752 | else | ||
753 | { | ||
754 | mlt->total_throughput_send = mult * mlt->total_bytes_sent; | ||
755 | mlt->total_throughput_recv = mult * mlt->total_bytes_received; | ||
756 | } | ||
757 | |||
758 | if (GNUNET_YES == l->verbose) | ||
759 | { | ||
760 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
761 | "Master[%u] delta: %llu us, bytes (sent/received): %u / %u; throughput send/recv: %u / %u\n", | ||
762 | c_m, | ||
763 | (unsigned long long) delta.rel_value_us, | ||
764 | mlt->total_bytes_sent, | ||
765 | mlt->total_bytes_received, | ||
766 | mlt->total_throughput_send, | ||
767 | mlt->total_throughput_recv); | ||
768 | } | ||
769 | |||
770 | mlt->slaves_log = GNUNET_malloc (bp->peer->num_partners | ||
771 | * sizeof(struct PartnerLoggingTimestep)); | ||
772 | |||
773 | for (c_s = 0; c_s < bp->peer->num_partners; c_s++) | ||
774 | { | ||
775 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
776 | "Collect logging data master[%u] slave [%u]\n", c_m, c_s); | ||
777 | |||
778 | p = &bp->peer->partners[c_s]; | ||
779 | slt = &mlt->slaves_log[c_s]; | ||
780 | |||
781 | slt->slave = p->dest; | ||
782 | /* Bytes sent from master to this slave */ | ||
783 | slt->total_bytes_sent = p->bytes_sent; | ||
784 | /* Messages sent from master to this slave */ | ||
785 | slt->total_messages_sent = p->messages_sent; | ||
786 | /* Bytes master received from this slave */ | ||
787 | slt->total_bytes_received = p->bytes_received; | ||
788 | /* Messages master received from this slave */ | ||
789 | slt->total_messages_received = p->messages_received; | ||
790 | slt->total_app_rtt = p->total_app_rtt; | ||
791 | /* ats performance information */ | ||
792 | slt->ats_delay = p->props.delay; | ||
793 | slt->ats_distance = p->props.distance; | ||
794 | slt->ats_network_type = p->props.scope; | ||
795 | slt->ats_utilization_in = p->props.utilization_out; | ||
796 | slt->ats_utilization_out = p->props.utilization_out; | ||
797 | slt->bandwidth_in = p->bandwidth_in; | ||
798 | slt->bandwidth_out = p->bandwidth_out; | ||
799 | slt->pref_bandwidth = p->pref_bandwidth; | ||
800 | slt->pref_delay = p->pref_delay; | ||
801 | |||
802 | /* Total application level rtt */ | ||
803 | if (NULL == prev_log_mlt) | ||
804 | { | ||
805 | if (0 != slt->total_messages_sent) | ||
806 | app_rtt = slt->total_app_rtt / slt->total_messages_sent; | ||
807 | else | ||
808 | app_rtt = 0; | ||
809 | } | ||
810 | else | ||
811 | { | ||
812 | prev_log_slt = &prev_log_mlt->slaves_log[c_s]; | ||
813 | if ((slt->total_messages_sent - prev_log_slt->total_messages_sent) > 0) | ||
814 | app_rtt = (slt->total_app_rtt - prev_log_slt->total_app_rtt) | ||
815 | / (slt->total_messages_sent | ||
816 | - prev_log_slt->total_messages_sent); | ||
817 | else | ||
818 | { | ||
819 | app_rtt = prev_log_slt->app_rtt; /* No messages were */ | ||
820 | } | ||
821 | } | ||
822 | slt->app_rtt = app_rtt; | ||
823 | |||
824 | /* Partner throughput */ | ||
825 | if (NULL != prev_log_mlt) | ||
826 | { | ||
827 | prev_log_slt = &prev_log_mlt->slaves_log[c_s]; | ||
828 | if (slt->total_bytes_sent > prev_log_slt->total_bytes_sent) | ||
829 | slt->throughput_sent = mult * (slt->total_bytes_sent | ||
830 | - prev_log_slt->total_bytes_sent); | ||
831 | else | ||
832 | slt->throughput_sent = 0; | ||
833 | |||
834 | if (slt->total_bytes_received > prev_log_slt->total_bytes_received) | ||
835 | slt->throughput_recv = mult | ||
836 | * (slt->total_bytes_received | ||
837 | - prev_log_slt->total_bytes_received); | ||
838 | else | ||
839 | slt->throughput_recv = 0; | ||
840 | } | ||
841 | else | ||
842 | { | ||
843 | slt->throughput_sent = mult * slt->total_bytes_sent; | ||
844 | slt->throughput_recv = mult * slt->total_bytes_received; | ||
845 | } | ||
846 | |||
847 | if (GNUNET_YES == l->verbose) | ||
848 | { | ||
849 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
850 | "Master [%u] -> Slave [%u]: delta: %llu us, bytes (sent/received): %u / %u; throughput send/recv: %u / %u\n", | ||
851 | c_m, c_s, | ||
852 | (unsigned long long) delta.rel_value_us, | ||
853 | mlt->total_bytes_sent, | ||
854 | mlt->total_bytes_received, | ||
855 | slt->throughput_sent, | ||
856 | slt->throughput_recv); | ||
857 | } | ||
858 | else | ||
859 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
860 | "Master [%u]: slave [%u]\n", | ||
861 | bp->peer->no, p->dest->no); | ||
862 | } | ||
863 | } | ||
864 | } | ||
865 | |||
866 | |||
867 | static void | ||
868 | collect_log_task (void *cls) | ||
869 | { | ||
870 | struct LoggingHandle *l = cls; | ||
871 | |||
872 | l->log_task = NULL; | ||
873 | GNUNET_ATS_TEST_logging_now (l); | ||
874 | l->log_task = GNUNET_SCHEDULER_add_delayed (l->frequency, | ||
875 | &collect_log_task, | ||
876 | l); | ||
877 | } | ||
878 | |||
879 | |||
880 | /** | ||
881 | * Stop logging | ||
882 | * | ||
883 | * @param l the logging handle | ||
884 | */ | ||
885 | void | ||
886 | GNUNET_ATS_TEST_logging_stop (struct LoggingHandle *l) | ||
887 | { | ||
888 | if (GNUNET_YES != l->running) | ||
889 | return; | ||
890 | |||
891 | if (NULL != l->log_task) | ||
892 | { | ||
893 | GNUNET_SCHEDULER_cancel (l->log_task); | ||
894 | l->log_task = NULL; | ||
895 | } | ||
896 | l->running = GNUNET_NO; | ||
897 | |||
898 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
899 | _ ("Stop logging\n")); | ||
900 | } | ||
901 | |||
902 | |||
903 | /** | ||
904 | * Clean up logging data | ||
905 | * | ||
906 | * @param l the logging handle | ||
907 | */ | ||
908 | void | ||
909 | GNUNET_ATS_TEST_logging_clean_up (struct LoggingHandle *l) | ||
910 | { | ||
911 | int c_m; | ||
912 | struct PeerLoggingTimestep *cur; | ||
913 | |||
914 | if (GNUNET_YES == l->running) | ||
915 | GNUNET_ATS_TEST_logging_stop (l); | ||
916 | |||
917 | for (c_m = 0; c_m < l->num_masters; c_m++) | ||
918 | { | ||
919 | while (NULL != (cur = l->lp[c_m].head)) | ||
920 | { | ||
921 | GNUNET_CONTAINER_DLL_remove (l->lp[c_m].head, l->lp[c_m].tail, cur); | ||
922 | GNUNET_free (cur->slaves_log); | ||
923 | GNUNET_free (cur); | ||
924 | } | ||
925 | } | ||
926 | |||
927 | GNUNET_free (l->lp); | ||
928 | GNUNET_free (l); | ||
929 | } | ||
930 | |||
931 | |||
932 | /** | ||
933 | * Start logging | ||
934 | * | ||
935 | * @param log_frequency the logging frequency | ||
936 | * @param testname the testname | ||
937 | * @param masters the master peers used for benchmarking | ||
938 | * @param num_masters the number of master peers | ||
939 | * @param num_slaves the number of slave peers | ||
940 | * @param verbose verbose logging | ||
941 | * @return the logging handle or NULL on error | ||
942 | */ | ||
943 | struct LoggingHandle * | ||
944 | GNUNET_ATS_TEST_logging_start (struct GNUNET_TIME_Relative log_frequency, | ||
945 | const char *testname, | ||
946 | struct BenchmarkPeer *masters, | ||
947 | int num_masters, | ||
948 | int num_slaves, | ||
949 | int verbose) | ||
950 | { | ||
951 | struct LoggingHandle *l; | ||
952 | int c_m; | ||
953 | |||
954 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
955 | _ ("Start logging `%s'\n"), testname); | ||
956 | |||
957 | l = GNUNET_new (struct LoggingHandle); | ||
958 | l->num_masters = num_masters; | ||
959 | l->num_slaves = num_slaves; | ||
960 | l->name = testname; | ||
961 | l->frequency = log_frequency; | ||
962 | l->verbose = verbose; | ||
963 | l->lp = GNUNET_malloc (num_masters * sizeof(struct LoggingPeer)); | ||
964 | |||
965 | for (c_m = 0; c_m < num_masters; c_m++) | ||
966 | { | ||
967 | l->lp[c_m].peer = &masters[c_m]; | ||
968 | l->lp[c_m].start = GNUNET_TIME_absolute_get (); | ||
969 | } | ||
970 | |||
971 | /* Schedule logging task */ | ||
972 | l->log_task = GNUNET_SCHEDULER_add_now (&collect_log_task, l); | ||
973 | l->running = GNUNET_YES; | ||
974 | |||
975 | return l; | ||
976 | } | ||
977 | |||
978 | |||
979 | /* end of file ats-testing-log.c */ | ||
diff --git a/src/ats-tests/ats-testing-preferences.c b/src/ats-tests/ats-testing-preferences.c deleted file mode 100644 index f30fde960..000000000 --- a/src/ats-tests/ats-testing-preferences.c +++ /dev/null | |||
@@ -1,265 +0,0 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet. | ||
3 | Copyright (C) 2010-2013 GNUnet e.V. | ||
4 | |||
5 | GNUnet is free software: you can redistribute it and/or modify it | ||
6 | under the terms of the GNU Affero General Public License as published | ||
7 | by the Free Software Foundation, either version 3 of the License, | ||
8 | or (at your option) any later version. | ||
9 | |||
10 | GNUnet is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Affero General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Affero General Public License | ||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | ||
19 | */ | ||
20 | /** | ||
21 | * @file ats-tests/ats-testing-preferences.c | ||
22 | * @brief ats benchmark: preference generator | ||
23 | * @author Christian Grothoff | ||
24 | * @author Matthias Wachs | ||
25 | */ | ||
26 | #include "platform.h" | ||
27 | #include "gnunet_util_lib.h" | ||
28 | #include "ats-testing.h" | ||
29 | |||
30 | static struct PreferenceGenerator *pg_head; | ||
31 | static struct PreferenceGenerator *pg_tail; | ||
32 | |||
33 | extern struct GNUNET_ATS_TEST_Topology *top; | ||
34 | |||
35 | static double | ||
36 | get_preference (struct PreferenceGenerator *pg) | ||
37 | { | ||
38 | struct GNUNET_TIME_Relative time_delta; | ||
39 | double delta_value; | ||
40 | double pref_value; | ||
41 | |||
42 | /* Calculate the current preference value */ | ||
43 | switch (pg->type) | ||
44 | { | ||
45 | case GNUNET_ATS_TEST_TG_CONSTANT: | ||
46 | pref_value = pg->base_value; | ||
47 | break; | ||
48 | |||
49 | case GNUNET_ATS_TEST_TG_LINEAR: | ||
50 | time_delta = GNUNET_TIME_absolute_get_duration (pg->time_start); | ||
51 | /* Calculate point of time in the current period */ | ||
52 | time_delta.rel_value_us = time_delta.rel_value_us | ||
53 | % pg->duration_period.rel_value_us; | ||
54 | delta_value = ((double) time_delta.rel_value_us | ||
55 | / pg->duration_period.rel_value_us) * (pg->max_value | ||
56 | - pg->base_value); | ||
57 | if ((pg->max_value < pg->base_value) && | ||
58 | ((pg->max_value - pg->base_value) > pg->base_value)) | ||
59 | { | ||
60 | /* This will cause an underflow */ | ||
61 | GNUNET_break (0); | ||
62 | } | ||
63 | pref_value = pg->base_value + delta_value; | ||
64 | break; | ||
65 | |||
66 | case GNUNET_ATS_TEST_TG_RANDOM: | ||
67 | delta_value = (double) GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, | ||
68 | 10000 * (pg->max_value | ||
69 | - pg->base_value)) | ||
70 | / 10000; | ||
71 | pref_value = pg->base_value + delta_value; | ||
72 | break; | ||
73 | |||
74 | case GNUNET_ATS_TEST_TG_SINUS: | ||
75 | time_delta = GNUNET_TIME_absolute_get_duration (pg->time_start); | ||
76 | /* Calculate point of time in the current period */ | ||
77 | time_delta.rel_value_us = time_delta.rel_value_us | ||
78 | % pg->duration_period.rel_value_us; | ||
79 | if ((pg->max_value - pg->base_value) > pg->base_value) | ||
80 | { | ||
81 | /* This will cause an underflow for second half of sinus period, | ||
82 | * will be detected in general when experiments are loaded */ | ||
83 | GNUNET_break (0); | ||
84 | } | ||
85 | delta_value = (pg->max_value - pg->base_value) | ||
86 | * sin ((2 * M_PI) | ||
87 | / ((double) pg->duration_period.rel_value_us) | ||
88 | * time_delta.rel_value_us); | ||
89 | pref_value = pg->base_value + delta_value; | ||
90 | break; | ||
91 | |||
92 | default: | ||
93 | pref_value = 0.0; | ||
94 | break; | ||
95 | } | ||
96 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Current preference value is %f\n", | ||
97 | pref_value); | ||
98 | return pref_value; | ||
99 | } | ||
100 | |||
101 | |||
102 | static void | ||
103 | set_pref_task (void *cls) | ||
104 | { | ||
105 | struct BenchmarkPartner *p = cls; | ||
106 | double pref_value; | ||
107 | |||
108 | p->pg->set_task = NULL; | ||
109 | |||
110 | pref_value = get_preference (p->pg); | ||
111 | |||
112 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
113 | "Setting preference for master [%u] and slave [%u] for %s to %f\n", | ||
114 | p->me->no, p->dest->no, | ||
115 | GNUNET_ATS_print_preference_type (p->pg->kind), pref_value); | ||
116 | |||
117 | GNUNET_ATS_performance_change_preference (p->me->ats_perf_handle, | ||
118 | &p->dest->id, | ||
119 | p->pg->kind, | ||
120 | pref_value, | ||
121 | GNUNET_ATS_PREFERENCE_END); | ||
122 | |||
123 | switch (p->pg->kind) | ||
124 | { | ||
125 | case GNUNET_ATS_PREFERENCE_BANDWIDTH: | ||
126 | p->pref_bandwidth = pref_value; | ||
127 | break; | ||
128 | |||
129 | case GNUNET_ATS_PREFERENCE_LATENCY: | ||
130 | p->pref_delay = pref_value; | ||
131 | break; | ||
132 | |||
133 | default: | ||
134 | break; | ||
135 | } | ||
136 | |||
137 | p->pg->set_task = GNUNET_SCHEDULER_add_delayed (p->pg->frequency, | ||
138 | set_pref_task, p); | ||
139 | } | ||
140 | |||
141 | |||
142 | /** | ||
143 | * Generate between the source master and the partner and set preferences with a | ||
144 | * value depending on the generator. | ||
145 | * | ||
146 | * @param src source | ||
147 | * @param dest partner | ||
148 | * @param type type of preferences to generate | ||
149 | * @param base_value traffic base rate to send data with | ||
150 | * @param value_rate traffic maximum rate to send data with | ||
151 | * @param period duration of a period of preferences generation (~ 1/frequency) | ||
152 | * @param frequency how long to generate preferences | ||
153 | * @param kind ATS preference to generate | ||
154 | * @return the preference generator | ||
155 | */ | ||
156 | struct PreferenceGenerator * | ||
157 | GNUNET_ATS_TEST_generate_preferences_start (struct BenchmarkPeer *src, | ||
158 | struct BenchmarkPartner *dest, | ||
159 | enum GeneratorType type, | ||
160 | unsigned int base_value, | ||
161 | unsigned int value_rate, | ||
162 | struct GNUNET_TIME_Relative period, | ||
163 | struct GNUNET_TIME_Relative | ||
164 | frequency, | ||
165 | enum GNUNET_ATS_PreferenceKind kind) | ||
166 | { | ||
167 | struct PreferenceGenerator *pg; | ||
168 | |||
169 | if (NULL != dest->pg) | ||
170 | { | ||
171 | GNUNET_break (0); | ||
172 | return NULL; | ||
173 | } | ||
174 | |||
175 | pg = GNUNET_new (struct PreferenceGenerator); | ||
176 | GNUNET_CONTAINER_DLL_insert (pg_head, pg_tail, pg); | ||
177 | pg->type = type; | ||
178 | pg->src = src; | ||
179 | pg->dest = dest; | ||
180 | pg->kind = kind; | ||
181 | pg->base_value = base_value; | ||
182 | pg->max_value = value_rate; | ||
183 | pg->duration_period = period; | ||
184 | pg->frequency = frequency; | ||
185 | pg->time_start = GNUNET_TIME_absolute_get (); | ||
186 | |||
187 | switch (type) | ||
188 | { | ||
189 | case GNUNET_ATS_TEST_TG_CONSTANT: | ||
190 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
191 | "Setting up constant preference generator master[%u] `%s' and slave [%u] `%s' max %u Bips\n", | ||
192 | dest->me->no, GNUNET_i2s (&dest->me->id), | ||
193 | dest->dest->no, GNUNET_i2s (&dest->dest->id), | ||
194 | base_value); | ||
195 | break; | ||
196 | |||
197 | case GNUNET_ATS_TEST_TG_LINEAR: | ||
198 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
199 | "Setting up linear preference generator master[%u] `%s' and slave [%u] `%s' min %u Bips max %u Bips\n", | ||
200 | dest->me->no, GNUNET_i2s (&dest->me->id), | ||
201 | dest->dest->no, GNUNET_i2s (&dest->dest->id), | ||
202 | base_value, value_rate); | ||
203 | break; | ||
204 | |||
205 | case GNUNET_ATS_TEST_TG_SINUS: | ||
206 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
207 | "Setting up sinus preference generator master[%u] `%s' and slave [%u] `%s' baserate %u Bips, amplitude %u Bps\n", | ||
208 | dest->me->no, GNUNET_i2s (&dest->me->id), | ||
209 | dest->dest->no, GNUNET_i2s (&dest->dest->id), | ||
210 | base_value, value_rate); | ||
211 | break; | ||
212 | |||
213 | case GNUNET_ATS_TEST_TG_RANDOM: | ||
214 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
215 | "Setting up random preference generator master[%u] `%s' and slave [%u] `%s' min %u Bips max %u Bps\n", | ||
216 | dest->me->no, GNUNET_i2s (&dest->me->id), | ||
217 | dest->dest->no, GNUNET_i2s (&dest->dest->id), | ||
218 | base_value, value_rate); | ||
219 | break; | ||
220 | |||
221 | default: | ||
222 | break; | ||
223 | } | ||
224 | |||
225 | dest->pg = pg; | ||
226 | pg->set_task = GNUNET_SCHEDULER_add_now (&set_pref_task, dest); | ||
227 | return pg; | ||
228 | } | ||
229 | |||
230 | |||
231 | void | ||
232 | GNUNET_ATS_TEST_generate_preferences_stop (struct PreferenceGenerator *pg) | ||
233 | { | ||
234 | GNUNET_CONTAINER_DLL_remove (pg_head, pg_tail, pg); | ||
235 | pg->dest->pg = NULL; | ||
236 | |||
237 | if (NULL != pg->set_task) | ||
238 | { | ||
239 | GNUNET_SCHEDULER_cancel (pg->set_task); | ||
240 | pg->set_task = NULL; | ||
241 | } | ||
242 | |||
243 | GNUNET_free (pg); | ||
244 | } | ||
245 | |||
246 | |||
247 | /** | ||
248 | * Stop all preferences generators | ||
249 | */ | ||
250 | void | ||
251 | GNUNET_ATS_TEST_generate_preferences_stop_all () | ||
252 | { | ||
253 | struct PreferenceGenerator *cur; | ||
254 | struct PreferenceGenerator *next; | ||
255 | |||
256 | next = pg_head; | ||
257 | for (cur = next; NULL != cur; cur = next) | ||
258 | { | ||
259 | next = cur->next; | ||
260 | GNUNET_ATS_TEST_generate_preferences_stop (cur); | ||
261 | } | ||
262 | } | ||
263 | |||
264 | |||
265 | /* end of file ats-testing-preferences.c */ | ||
diff --git a/src/ats-tests/ats-testing-traffic.c b/src/ats-tests/ats-testing-traffic.c deleted file mode 100644 index f19eac871..000000000 --- a/src/ats-tests/ats-testing-traffic.c +++ /dev/null | |||
@@ -1,393 +0,0 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet. | ||
3 | Copyright (C) 2010-2013, 2016 GNUnet e.V. | ||
4 | |||
5 | GNUnet is free software: you can redistribute it and/or modify it | ||
6 | under the terms of the GNU Affero General Public License as published | ||
7 | by the Free Software Foundation, either version 3 of the License, | ||
8 | or (at your option) any later version. | ||
9 | |||
10 | GNUnet is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Affero General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Affero General Public License | ||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | ||
19 | */ | ||
20 | /** | ||
21 | * @file ats-tests/ats-testing-traffic.c | ||
22 | * @brief ats benchmark: traffic generator | ||
23 | * @author Christian Grothoff | ||
24 | * @author Matthias Wachs | ||
25 | */ | ||
26 | #include "platform.h" | ||
27 | #include "gnunet_util_lib.h" | ||
28 | #include "ats-testing.h" | ||
29 | |||
30 | static struct TrafficGenerator *tg_head; | ||
31 | static struct TrafficGenerator *tg_tail; | ||
32 | |||
33 | extern struct GNUNET_ATS_TEST_Topology *top; | ||
34 | |||
35 | static struct GNUNET_TIME_Relative | ||
36 | get_delay (struct TrafficGenerator *tg) | ||
37 | { | ||
38 | struct GNUNET_TIME_Relative delay; | ||
39 | struct GNUNET_TIME_Relative time_delta; | ||
40 | long long int cur_rate; | ||
41 | long long int delta_rate; | ||
42 | |||
43 | delay.rel_value_us = 0; | ||
44 | |||
45 | /* Calculate the current transmission rate based on the type of traffic */ | ||
46 | switch (tg->type) | ||
47 | { | ||
48 | case GNUNET_ATS_TEST_TG_CONSTANT: | ||
49 | if (UINT32_MAX == tg->base_rate) | ||
50 | return GNUNET_TIME_UNIT_ZERO; | ||
51 | cur_rate = tg->base_rate; | ||
52 | break; | ||
53 | |||
54 | case GNUNET_ATS_TEST_TG_LINEAR: | ||
55 | time_delta = GNUNET_TIME_absolute_get_duration (tg->time_start); | ||
56 | /* Calculate point of time in the current period */ | ||
57 | time_delta.rel_value_us = time_delta.rel_value_us | ||
58 | % tg->duration_period.rel_value_us; | ||
59 | delta_rate = ((double) time_delta.rel_value_us | ||
60 | / tg->duration_period.rel_value_us) | ||
61 | * (tg->max_rate - tg->base_rate); | ||
62 | if ((tg->max_rate < tg->base_rate) && ((tg->max_rate - tg->base_rate) > | ||
63 | tg->base_rate)) | ||
64 | { | ||
65 | /* This will cause an underflow */ | ||
66 | GNUNET_break (0); | ||
67 | } | ||
68 | cur_rate = tg->base_rate + delta_rate; | ||
69 | break; | ||
70 | |||
71 | case GNUNET_ATS_TEST_TG_RANDOM: | ||
72 | cur_rate = tg->base_rate + GNUNET_CRYPTO_random_u32 ( | ||
73 | GNUNET_CRYPTO_QUALITY_WEAK, | ||
74 | tg->max_rate | ||
75 | - tg->base_rate); | ||
76 | break; | ||
77 | |||
78 | case GNUNET_ATS_TEST_TG_SINUS: | ||
79 | time_delta = GNUNET_TIME_absolute_get_duration (tg->time_start); | ||
80 | /* Calculate point of time in the current period */ | ||
81 | time_delta.rel_value_us = time_delta.rel_value_us | ||
82 | % tg->duration_period.rel_value_us; | ||
83 | if ((tg->max_rate - tg->base_rate) > tg->base_rate) | ||
84 | { | ||
85 | /* This will cause an underflow for second half of sinus period, | ||
86 | * will be detected in general when experiments are loaded */ | ||
87 | GNUNET_break (0); | ||
88 | } | ||
89 | delta_rate = (tg->max_rate - tg->base_rate) | ||
90 | * sin ((2 * M_PI) | ||
91 | / ((double) tg->duration_period.rel_value_us) | ||
92 | * time_delta.rel_value_us); | ||
93 | cur_rate = tg->base_rate + delta_rate; | ||
94 | break; | ||
95 | |||
96 | default: | ||
97 | return delay; | ||
98 | break; | ||
99 | } | ||
100 | |||
101 | if (cur_rate < 0) | ||
102 | { | ||
103 | cur_rate = 1; | ||
104 | } | ||
105 | /* Calculate the delay for the next message based on the current delay */ | ||
106 | delay.rel_value_us = GNUNET_TIME_UNIT_SECONDS.rel_value_us | ||
107 | * TEST_MESSAGE_SIZE / cur_rate; | ||
108 | |||
109 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
110 | "Current rate is %lld, calculated delay is %llu\n", | ||
111 | cur_rate, | ||
112 | (unsigned long long) delay.rel_value_us); | ||
113 | return delay; | ||
114 | } | ||
115 | |||
116 | |||
117 | static void | ||
118 | update_ping_data (void *cls) | ||
119 | { | ||
120 | struct BenchmarkPartner *p = cls; | ||
121 | struct GNUNET_TIME_Relative delay; | ||
122 | |||
123 | p->messages_sent++; | ||
124 | p->bytes_sent += TEST_MESSAGE_SIZE; | ||
125 | p->me->total_messages_sent++; | ||
126 | p->me->total_bytes_sent += TEST_MESSAGE_SIZE; | ||
127 | |||
128 | if (NULL == p->tg) | ||
129 | { | ||
130 | GNUNET_break (0); | ||
131 | return; | ||
132 | } | ||
133 | delay = get_delay (p->tg); | ||
134 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
135 | "Delay for next transmission %s\n", | ||
136 | GNUNET_STRINGS_relative_time_to_string (delay, | ||
137 | GNUNET_YES)); | ||
138 | p->tg->next_ping_transmission | ||
139 | = GNUNET_TIME_absolute_add (GNUNET_TIME_absolute_get (), | ||
140 | delay); | ||
141 | } | ||
142 | |||
143 | |||
144 | static void | ||
145 | comm_schedule_send (void *cls) | ||
146 | { | ||
147 | struct BenchmarkPartner *p = cls; | ||
148 | struct TestMessage *msg; | ||
149 | struct GNUNET_MQ_Envelope *env; | ||
150 | |||
151 | p->tg->send_task = NULL; | ||
152 | p->last_message_sent = GNUNET_TIME_absolute_get (); | ||
153 | env = GNUNET_MQ_msg (msg, | ||
154 | TEST_MESSAGE_TYPE_PING); | ||
155 | memset (msg->padding, | ||
156 | 'a', | ||
157 | sizeof(msg->padding)); | ||
158 | GNUNET_MQ_notify_sent (env, | ||
159 | &update_ping_data, | ||
160 | p); | ||
161 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
162 | "Master [%u]: Sending PING to [%u]\n", | ||
163 | p->me->no, | ||
164 | p->dest->no); | ||
165 | GNUNET_MQ_send (p->mq, | ||
166 | env); | ||
167 | } | ||
168 | |||
169 | |||
170 | static void | ||
171 | update_pong_data (void *cls) | ||
172 | { | ||
173 | struct BenchmarkPartner *p = cls; | ||
174 | |||
175 | p->messages_sent++; | ||
176 | p->bytes_sent += TEST_MESSAGE_SIZE; | ||
177 | p->me->total_messages_sent++; | ||
178 | p->me->total_bytes_sent += TEST_MESSAGE_SIZE; | ||
179 | } | ||
180 | |||
181 | |||
182 | void | ||
183 | GNUNET_ATS_TEST_traffic_handle_ping (struct BenchmarkPartner *p) | ||
184 | { | ||
185 | struct TestMessage *msg; | ||
186 | struct GNUNET_MQ_Envelope *env; | ||
187 | |||
188 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
189 | "Slave [%u]: Received PING from [%u], sending PONG\n", | ||
190 | p->me->no, | ||
191 | p->dest->no); | ||
192 | p->messages_received++; | ||
193 | p->bytes_received += TEST_MESSAGE_SIZE; | ||
194 | p->me->total_messages_received++; | ||
195 | p->me->total_bytes_received += TEST_MESSAGE_SIZE; | ||
196 | |||
197 | |||
198 | env = GNUNET_MQ_msg (msg, | ||
199 | TEST_MESSAGE_TYPE_PING); | ||
200 | memset (msg->padding, | ||
201 | 'a', | ||
202 | sizeof(msg->padding)); | ||
203 | GNUNET_MQ_notify_sent (env, | ||
204 | &update_pong_data, | ||
205 | p); | ||
206 | GNUNET_MQ_send (p->mq, | ||
207 | env); | ||
208 | } | ||
209 | |||
210 | |||
211 | void | ||
212 | GNUNET_ATS_TEST_traffic_handle_pong (struct BenchmarkPartner *p) | ||
213 | { | ||
214 | struct GNUNET_TIME_Relative left; | ||
215 | |||
216 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
217 | "Master [%u]: Received PONG from [%u], next message\n", | ||
218 | p->me->no, | ||
219 | p->dest->no); | ||
220 | |||
221 | p->messages_received++; | ||
222 | p->bytes_received += TEST_MESSAGE_SIZE; | ||
223 | p->me->total_messages_received++; | ||
224 | p->me->total_bytes_received += TEST_MESSAGE_SIZE; | ||
225 | p->total_app_rtt += GNUNET_TIME_absolute_get_difference (p->last_message_sent, | ||
226 | GNUNET_TIME_absolute_get ()) | ||
227 | .rel_value_us; | ||
228 | |||
229 | /* Schedule next send event */ | ||
230 | if (NULL == p->tg) | ||
231 | return; | ||
232 | |||
233 | left = GNUNET_TIME_absolute_get_remaining (p->tg->next_ping_transmission); | ||
234 | if (UINT32_MAX == p->tg->base_rate) | ||
235 | { | ||
236 | p->tg->send_task = GNUNET_SCHEDULER_add_now (&comm_schedule_send, p); | ||
237 | } | ||
238 | else if (0 == left.rel_value_us) | ||
239 | { | ||
240 | p->tg->send_task = GNUNET_SCHEDULER_add_now (&comm_schedule_send, p); | ||
241 | } | ||
242 | else | ||
243 | { | ||
244 | /* Enforce minimum transmission rate 1 msg / sec */ | ||
245 | if (GNUNET_TIME_UNIT_SECONDS.rel_value_us == (left = | ||
246 | GNUNET_TIME_relative_min ( | ||
247 | left, | ||
248 | GNUNET_TIME_UNIT_SECONDS)) | ||
249 | .rel_value_us) | ||
250 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
251 | "Enforcing minimum send rate between master [%u] and slave [%u]\n", | ||
252 | p->me->no, p->dest->no); | ||
253 | p->tg->send_task = GNUNET_SCHEDULER_add_delayed (left, | ||
254 | &comm_schedule_send, p); | ||
255 | } | ||
256 | } | ||
257 | |||
258 | |||
259 | /** | ||
260 | * Generate between the source master and the partner and send traffic with a | ||
261 | * maximum rate. | ||
262 | * | ||
263 | * @param src traffic source | ||
264 | * @param dest traffic partner | ||
265 | * @param type type of traffic to generate | ||
266 | * @param base_rate traffic base rate to send data with | ||
267 | * @param max_rate traffic maximum rate to send data with | ||
268 | * @param period duration of a period of traffic generation (~ 1/frequency) | ||
269 | * @param duration how long to generate traffic | ||
270 | * @return the traffic generator | ||
271 | */ | ||
272 | struct TrafficGenerator * | ||
273 | GNUNET_ATS_TEST_generate_traffic_start (struct BenchmarkPeer *src, | ||
274 | struct BenchmarkPartner *dest, | ||
275 | enum GeneratorType type, | ||
276 | unsigned int base_rate, | ||
277 | unsigned int max_rate, | ||
278 | struct GNUNET_TIME_Relative period, | ||
279 | struct GNUNET_TIME_Relative duration) | ||
280 | { | ||
281 | struct TrafficGenerator *tg; | ||
282 | |||
283 | if (NULL != dest->tg) | ||
284 | { | ||
285 | GNUNET_break (0); | ||
286 | return NULL; | ||
287 | } | ||
288 | |||
289 | tg = GNUNET_new (struct TrafficGenerator); | ||
290 | GNUNET_CONTAINER_DLL_insert (tg_head, | ||
291 | tg_tail, | ||
292 | tg); | ||
293 | tg->type = type; | ||
294 | tg->src = src; | ||
295 | tg->dest = dest; | ||
296 | tg->base_rate = base_rate; | ||
297 | tg->max_rate = max_rate; | ||
298 | tg->duration_period = period; | ||
299 | tg->time_start = GNUNET_TIME_absolute_get (); | ||
300 | tg->next_ping_transmission = GNUNET_TIME_UNIT_FOREVER_ABS; | ||
301 | |||
302 | switch (type) | ||
303 | { | ||
304 | case GNUNET_ATS_TEST_TG_CONSTANT: | ||
305 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
306 | "Setting up constant traffic generator master[%u] `%s' and slave [%u] `%s' max %u Bips\n", | ||
307 | dest->me->no, | ||
308 | GNUNET_i2s (&dest->me->id), | ||
309 | dest->dest->no, | ||
310 | GNUNET_i2s (&dest->dest->id), | ||
311 | base_rate); | ||
312 | break; | ||
313 | |||
314 | case GNUNET_ATS_TEST_TG_LINEAR: | ||
315 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
316 | "Setting up linear traffic generator master[%u] `%s' and slave [%u] `%s' min %u Bips max %u Bips\n", | ||
317 | dest->me->no, | ||
318 | GNUNET_i2s (&dest->me->id), | ||
319 | dest->dest->no, | ||
320 | GNUNET_i2s (&dest->dest->id), | ||
321 | base_rate, | ||
322 | max_rate); | ||
323 | break; | ||
324 | |||
325 | case GNUNET_ATS_TEST_TG_SINUS: | ||
326 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
327 | "Setting up sinus traffic generator master[%u] `%s' and slave [%u] `%s' baserate %u Bips, amplitude %u Bps\n", | ||
328 | dest->me->no, | ||
329 | GNUNET_i2s (&dest->me->id), | ||
330 | dest->dest->no, | ||
331 | GNUNET_i2s (&dest->dest->id), | ||
332 | base_rate, | ||
333 | max_rate); | ||
334 | break; | ||
335 | |||
336 | case GNUNET_ATS_TEST_TG_RANDOM: | ||
337 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
338 | "Setting up random traffic generator master[%u] `%s' and slave [%u] `%s' min %u Bips max %u Bps\n", | ||
339 | dest->me->no, | ||
340 | GNUNET_i2s (&dest->me->id), | ||
341 | dest->dest->no, | ||
342 | GNUNET_i2s (&dest->dest->id), | ||
343 | base_rate, | ||
344 | max_rate); | ||
345 | break; | ||
346 | |||
347 | default: | ||
348 | break; | ||
349 | } | ||
350 | |||
351 | dest->tg = tg; | ||
352 | tg->send_task | ||
353 | = GNUNET_SCHEDULER_add_now (&comm_schedule_send, | ||
354 | dest); | ||
355 | return tg; | ||
356 | } | ||
357 | |||
358 | |||
359 | void | ||
360 | GNUNET_ATS_TEST_generate_traffic_stop (struct TrafficGenerator *tg) | ||
361 | { | ||
362 | GNUNET_CONTAINER_DLL_remove (tg_head, | ||
363 | tg_tail, | ||
364 | tg); | ||
365 | tg->dest->tg = NULL; | ||
366 | if (NULL != tg->send_task) | ||
367 | { | ||
368 | GNUNET_SCHEDULER_cancel (tg->send_task); | ||
369 | tg->send_task = NULL; | ||
370 | } | ||
371 | GNUNET_free (tg); | ||
372 | } | ||
373 | |||
374 | |||
375 | /** | ||
376 | * Stop all traffic generators | ||
377 | */ | ||
378 | void | ||
379 | GNUNET_ATS_TEST_generate_traffic_stop_all () | ||
380 | { | ||
381 | struct TrafficGenerator *cur; | ||
382 | struct TrafficGenerator *next; | ||
383 | |||
384 | next = tg_head; | ||
385 | for (cur = next; NULL != cur; cur = next) | ||
386 | { | ||
387 | next = cur->next; | ||
388 | GNUNET_ATS_TEST_generate_traffic_stop (cur); | ||
389 | } | ||
390 | } | ||
391 | |||
392 | |||
393 | /* end of file ats-testing-traffic.c */ | ||
diff --git a/src/ats-tests/ats-testing.c b/src/ats-tests/ats-testing.c deleted file mode 100644 index c6ba8533d..000000000 --- a/src/ats-tests/ats-testing.c +++ /dev/null | |||
@@ -1,975 +0,0 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet. | ||
3 | Copyright (C) 2010-2013, 2016, 2017 GNUnet e.V. | ||
4 | |||
5 | GNUnet is free software: you can redistribute it and/or modify it | ||
6 | under the terms of the GNU Affero General Public License as published | ||
7 | by the Free Software Foundation, either version 3 of the License, | ||
8 | or (at your option) any later version. | ||
9 | |||
10 | GNUnet is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Affero General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Affero General Public License | ||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | ||
19 | */ | ||
20 | /** | ||
21 | * @file ats-tests/ats-testing.c | ||
22 | * @brief ats testing library: setup topology | ||
23 | * solvers | ||
24 | * @author Christian Grothoff | ||
25 | * @author Matthias Wachs | ||
26 | */ | ||
27 | #include "ats-testing.h" | ||
28 | |||
29 | |||
30 | /** | ||
31 | * Connect peers with testbed | ||
32 | */ | ||
33 | struct TestbedConnectOperation | ||
34 | { | ||
35 | /** | ||
36 | * The benchmarking master initiating this connection | ||
37 | */ | ||
38 | struct BenchmarkPeer *master; | ||
39 | |||
40 | /** | ||
41 | * The benchmarking slave to connect to | ||
42 | */ | ||
43 | struct BenchmarkPeer *slave; | ||
44 | |||
45 | /** | ||
46 | * Testbed operation to connect peers | ||
47 | */ | ||
48 | struct GNUNET_TESTBED_Operation *connect_op; | ||
49 | }; | ||
50 | |||
51 | struct GNUNET_CONFIGURATION_Handle *cfg; | ||
52 | |||
53 | struct GNUNET_ATS_TEST_Topology *top; | ||
54 | |||
55 | |||
56 | /** | ||
57 | * Shutdown nicely | ||
58 | * | ||
59 | * @param cls NULL | ||
60 | */ | ||
61 | static void | ||
62 | do_shutdown (void *cls) | ||
63 | { | ||
64 | int c_m; | ||
65 | int c_s; | ||
66 | int c_op; | ||
67 | struct BenchmarkPeer *p; | ||
68 | |||
69 | top->state.benchmarking = GNUNET_NO; | ||
70 | |||
71 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
72 | "Benchmarking done\n"); | ||
73 | |||
74 | GNUNET_ATS_TEST_generate_traffic_stop_all (); | ||
75 | |||
76 | for (c_m = 0; c_m < top->num_masters; c_m++) | ||
77 | { | ||
78 | p = &top->mps[c_m]; | ||
79 | if (NULL != top->mps[c_m].peer_id_op) | ||
80 | { | ||
81 | GNUNET_TESTBED_operation_done (p->peer_id_op); | ||
82 | p->peer_id_op = NULL; | ||
83 | } | ||
84 | |||
85 | if (NULL != p->ats_task) | ||
86 | GNUNET_SCHEDULER_cancel (p->ats_task); | ||
87 | p->ats_task = NULL; | ||
88 | |||
89 | for (c_op = 0; c_op < p->num_partners; c_op++) | ||
90 | { | ||
91 | if ((NULL != p->core_connect_ops) && | ||
92 | (NULL != p->core_connect_ops[c_op].connect_op)) | ||
93 | { | ||
94 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
95 | "Failed to connect peer 0 and %u\n", | ||
96 | c_op); | ||
97 | GNUNET_TESTBED_operation_done (p->core_connect_ops[c_op].connect_op); | ||
98 | p->core_connect_ops[c_op].connect_op = NULL; | ||
99 | } | ||
100 | } | ||
101 | |||
102 | if (NULL != p->ats_perf_op) | ||
103 | { | ||
104 | GNUNET_TESTBED_operation_done (p->ats_perf_op); | ||
105 | p->ats_perf_op = NULL; | ||
106 | } | ||
107 | |||
108 | if (NULL != p->comm_op) | ||
109 | { | ||
110 | GNUNET_TESTBED_operation_done (p->comm_op); | ||
111 | p->comm_op = NULL; | ||
112 | } | ||
113 | GNUNET_free (p->core_connect_ops); | ||
114 | GNUNET_free (p->partners); | ||
115 | p->partners = NULL; | ||
116 | } | ||
117 | |||
118 | for (c_s = 0; c_s < top->num_slaves; c_s++) | ||
119 | { | ||
120 | p = &top->sps[c_s]; | ||
121 | if (NULL != p->peer_id_op) | ||
122 | { | ||
123 | GNUNET_TESTBED_operation_done (p->peer_id_op); | ||
124 | p->peer_id_op = NULL; | ||
125 | } | ||
126 | if (NULL != p->ats_perf_op) | ||
127 | { | ||
128 | GNUNET_TESTBED_operation_done (p->ats_perf_op); | ||
129 | p->ats_perf_op = NULL; | ||
130 | } | ||
131 | if (NULL != p->comm_op) | ||
132 | { | ||
133 | GNUNET_TESTBED_operation_done (p->comm_op); | ||
134 | p->comm_op = NULL; | ||
135 | } | ||
136 | GNUNET_free (p->partners); | ||
137 | p->partners = NULL; | ||
138 | } | ||
139 | GNUNET_SCHEDULER_shutdown (); | ||
140 | GNUNET_free (top); | ||
141 | top = NULL; | ||
142 | } | ||
143 | |||
144 | |||
145 | static struct BenchmarkPartner * | ||
146 | find_partner (struct BenchmarkPeer *me, | ||
147 | const struct GNUNET_PeerIdentity *peer) | ||
148 | { | ||
149 | int c_m; | ||
150 | |||
151 | for (c_m = 0; c_m < me->num_partners; c_m++) | ||
152 | { | ||
153 | /* Find a partner with other as destination */ | ||
154 | if (0 == GNUNET_memcmp (peer, | ||
155 | &me->partners[c_m].dest->id)) | ||
156 | { | ||
157 | return &me->partners[c_m]; | ||
158 | } | ||
159 | } | ||
160 | |||
161 | return NULL; | ||
162 | } | ||
163 | |||
164 | |||
165 | static struct BenchmarkPeer * | ||
166 | find_peer (const struct GNUNET_PeerIdentity *peer) | ||
167 | { | ||
168 | int c_p; | ||
169 | |||
170 | for (c_p = 0; c_p < top->num_masters; c_p++) | ||
171 | { | ||
172 | if (0 == GNUNET_memcmp (&top->mps[c_p].id, | ||
173 | peer)) | ||
174 | return &top->mps[c_p]; | ||
175 | } | ||
176 | |||
177 | for (c_p = 0; c_p < top->num_slaves; c_p++) | ||
178 | { | ||
179 | if (0 == GNUNET_memcmp (&top->sps[c_p].id, | ||
180 | peer)) | ||
181 | return &top->sps[c_p]; | ||
182 | } | ||
183 | return NULL; | ||
184 | } | ||
185 | |||
186 | |||
187 | /** | ||
188 | * Method called whenever a given peer connects. | ||
189 | * | ||
190 | * @param cls closure | ||
191 | * @param peer peer identity this notification is about | ||
192 | * @param mq queue to use to send messages to @a peer | ||
193 | * @return the `struct BenchmarkPartner` of @a peer | ||
194 | */ | ||
195 | static void * | ||
196 | comm_connect_cb (void *cls, | ||
197 | const struct GNUNET_PeerIdentity *peer, | ||
198 | struct GNUNET_MQ_Handle *mq) | ||
199 | { | ||
200 | struct BenchmarkPeer *me = cls; | ||
201 | struct BenchmarkPeer *remote; | ||
202 | struct BenchmarkPartner *p; | ||
203 | char *id; | ||
204 | int c; | ||
205 | int completed; | ||
206 | |||
207 | remote = find_peer (peer); | ||
208 | if (NULL == remote) | ||
209 | { | ||
210 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
211 | "Unknown peer connected: `%s'\n", | ||
212 | GNUNET_i2s (peer)); | ||
213 | GNUNET_break (0); | ||
214 | return NULL; | ||
215 | } | ||
216 | |||
217 | id = GNUNET_strdup (GNUNET_i2s (&me->id)); | ||
218 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
219 | "%s [%u] `%s' connected to %s [%u] %s\n", | ||
220 | (me->master == GNUNET_YES) ? "Master" : "Slave", | ||
221 | me->no, | ||
222 | id, | ||
223 | (remote->master == GNUNET_YES) ? "Master" : "Slave", | ||
224 | remote->no, | ||
225 | GNUNET_i2s (peer)); | ||
226 | |||
227 | me->core_connections++; | ||
228 | if ((GNUNET_YES == me->master) && | ||
229 | (GNUNET_NO == remote->master) && | ||
230 | (GNUNET_NO == top->state.connected_CORE)) | ||
231 | { | ||
232 | me->core_slave_connections++; | ||
233 | |||
234 | if (me->core_slave_connections == top->num_slaves) | ||
235 | { | ||
236 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
237 | "Master [%u] connected all slaves\n", | ||
238 | me->no); | ||
239 | } | ||
240 | completed = GNUNET_YES; | ||
241 | for (c = 0; c < top->num_masters; c++) | ||
242 | { | ||
243 | if (top->mps[c].core_slave_connections != top->num_slaves) | ||
244 | completed = GNUNET_NO; | ||
245 | } | ||
246 | if (GNUNET_YES == completed) | ||
247 | { | ||
248 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
249 | "All master peers connected all slave peers\n"); | ||
250 | top->state.connected_CORE = GNUNET_YES; | ||
251 | /* Notify about setup done */ | ||
252 | if (NULL != top->done_cb) | ||
253 | top->done_cb (top->done_cb_cls, | ||
254 | top->mps, | ||
255 | top->sps); | ||
256 | } | ||
257 | } | ||
258 | GNUNET_free (id); | ||
259 | p = find_partner (me, | ||
260 | peer); | ||
261 | if (NULL != p) | ||
262 | p->mq = mq; | ||
263 | return p; | ||
264 | } | ||
265 | |||
266 | |||
267 | /** | ||
268 | * @param cls this peer | ||
269 | * @param peer id of disconnecting peer | ||
270 | * @param internal_cls the `struct BenchmarkPartner` of @a peer | ||
271 | */ | ||
272 | static void | ||
273 | comm_disconnect_cb (void *cls, | ||
274 | const struct GNUNET_PeerIdentity *peer, | ||
275 | void *internal_cls) | ||
276 | { | ||
277 | struct BenchmarkPeer *me = cls; | ||
278 | struct BenchmarkPartner *p = internal_cls; | ||
279 | char *id; | ||
280 | |||
281 | if (NULL == p) | ||
282 | return; | ||
283 | |||
284 | id = GNUNET_strdup (GNUNET_i2s (&me->id)); | ||
285 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
286 | "%s disconnected from %s\n", | ||
287 | id, | ||
288 | GNUNET_i2s (peer)); | ||
289 | GNUNET_assert (me->core_connections > 0); | ||
290 | me->core_connections--; | ||
291 | |||
292 | if ((GNUNET_YES == top->state.benchmarking) && | ||
293 | ((GNUNET_YES == me->master) || | ||
294 | (GNUNET_YES == p->dest->master))) | ||
295 | { | ||
296 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
297 | "%s disconnected from %s while benchmarking\n", | ||
298 | id, | ||
299 | GNUNET_i2s (peer)); | ||
300 | } | ||
301 | GNUNET_free (id); | ||
302 | } | ||
303 | |||
304 | |||
305 | static void | ||
306 | handle_pong (void *cls, | ||
307 | const struct TestMessage *message) | ||
308 | { | ||
309 | struct BenchmarkPartner *p = cls; | ||
310 | |||
311 | GNUNET_ATS_TEST_traffic_handle_pong (p); | ||
312 | } | ||
313 | |||
314 | |||
315 | static void | ||
316 | handle_ping (void *cls, | ||
317 | const struct TestMessage *message) | ||
318 | { | ||
319 | struct BenchmarkPartner *p = cls; | ||
320 | |||
321 | GNUNET_ATS_TEST_traffic_handle_ping (p); | ||
322 | } | ||
323 | |||
324 | |||
325 | static void * | ||
326 | transport_connect_adapter (void *cls, | ||
327 | const struct GNUNET_CONFIGURATION_Handle *cfg) | ||
328 | { | ||
329 | struct BenchmarkPeer *me = cls; | ||
330 | struct GNUNET_MQ_MessageHandler handlers[] = { | ||
331 | GNUNET_MQ_hd_fixed_size (ping, | ||
332 | TEST_MESSAGE_TYPE_PING, | ||
333 | struct TestMessage, | ||
334 | me), | ||
335 | GNUNET_MQ_hd_fixed_size (pong, | ||
336 | TEST_MESSAGE_TYPE_PONG, | ||
337 | struct TestMessage, | ||
338 | me), | ||
339 | GNUNET_MQ_handler_end () | ||
340 | }; | ||
341 | |||
342 | me->th = GNUNET_TRANSPORT_core_connect (cfg, | ||
343 | &me->id, | ||
344 | handlers, | ||
345 | me, | ||
346 | &comm_connect_cb, | ||
347 | &comm_disconnect_cb, | ||
348 | NULL); | ||
349 | if (NULL == me->th) | ||
350 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
351 | "Failed to create transport connection \n"); | ||
352 | return me->th; | ||
353 | } | ||
354 | |||
355 | |||
356 | static void | ||
357 | transport_disconnect_adapter (void *cls, | ||
358 | void *op_result) | ||
359 | { | ||
360 | struct BenchmarkPeer *me = cls; | ||
361 | |||
362 | GNUNET_TRANSPORT_core_disconnect (me->th); | ||
363 | me->th = NULL; | ||
364 | } | ||
365 | |||
366 | |||
367 | static void * | ||
368 | core_connect_adapter (void *cls, | ||
369 | const struct GNUNET_CONFIGURATION_Handle *cfg) | ||
370 | { | ||
371 | struct BenchmarkPeer *me = cls; | ||
372 | struct GNUNET_MQ_MessageHandler handlers[] = { | ||
373 | GNUNET_MQ_hd_fixed_size (ping, | ||
374 | TEST_MESSAGE_TYPE_PING, | ||
375 | struct TestMessage, | ||
376 | me), | ||
377 | GNUNET_MQ_hd_fixed_size (pong, | ||
378 | TEST_MESSAGE_TYPE_PONG, | ||
379 | struct TestMessage, | ||
380 | me), | ||
381 | GNUNET_MQ_handler_end () | ||
382 | }; | ||
383 | |||
384 | me->ch = GNUNET_CORE_connect (cfg, | ||
385 | me, | ||
386 | NULL, | ||
387 | &comm_connect_cb, | ||
388 | &comm_disconnect_cb, | ||
389 | handlers); | ||
390 | if (NULL == me->ch) | ||
391 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
392 | "Failed to create core connection \n"); | ||
393 | return me->ch; | ||
394 | } | ||
395 | |||
396 | |||
397 | static void | ||
398 | core_disconnect_adapter (void *cls, | ||
399 | void *op_result) | ||
400 | { | ||
401 | struct BenchmarkPeer *me = cls; | ||
402 | |||
403 | GNUNET_CORE_disconnect (me->ch); | ||
404 | me->ch = NULL; | ||
405 | } | ||
406 | |||
407 | |||
408 | static void | ||
409 | connect_completion_callback (void *cls, | ||
410 | struct GNUNET_TESTBED_Operation *op, | ||
411 | const char *emsg) | ||
412 | { | ||
413 | struct TestbedConnectOperation *cop = cls; | ||
414 | static int ops = 0; | ||
415 | int c; | ||
416 | |||
417 | if (NULL == emsg) | ||
418 | { | ||
419 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
420 | _ ("Connected master [%u] with slave [%u]\n"), | ||
421 | cop->master->no, | ||
422 | cop->slave->no); | ||
423 | } | ||
424 | else | ||
425 | { | ||
426 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
427 | _ ("Failed to connect master peer [%u] with slave [%u]\n"), | ||
428 | cop->master->no, cop->slave->no); | ||
429 | GNUNET_break (0); | ||
430 | GNUNET_SCHEDULER_shutdown (); | ||
431 | } | ||
432 | GNUNET_TESTBED_operation_done (op); | ||
433 | ops++; | ||
434 | for (c = 0; c < top->num_slaves; c++) | ||
435 | { | ||
436 | if (cop == &cop->master->core_connect_ops[c]) | ||
437 | cop->master->core_connect_ops[c].connect_op = NULL; | ||
438 | } | ||
439 | if (ops == top->num_masters * top->num_slaves) | ||
440 | { | ||
441 | top->state.connected_PEERS = GNUNET_YES; | ||
442 | } | ||
443 | } | ||
444 | |||
445 | |||
446 | static void | ||
447 | do_connect_peers (void *cls) | ||
448 | { | ||
449 | int c_m; | ||
450 | int c_s; | ||
451 | struct BenchmarkPeer *p; | ||
452 | |||
453 | if ((top->state.connected_ATS_service == GNUNET_NO) || | ||
454 | (top->state.connected_COMM_service == GNUNET_NO)) | ||
455 | return; | ||
456 | |||
457 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
458 | "Connecting peers on CORE level\n"); | ||
459 | for (c_m = 0; c_m < top->num_masters; c_m++) | ||
460 | { | ||
461 | p = &top->mps[c_m]; | ||
462 | p->core_connect_ops = GNUNET_malloc (top->num_slaves | ||
463 | * sizeof(struct | ||
464 | TestbedConnectOperation)); | ||
465 | |||
466 | for (c_s = 0; c_s < top->num_slaves; c_s++) | ||
467 | { | ||
468 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
469 | "Connecting master [%u] with slave [%u]\n", | ||
470 | p->no, | ||
471 | top->sps[c_s].no); | ||
472 | p->core_connect_ops[c_s].master = p; | ||
473 | p->core_connect_ops[c_s].slave = &top->sps[c_s]; | ||
474 | p->core_connect_ops[c_s].connect_op | ||
475 | = GNUNET_TESTBED_overlay_connect (NULL, | ||
476 | &connect_completion_callback, | ||
477 | &p->core_connect_ops[c_s], | ||
478 | top->sps[c_s].peer, | ||
479 | p->peer); | ||
480 | if (NULL == p->core_connect_ops[c_s].connect_op) | ||
481 | { | ||
482 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
483 | "Could not connect master [%u] and slave [%u]\n", | ||
484 | p->no, | ||
485 | top->sps[c_s].no); | ||
486 | GNUNET_break (0); | ||
487 | GNUNET_SCHEDULER_shutdown (); | ||
488 | return; | ||
489 | } | ||
490 | } | ||
491 | } | ||
492 | } | ||
493 | |||
494 | |||
495 | static void | ||
496 | comm_connect_completion_cb (void *cls, | ||
497 | struct GNUNET_TESTBED_Operation *op, | ||
498 | void *ca_result, | ||
499 | const char *emsg) | ||
500 | { | ||
501 | static int comm_done = 0; | ||
502 | |||
503 | if ((NULL != emsg) || (NULL == ca_result)) | ||
504 | { | ||
505 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
506 | "Initialization failed, shutdown\n"); | ||
507 | GNUNET_break (0); | ||
508 | GNUNET_SCHEDULER_shutdown (); | ||
509 | return; | ||
510 | } | ||
511 | comm_done++; | ||
512 | |||
513 | if (comm_done == top->num_slaves + top->num_masters) | ||
514 | { | ||
515 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
516 | "Connected to all %s services\n", | ||
517 | (GNUNET_YES == top->test_core) ? "CORE" : "TRANSPORT"); | ||
518 | top->state.connected_COMM_service = GNUNET_YES; | ||
519 | GNUNET_SCHEDULER_add_now (&do_connect_peers, | ||
520 | NULL); | ||
521 | } | ||
522 | } | ||
523 | |||
524 | |||
525 | static void | ||
526 | do_comm_connect (void *cls) | ||
527 | { | ||
528 | int c_s; | ||
529 | int c_m; | ||
530 | |||
531 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
532 | "Connecting to all %s services\n", | ||
533 | (GNUNET_YES == top->test_core) ? "CORE" : "TRANSPORT"); | ||
534 | for (c_m = 0; c_m < top->num_masters; c_m++) | ||
535 | { | ||
536 | if (GNUNET_YES == top->test_core) | ||
537 | top->mps[c_m].comm_op | ||
538 | = GNUNET_TESTBED_service_connect (NULL, | ||
539 | top->mps[c_m].peer, | ||
540 | "core", | ||
541 | &comm_connect_completion_cb, | ||
542 | NULL, | ||
543 | &core_connect_adapter, | ||
544 | &core_disconnect_adapter, | ||
545 | &top->mps[c_m]); | ||
546 | else | ||
547 | { | ||
548 | top->mps[c_m].comm_op | ||
549 | = GNUNET_TESTBED_service_connect (NULL, | ||
550 | top->mps[c_m].peer, | ||
551 | "transport", | ||
552 | &comm_connect_completion_cb, | ||
553 | NULL, | ||
554 | &transport_connect_adapter, | ||
555 | &transport_disconnect_adapter, | ||
556 | &top->mps[c_m]); | ||
557 | } | ||
558 | } | ||
559 | |||
560 | for (c_s = 0; c_s < top->num_slaves; c_s++) | ||
561 | { | ||
562 | if (GNUNET_YES == top->test_core) | ||
563 | top->sps[c_s].comm_op | ||
564 | = GNUNET_TESTBED_service_connect (NULL, | ||
565 | top->sps[c_s].peer, | ||
566 | "core", | ||
567 | &comm_connect_completion_cb, | ||
568 | NULL, | ||
569 | &core_connect_adapter, | ||
570 | &core_disconnect_adapter, | ||
571 | &top->sps[c_s]); | ||
572 | else | ||
573 | { | ||
574 | top->sps[c_s].comm_op | ||
575 | = GNUNET_TESTBED_service_connect (NULL, | ||
576 | top->sps[c_s].peer, | ||
577 | "transport", | ||
578 | &comm_connect_completion_cb, | ||
579 | NULL, | ||
580 | &transport_connect_adapter, | ||
581 | &transport_disconnect_adapter, | ||
582 | &top->sps[c_s]); | ||
583 | } | ||
584 | } | ||
585 | } | ||
586 | |||
587 | |||
588 | static void | ||
589 | ats_performance_info_cb (void *cls, | ||
590 | const struct GNUNET_HELLO_Address *address, | ||
591 | int address_active, | ||
592 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, | ||
593 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, | ||
594 | const struct GNUNET_ATS_Properties *ats_prop) | ||
595 | { | ||
596 | struct BenchmarkPeer *me = cls; | ||
597 | struct BenchmarkPartner *p; | ||
598 | int log; | ||
599 | char *peer_id; | ||
600 | |||
601 | if (NULL == address) | ||
602 | { | ||
603 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
604 | "Peer %u: ATS Service disconnected!\n", | ||
605 | me->no); | ||
606 | return; | ||
607 | } | ||
608 | |||
609 | p = find_partner (me, | ||
610 | &address->peer); | ||
611 | if (NULL == p) | ||
612 | { | ||
613 | /* This is not one of my partners | ||
614 | * Will happen since the peers will connect to each other due to gossiping | ||
615 | */ | ||
616 | return; | ||
617 | } | ||
618 | peer_id = GNUNET_strdup (GNUNET_i2s (&me->id)); | ||
619 | |||
620 | log = GNUNET_NO; | ||
621 | if ((p->bandwidth_in != ntohl (bandwidth_in.value__)) || | ||
622 | (p->bandwidth_out != ntohl (bandwidth_out.value__))) | ||
623 | log = GNUNET_YES; | ||
624 | p->bandwidth_in = ntohl (bandwidth_in.value__); | ||
625 | p->bandwidth_out = ntohl (bandwidth_out.value__); | ||
626 | |||
627 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
628 | "%s [%u] received ATS information: %s\n", | ||
629 | (GNUNET_YES == p->me->master) ? "Master" : "Slave", | ||
630 | p->me->no, | ||
631 | GNUNET_i2s (&p->dest->id)); | ||
632 | |||
633 | p->props.utilization_out = ats_prop->utilization_out; | ||
634 | p->props.utilization_in = ats_prop->utilization_in; | ||
635 | p->props.scope = ats_prop->scope; | ||
636 | p->props.delay = ats_prop->delay; | ||
637 | p->props.distance = ats_prop->distance; | ||
638 | |||
639 | if (GNUNET_YES == log) | ||
640 | top->ats_perf_cb (cls, address, | ||
641 | address_active, | ||
642 | bandwidth_out, | ||
643 | bandwidth_in, | ||
644 | ats_prop); | ||
645 | GNUNET_free (peer_id); | ||
646 | } | ||
647 | |||
648 | |||
649 | static void * | ||
650 | ats_perf_connect_adapter (void *cls, | ||
651 | const struct GNUNET_CONFIGURATION_Handle *cfg) | ||
652 | { | ||
653 | struct BenchmarkPeer *me = cls; | ||
654 | |||
655 | me->ats_perf_handle | ||
656 | = GNUNET_ATS_performance_init (cfg, | ||
657 | &ats_performance_info_cb, | ||
658 | me); | ||
659 | if (NULL == me->ats_perf_handle) | ||
660 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
661 | "Failed to create ATS performance handle \n"); | ||
662 | return me->ats_perf_handle; | ||
663 | } | ||
664 | |||
665 | |||
666 | static void | ||
667 | ats_perf_disconnect_adapter (void *cls, | ||
668 | void *op_result) | ||
669 | { | ||
670 | struct BenchmarkPeer *me = cls; | ||
671 | |||
672 | GNUNET_ATS_performance_done (me->ats_perf_handle); | ||
673 | me->ats_perf_handle = NULL; | ||
674 | } | ||
675 | |||
676 | |||
677 | static void | ||
678 | ats_connect_completion_cb (void *cls, | ||
679 | struct GNUNET_TESTBED_Operation *op, | ||
680 | void *ca_result, | ||
681 | const char *emsg) | ||
682 | { | ||
683 | static int op_done = 0; | ||
684 | |||
685 | if ((NULL != emsg) || (NULL == ca_result)) | ||
686 | { | ||
687 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
688 | "Initialization failed, shutdown\n"); | ||
689 | GNUNET_break (0); | ||
690 | GNUNET_SCHEDULER_shutdown (); | ||
691 | return; | ||
692 | } | ||
693 | op_done++; | ||
694 | if (op_done == (top->num_masters + top->num_slaves)) | ||
695 | { | ||
696 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
697 | "Connected to all ATS services\n"); | ||
698 | top->state.connected_ATS_service = GNUNET_YES; | ||
699 | GNUNET_SCHEDULER_add_now (&do_comm_connect, | ||
700 | NULL); | ||
701 | } | ||
702 | } | ||
703 | |||
704 | |||
705 | static void | ||
706 | do_connect_ats (void *cls) | ||
707 | { | ||
708 | int c_m; | ||
709 | int c_s; | ||
710 | |||
711 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
712 | "Connecting to all ATS services\n"); | ||
713 | for (c_m = 0; c_m < top->num_masters; c_m++) | ||
714 | { | ||
715 | top->mps[c_m].ats_perf_op | ||
716 | = GNUNET_TESTBED_service_connect (NULL, | ||
717 | top->mps[c_m].peer, | ||
718 | "ats", | ||
719 | &ats_connect_completion_cb, | ||
720 | NULL, | ||
721 | &ats_perf_connect_adapter, | ||
722 | &ats_perf_disconnect_adapter, | ||
723 | &top->mps[c_m]); | ||
724 | } | ||
725 | |||
726 | for (c_s = 0; c_s < top->num_slaves; c_s++) | ||
727 | { | ||
728 | top->sps[c_s].ats_perf_op | ||
729 | = GNUNET_TESTBED_service_connect (NULL, | ||
730 | top->sps[c_s].peer, | ||
731 | "ats", | ||
732 | &ats_connect_completion_cb, | ||
733 | NULL, | ||
734 | &ats_perf_connect_adapter, | ||
735 | &ats_perf_disconnect_adapter, | ||
736 | &top->sps[c_s]); | ||
737 | } | ||
738 | } | ||
739 | |||
740 | |||
741 | static void | ||
742 | peerinformation_cb (void *cb_cls, | ||
743 | struct GNUNET_TESTBED_Operation *op, | ||
744 | const struct GNUNET_TESTBED_PeerInformation *pinfo, | ||
745 | const char *emsg) | ||
746 | { | ||
747 | struct BenchmarkPeer *p = cb_cls; | ||
748 | static int done = 0; | ||
749 | |||
750 | GNUNET_assert (pinfo->pit == GNUNET_TESTBED_PIT_IDENTITY); | ||
751 | |||
752 | p->id = *pinfo->result.id; | ||
753 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
754 | "%s [%u] has peer id `%s'\n", | ||
755 | (p->master == GNUNET_YES) ? "Master" : "Slave", | ||
756 | p->no, | ||
757 | GNUNET_i2s (&p->id)); | ||
758 | |||
759 | GNUNET_TESTBED_operation_done (op); | ||
760 | p->peer_id_op = NULL; | ||
761 | done++; | ||
762 | |||
763 | if (done == top->num_slaves + top->num_masters) | ||
764 | { | ||
765 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
766 | "Retrieved all peer ID, connect to ATS\n"); | ||
767 | GNUNET_SCHEDULER_add_now (&do_connect_ats, | ||
768 | NULL); | ||
769 | } | ||
770 | } | ||
771 | |||
772 | |||
773 | /** | ||
774 | * Signature of a main function for a testcase. | ||
775 | * | ||
776 | * @param cls closure | ||
777 | * @param h testbed handle | ||
778 | * @param num_peers number of peers in 'peers' | ||
779 | * @param peers_ handle to peers run in the testbed | ||
780 | * @param links_succeeded the number of overlay link connection attempts that | ||
781 | * succeeded | ||
782 | * @param links_failed the number of overlay link connection attempts that | ||
783 | * failed | ||
784 | */ | ||
785 | static void | ||
786 | main_run (void *cls, | ||
787 | struct GNUNET_TESTBED_RunHandle *h, | ||
788 | unsigned int num_peers, | ||
789 | struct GNUNET_TESTBED_Peer **peers_, | ||
790 | unsigned int links_succeeded, | ||
791 | unsigned int links_failed) | ||
792 | { | ||
793 | int c_m; | ||
794 | int c_s; | ||
795 | |||
796 | GNUNET_assert (NULL == cls); | ||
797 | GNUNET_assert (top->num_masters + top->num_slaves == num_peers); | ||
798 | GNUNET_assert (NULL != peers_); | ||
799 | |||
800 | GNUNET_SCHEDULER_add_shutdown (&do_shutdown, | ||
801 | top); | ||
802 | |||
803 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
804 | "Setting up %u masters and %u slaves\n", | ||
805 | top->num_masters, | ||
806 | top->num_slaves); | ||
807 | |||
808 | /* Setup master peers */ | ||
809 | for (c_m = 0; c_m < top->num_masters; c_m++) | ||
810 | { | ||
811 | GNUNET_assert (NULL != peers_[c_m]); | ||
812 | top->mps[c_m].peer = peers_[c_m]; | ||
813 | top->mps[c_m].no = c_m; | ||
814 | top->mps[c_m].master = GNUNET_YES; | ||
815 | top->mps[c_m].pref_partner = &top->sps[c_m]; | ||
816 | top->mps[c_m].pref_value = TEST_ATS_PREFERENCE_DEFAULT; | ||
817 | top->mps[c_m].partners = | ||
818 | GNUNET_malloc (top->num_slaves * sizeof(struct BenchmarkPartner)); | ||
819 | top->mps[c_m].num_partners = top->num_slaves; | ||
820 | /* Initialize partners */ | ||
821 | for (c_s = 0; c_s < top->num_slaves; c_s++) | ||
822 | { | ||
823 | top->mps[c_m].partners[c_s].me = &top->mps[c_m]; | ||
824 | top->mps[c_m].partners[c_s].dest = &top->sps[c_s]; | ||
825 | } | ||
826 | /* Get configuration */ | ||
827 | top->mps[c_m].peer_id_op | ||
828 | = GNUNET_TESTBED_peer_get_information (top->mps[c_m].peer, | ||
829 | GNUNET_TESTBED_PIT_IDENTITY, | ||
830 | &peerinformation_cb, | ||
831 | &top->mps[c_m]); | ||
832 | } | ||
833 | |||
834 | /* Setup slave peers */ | ||
835 | for (c_s = 0; c_s < top->num_slaves; c_s++) | ||
836 | { | ||
837 | GNUNET_assert (NULL != peers_[c_s + top->num_masters]); | ||
838 | top->sps[c_s].peer = peers_[c_s + top->num_masters]; | ||
839 | top->sps[c_s].no = c_s + top->num_masters; | ||
840 | top->sps[c_s].master = GNUNET_NO; | ||
841 | top->sps[c_s].partners = | ||
842 | GNUNET_new_array (top->num_masters, | ||
843 | struct BenchmarkPartner); | ||
844 | top->sps[c_s].num_partners = top->num_masters; | ||
845 | /* Initialize partners */ | ||
846 | for (c_m = 0; c_m < top->num_masters; c_m++) | ||
847 | { | ||
848 | top->sps[c_s].partners[c_m].me = &top->sps[c_s]; | ||
849 | top->sps[c_s].partners[c_m].dest = &top->mps[c_m]; | ||
850 | |||
851 | /* Initialize properties */ | ||
852 | top->sps[c_s].partners[c_m].props.delay = GNUNET_TIME_UNIT_ZERO; | ||
853 | top->sps[c_s].partners[c_m].props.distance = 0; | ||
854 | top->sps[c_s].partners[c_m].props.scope = GNUNET_NT_UNSPECIFIED; | ||
855 | top->sps[c_s].partners[c_m].props.utilization_in = 0; | ||
856 | top->sps[c_s].partners[c_m].props.utilization_out = 0; | ||
857 | } | ||
858 | /* Get configuration */ | ||
859 | top->sps[c_s].peer_id_op | ||
860 | = GNUNET_TESTBED_peer_get_information (top->sps[c_s].peer, | ||
861 | GNUNET_TESTBED_PIT_IDENTITY, | ||
862 | &peerinformation_cb, | ||
863 | &top->sps[c_s]); | ||
864 | } | ||
865 | } | ||
866 | |||
867 | |||
868 | /** | ||
869 | * Controller event callback | ||
870 | * | ||
871 | * @param cls NULL | ||
872 | * @param event the controller event | ||
873 | */ | ||
874 | static void | ||
875 | controller_event_cb (void *cls, | ||
876 | const struct GNUNET_TESTBED_EventInformation *event) | ||
877 | { | ||
878 | switch (event->type) | ||
879 | { | ||
880 | case GNUNET_TESTBED_ET_CONNECT: | ||
881 | break; | ||
882 | |||
883 | case GNUNET_TESTBED_ET_OPERATION_FINISHED: | ||
884 | break; | ||
885 | |||
886 | default: | ||
887 | GNUNET_break (0); | ||
888 | GNUNET_SCHEDULER_shutdown (); | ||
889 | } | ||
890 | } | ||
891 | |||
892 | |||
893 | struct BenchmarkPeer * | ||
894 | GNUNET_ATS_TEST_get_peer (int src) | ||
895 | { | ||
896 | if (src > top->num_masters) | ||
897 | return NULL; | ||
898 | return &top->mps[src]; | ||
899 | } | ||
900 | |||
901 | |||
902 | struct BenchmarkPartner * | ||
903 | GNUNET_ATS_TEST_get_partner (int src, | ||
904 | int dest) | ||
905 | { | ||
906 | if (src > top->num_masters) | ||
907 | return NULL; | ||
908 | if (dest > top->num_slaves) | ||
909 | return NULL; | ||
910 | return &top->mps[src].partners[dest]; | ||
911 | } | ||
912 | |||
913 | |||
914 | /** | ||
915 | * Create a topology for ats testing | ||
916 | * | ||
917 | * @param name test name | ||
918 | * @param cfg_file configuration file to use for the peers | ||
919 | * @param num_slaves number of slaves | ||
920 | * @param num_masters number of masters | ||
921 | * @param test_core connect to CORE service (GNUNET_YES) or transport (GNUNET_NO) | ||
922 | * @param done_cb function to call when topology is setup | ||
923 | * @param done_cb_cls cls for callback | ||
924 | * @param log_request_cb callback to call when logging is required | ||
925 | */ | ||
926 | void | ||
927 | GNUNET_ATS_TEST_create_topology (char *name, char *cfg_file, | ||
928 | unsigned int num_slaves, | ||
929 | unsigned int num_masters, | ||
930 | int test_core, | ||
931 | GNUNET_ATS_TEST_TopologySetupDoneCallback | ||
932 | done_cb, | ||
933 | void *done_cb_cls, | ||
934 | GNUNET_ATS_AddressInformationCallback | ||
935 | log_request_cb) | ||
936 | { | ||
937 | top = GNUNET_new (struct GNUNET_ATS_TEST_Topology); | ||
938 | top->num_masters = num_masters; | ||
939 | top->num_slaves = num_slaves; | ||
940 | top->done_cb = done_cb; | ||
941 | top->done_cb_cls = done_cb_cls; | ||
942 | top->test_core = test_core; | ||
943 | top->ats_perf_cb = log_request_cb; | ||
944 | top->mps = GNUNET_new_array (num_masters, | ||
945 | struct BenchmarkPeer); | ||
946 | top->sps = GNUNET_new_array (num_slaves, | ||
947 | struct BenchmarkPeer); | ||
948 | |||
949 | /* Start topology */ | ||
950 | uint64_t event_mask; | ||
951 | event_mask = 0; | ||
952 | event_mask |= (1LL << GNUNET_TESTBED_ET_CONNECT); | ||
953 | event_mask |= (1LL << GNUNET_TESTBED_ET_OPERATION_FINISHED); | ||
954 | (void) GNUNET_TESTBED_test_run (name, | ||
955 | cfg_file, | ||
956 | num_slaves + num_masters, | ||
957 | event_mask, | ||
958 | &controller_event_cb, NULL, | ||
959 | &main_run, NULL); | ||
960 | } | ||
961 | |||
962 | |||
963 | /** | ||
964 | * Shutdown topology | ||
965 | */ | ||
966 | void | ||
967 | GNUNET_ATS_TEST_shutdown_topology (void) | ||
968 | { | ||
969 | if (NULL == top) | ||
970 | return; | ||
971 | GNUNET_SCHEDULER_shutdown (); | ||
972 | } | ||
973 | |||
974 | |||
975 | /* end of file ats-testing.c */ | ||
diff --git a/src/ats-tests/ats-testing.h b/src/ats-tests/ats-testing.h deleted file mode 100644 index 017ffef4f..000000000 --- a/src/ats-tests/ats-testing.h +++ /dev/null | |||
@@ -1,757 +0,0 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet. | ||
3 | Copyright (C) 2010-2013 GNUnet e.V. | ||
4 | |||
5 | GNUnet is free software: you can redistribute it and/or modify it | ||
6 | under the terms of the GNU Affero General Public License as published | ||
7 | by the Free Software Foundation, either version 3 of the License, | ||
8 | or (at your option) any later version. | ||
9 | |||
10 | GNUnet is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Affero General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Affero General Public License | ||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | ||
19 | */ | ||
20 | /** | ||
21 | * @file ats-tests/ats-testing.h | ||
22 | * @brief ats testing library: setup topology and provide logging to test ats | ||
23 | * @author Christian Grothoff | ||
24 | * @author Matthias Wachs | ||
25 | */ | ||
26 | #include "platform.h" | ||
27 | #include "gnunet_util_lib.h" | ||
28 | #include "gnunet_testbed_service.h" | ||
29 | #include "gnunet_ats_service.h" | ||
30 | #include "gnunet_core_service.h" | ||
31 | #include "gnunet_transport_service.h" | ||
32 | |||
33 | #define TEST_ATS_PREFERENCE_DEFAULT 1.0 | ||
34 | |||
35 | /** | ||
36 | * Message type sent for traffic generation | ||
37 | */ | ||
38 | #define TEST_MESSAGE_TYPE_PING 12345 | ||
39 | |||
40 | /** | ||
41 | * Message type sent as response during traffic generation | ||
42 | */ | ||
43 | #define TEST_MESSAGE_TYPE_PONG 12346 | ||
44 | |||
45 | /** | ||
46 | * Size of test messages | ||
47 | */ | ||
48 | #define TEST_MESSAGE_SIZE 100 | ||
49 | |||
50 | |||
51 | struct TestMessage | ||
52 | { | ||
53 | struct GNUNET_MessageHeader header; | ||
54 | |||
55 | uint8_t padding[TEST_MESSAGE_SIZE - sizeof(struct GNUNET_MessageHeader)]; | ||
56 | }; | ||
57 | |||
58 | |||
59 | struct BenchmarkPartner; | ||
60 | |||
61 | struct BenchmarkPeer; | ||
62 | |||
63 | struct GNUNET_ATS_TEST_Topology; | ||
64 | |||
65 | struct TrafficGenerator; | ||
66 | |||
67 | struct LoggingHandle; | ||
68 | |||
69 | enum GeneratorType | ||
70 | { | ||
71 | GNUNET_ATS_TEST_TG_LINEAR, | ||
72 | GNUNET_ATS_TEST_TG_CONSTANT, | ||
73 | GNUNET_ATS_TEST_TG_RANDOM, | ||
74 | GNUNET_ATS_TEST_TG_SINUS | ||
75 | }; | ||
76 | |||
77 | |||
78 | /** | ||
79 | * Callback to call when topology setup is completed | ||
80 | * | ||
81 | * @param cls the closure | ||
82 | * @param masters array of master peers | ||
83 | * @param slaves array of master peers | ||
84 | */ | ||
85 | typedef void (*GNUNET_ATS_TEST_TopologySetupDoneCallback) ( | ||
86 | void *cls, | ||
87 | struct BenchmarkPeer *masters, | ||
88 | struct BenchmarkPeer *slaves); | ||
89 | |||
90 | /** | ||
91 | * Callback called when logging is required for the data contained | ||
92 | * | ||
93 | * @param cls the closure | ||
94 | * @param address an address | ||
95 | * @param address_active is address active | ||
96 | * @param bandwidth_out bandwidth outbound | ||
97 | * @param bandwidth_in bandwidth inbound | ||
98 | * @param prop performance information | ||
99 | */ | ||
100 | typedef void (*GNUNET_ATS_TEST_LogRequest) ( | ||
101 | void *cls, | ||
102 | const struct GNUNET_HELLO_Address *address, | ||
103 | int address_active, | ||
104 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, | ||
105 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, | ||
106 | const struct GNUNET_ATS_Properties *prop); | ||
107 | |||
108 | /** | ||
109 | * Information we track for a peer in the testbed. | ||
110 | */ | ||
111 | struct BenchmarkPeer | ||
112 | { | ||
113 | /** | ||
114 | * Handle with testbed. | ||
115 | */ | ||
116 | struct GNUNET_TESTBED_Peer *peer; | ||
117 | |||
118 | /** | ||
119 | * Unique identifier | ||
120 | */ | ||
121 | int no; | ||
122 | |||
123 | /** | ||
124 | * Is this peer a measter: GNUNET_YES/GNUNET_NO | ||
125 | */ | ||
126 | int master; | ||
127 | |||
128 | /** | ||
129 | * Peer ID | ||
130 | */ | ||
131 | struct GNUNET_PeerIdentity id; | ||
132 | |||
133 | /** | ||
134 | * Testbed operation to get peer information | ||
135 | */ | ||
136 | struct GNUNET_TESTBED_Operation *peer_id_op; | ||
137 | |||
138 | /** | ||
139 | * Testbed operation to connect to ATS performance service | ||
140 | */ | ||
141 | struct GNUNET_TESTBED_Operation *ats_perf_op; | ||
142 | |||
143 | /** | ||
144 | * Testbed operation to connect to core | ||
145 | */ | ||
146 | struct GNUNET_TESTBED_Operation *comm_op; | ||
147 | |||
148 | /** | ||
149 | * ATS performance handle | ||
150 | */ | ||
151 | struct GNUNET_ATS_PerformanceHandle *ats_perf_handle; | ||
152 | |||
153 | /** | ||
154 | * Masters only: | ||
155 | * Testbed connect operations to connect masters to slaves | ||
156 | */ | ||
157 | struct TestbedConnectOperation *core_connect_ops; | ||
158 | |||
159 | /** | ||
160 | * Core handle | ||
161 | */ | ||
162 | struct GNUNET_CORE_Handle *ch; | ||
163 | |||
164 | /** | ||
165 | * Transport handle | ||
166 | */ | ||
167 | struct GNUNET_TRANSPORT_CoreHandle *th; | ||
168 | |||
169 | /** | ||
170 | * Masters only: | ||
171 | * Peer to set ATS preferences for | ||
172 | */ | ||
173 | struct BenchmarkPeer *pref_partner; | ||
174 | |||
175 | /** | ||
176 | * Masters only | ||
177 | * Progress task | ||
178 | */ | ||
179 | struct GNUNET_SCHEDULER_Task *ats_task; | ||
180 | |||
181 | /** | ||
182 | * Masters only | ||
183 | * Progress task | ||
184 | */ | ||
185 | double pref_value; | ||
186 | |||
187 | /** | ||
188 | * Array of partners with num_slaves entries (if master) or | ||
189 | * num_master entries (if slave) | ||
190 | */ | ||
191 | struct BenchmarkPartner *partners; | ||
192 | |||
193 | /** | ||
194 | * Number of partners | ||
195 | */ | ||
196 | int num_partners; | ||
197 | |||
198 | /** | ||
199 | * Number of core connections | ||
200 | */ | ||
201 | int core_connections; | ||
202 | |||
203 | /** | ||
204 | * Masters only: | ||
205 | * Number of connections to slave peers | ||
206 | */ | ||
207 | int core_slave_connections; | ||
208 | |||
209 | /** | ||
210 | * Total number of messages this peer has sent | ||
211 | */ | ||
212 | unsigned int total_messages_sent; | ||
213 | |||
214 | /** | ||
215 | * Total number of bytes this peer has sent | ||
216 | */ | ||
217 | unsigned int total_bytes_sent; | ||
218 | |||
219 | /** | ||
220 | * Total number of messages this peer has received | ||
221 | */ | ||
222 | unsigned int total_messages_received; | ||
223 | |||
224 | /** | ||
225 | * Total number of bytes this peer has received | ||
226 | */ | ||
227 | unsigned int total_bytes_received; | ||
228 | }; | ||
229 | |||
230 | struct TrafficGenerator | ||
231 | { | ||
232 | struct TrafficGenerator *prev; | ||
233 | struct TrafficGenerator *next; | ||
234 | |||
235 | enum GeneratorType type; | ||
236 | |||
237 | struct BenchmarkPeer *src; | ||
238 | struct BenchmarkPartner *dest; | ||
239 | |||
240 | long int base_rate; | ||
241 | long int max_rate; | ||
242 | struct GNUNET_TIME_Relative duration_period; | ||
243 | |||
244 | struct GNUNET_SCHEDULER_Task *send_task; | ||
245 | struct GNUNET_TIME_Absolute next_ping_transmission; | ||
246 | struct GNUNET_TIME_Absolute time_start; | ||
247 | }; | ||
248 | |||
249 | |||
250 | struct PreferenceGenerator | ||
251 | { | ||
252 | struct PreferenceGenerator *prev; | ||
253 | struct PreferenceGenerator *next; | ||
254 | |||
255 | enum GeneratorType type; | ||
256 | |||
257 | struct BenchmarkPeer *src; | ||
258 | struct BenchmarkPartner *dest; | ||
259 | |||
260 | enum GNUNET_ATS_PreferenceKind kind; | ||
261 | |||
262 | long int base_value; | ||
263 | long int max_value; | ||
264 | struct GNUNET_TIME_Relative duration_period; | ||
265 | struct GNUNET_TIME_Relative frequency; | ||
266 | |||
267 | struct GNUNET_SCHEDULER_Task *set_task; | ||
268 | struct GNUNET_TIME_Absolute next_ping_transmission; | ||
269 | struct GNUNET_TIME_Absolute time_start; | ||
270 | }; | ||
271 | |||
272 | /** | ||
273 | * Information about a benchmarking partner | ||
274 | */ | ||
275 | struct BenchmarkPartner | ||
276 | { | ||
277 | /** | ||
278 | * The peer itself this partner belongs to | ||
279 | */ | ||
280 | struct BenchmarkPeer *me; | ||
281 | |||
282 | /** | ||
283 | * The partner peer | ||
284 | */ | ||
285 | struct BenchmarkPeer *dest; | ||
286 | |||
287 | /** | ||
288 | * Message queue handle. | ||
289 | */ | ||
290 | struct GNUNET_MQ_Handle *mq; | ||
291 | |||
292 | /** | ||
293 | * Handle for traffic generator | ||
294 | */ | ||
295 | struct TrafficGenerator *tg; | ||
296 | |||
297 | /** | ||
298 | * Handle for preference generator | ||
299 | */ | ||
300 | struct PreferenceGenerator *pg; | ||
301 | |||
302 | /** | ||
303 | * Timestamp to calculate communication layer delay | ||
304 | */ | ||
305 | struct GNUNET_TIME_Absolute last_message_sent; | ||
306 | |||
307 | /** | ||
308 | * Accumulated RTT for all messages | ||
309 | */ | ||
310 | unsigned int total_app_rtt; | ||
311 | |||
312 | /** | ||
313 | * Number of messages sent to this partner | ||
314 | */ | ||
315 | unsigned int messages_sent; | ||
316 | |||
317 | /** | ||
318 | * Number of bytes sent to this partner | ||
319 | */ | ||
320 | unsigned int bytes_sent; | ||
321 | |||
322 | /** | ||
323 | * Number of messages received from this partner | ||
324 | */ | ||
325 | unsigned int messages_received; | ||
326 | |||
327 | /** | ||
328 | * Number of bytes received from this partner | ||
329 | */ | ||
330 | unsigned int bytes_received; | ||
331 | |||
332 | /** | ||
333 | * Current ATS properties | ||
334 | */ | ||
335 | struct GNUNET_ATS_Properties props; | ||
336 | |||
337 | /** | ||
338 | * Bandwidth assigned inbound | ||
339 | */ | ||
340 | uint32_t bandwidth_in; | ||
341 | |||
342 | /** | ||
343 | * Bandwidth assigned outbound | ||
344 | */ | ||
345 | uint32_t bandwidth_out; | ||
346 | |||
347 | /** | ||
348 | * Current preference values for bandwidth | ||
349 | */ | ||
350 | double pref_bandwidth; | ||
351 | |||
352 | /** | ||
353 | * Current preference values for delay | ||
354 | */ | ||
355 | double pref_delay; | ||
356 | }; | ||
357 | |||
358 | |||
359 | /** | ||
360 | * Overall state of the performance benchmark | ||
361 | */ | ||
362 | struct BenchmarkState | ||
363 | { | ||
364 | /** | ||
365 | * Are we connected to ATS service of all peers: GNUNET_YES/NO | ||
366 | */ | ||
367 | int connected_ATS_service; | ||
368 | |||
369 | /** | ||
370 | * Are we connected to CORE service of all peers: GNUNET_YES/NO | ||
371 | */ | ||
372 | int connected_COMM_service; | ||
373 | |||
374 | /** | ||
375 | * Are we connected to all peers: GNUNET_YES/NO | ||
376 | */ | ||
377 | int connected_PEERS; | ||
378 | |||
379 | /** | ||
380 | * Are we connected to all slave peers on CORE level: GNUNET_YES/NO | ||
381 | */ | ||
382 | int connected_CORE; | ||
383 | |||
384 | /** | ||
385 | * Are we connected to CORE service of all peers: GNUNET_YES/NO | ||
386 | */ | ||
387 | int benchmarking; | ||
388 | }; | ||
389 | |||
390 | |||
391 | struct GNUNET_ATS_TEST_Topology | ||
392 | { | ||
393 | /** | ||
394 | * Progress task | ||
395 | */ | ||
396 | struct GNUNET_SCHEDULER_Task *progress_task; | ||
397 | |||
398 | /** | ||
399 | * Test result | ||
400 | */ | ||
401 | int result; | ||
402 | |||
403 | /** | ||
404 | * Test core (#GNUNET_YES) or transport (#GNUNET_NO) | ||
405 | */ | ||
406 | int test_core; | ||
407 | |||
408 | /** | ||
409 | * Solver string | ||
410 | */ | ||
411 | char *solver; | ||
412 | |||
413 | /** | ||
414 | * Preference string | ||
415 | */ | ||
416 | char *testname; | ||
417 | |||
418 | /** | ||
419 | * Preference string | ||
420 | */ | ||
421 | char *pref_str; | ||
422 | |||
423 | /** | ||
424 | * ATS preference value | ||
425 | */ | ||
426 | int pref_val; | ||
427 | |||
428 | /** | ||
429 | * Number master peers | ||
430 | */ | ||
431 | unsigned int num_masters; | ||
432 | |||
433 | /** | ||
434 | * Array of master peers | ||
435 | */ | ||
436 | struct BenchmarkPeer *mps; | ||
437 | |||
438 | /** | ||
439 | * Number slave peers | ||
440 | */ | ||
441 | unsigned int num_slaves; | ||
442 | |||
443 | /** | ||
444 | * Array of slave peers | ||
445 | */ | ||
446 | struct BenchmarkPeer *sps; | ||
447 | |||
448 | /** | ||
449 | * Benchmark duration | ||
450 | */ | ||
451 | struct GNUNET_TIME_Relative perf_duration; | ||
452 | |||
453 | /** | ||
454 | * Logging frequency | ||
455 | */ | ||
456 | struct GNUNET_TIME_Relative log_frequency; | ||
457 | |||
458 | /** | ||
459 | * Benchmark state | ||
460 | */ | ||
461 | struct BenchmarkState state; | ||
462 | |||
463 | GNUNET_ATS_TEST_TopologySetupDoneCallback done_cb; | ||
464 | |||
465 | GNUNET_ATS_AddressInformationCallback ats_perf_cb; | ||
466 | |||
467 | void *done_cb_cls; | ||
468 | }; | ||
469 | |||
470 | enum OperationType | ||
471 | { | ||
472 | START_SEND, | ||
473 | STOP_SEND, | ||
474 | START_PREFERENCE, | ||
475 | STOP_PREFERENCE | ||
476 | }; | ||
477 | |||
478 | struct Episode; | ||
479 | |||
480 | struct Experiment; | ||
481 | |||
482 | typedef void (*GNUNET_ATS_TESTING_EpisodeDoneCallback) (struct Episode *e); | ||
483 | |||
484 | typedef void (*GNUNET_ATS_TESTING_ExperimentDoneCallback) ( | ||
485 | struct Experiment *e, | ||
486 | struct GNUNET_TIME_Relative duration, | ||
487 | int success); | ||
488 | |||
489 | /** | ||
490 | * An operation in an experiment | ||
491 | */ | ||
492 | struct GNUNET_ATS_TEST_Operation | ||
493 | { | ||
494 | struct GNUNET_ATS_TEST_Operation *next; | ||
495 | struct GNUNET_ATS_TEST_Operation *prev; | ||
496 | |||
497 | long long unsigned int src_id; | ||
498 | long long unsigned int dest_id; | ||
499 | |||
500 | long long unsigned int base_rate; | ||
501 | long long unsigned int max_rate; | ||
502 | struct GNUNET_TIME_Relative period; | ||
503 | struct GNUNET_TIME_Relative frequency; | ||
504 | |||
505 | enum OperationType type; | ||
506 | enum GeneratorType gen_type; | ||
507 | enum GNUNET_ATS_PreferenceKind pref_type; | ||
508 | }; | ||
509 | |||
510 | struct Episode | ||
511 | { | ||
512 | int id; | ||
513 | struct Episode *next; | ||
514 | struct GNUNET_TIME_Relative duration; | ||
515 | |||
516 | struct GNUNET_ATS_TEST_Operation *head; | ||
517 | struct GNUNET_ATS_TEST_Operation *tail; | ||
518 | }; | ||
519 | |||
520 | |||
521 | struct Experiment | ||
522 | { | ||
523 | char *name; | ||
524 | char *cfg_file; | ||
525 | unsigned long long int num_masters; | ||
526 | unsigned long long int num_slaves; | ||
527 | struct GNUNET_TIME_Relative log_freq; | ||
528 | struct GNUNET_TIME_Relative max_duration; | ||
529 | struct GNUNET_TIME_Relative total_duration; | ||
530 | struct GNUNET_TIME_Absolute start_time; | ||
531 | unsigned int num_episodes; | ||
532 | struct Episode *start; | ||
533 | |||
534 | struct GNUNET_SCHEDULER_Task *experiment_timeout_task; | ||
535 | struct GNUNET_SCHEDULER_Task *episode_timeout_task; | ||
536 | struct Episode *cur; | ||
537 | |||
538 | GNUNET_ATS_TESTING_EpisodeDoneCallback ep_done_cb; | ||
539 | GNUNET_ATS_TESTING_ExperimentDoneCallback e_done_cb; | ||
540 | }; | ||
541 | |||
542 | |||
543 | extern struct GNUNET_CONFIGURATION_Handle *cfg; | ||
544 | |||
545 | /** | ||
546 | * Execute the specified experiment | ||
547 | * | ||
548 | * @param e the Experiment | ||
549 | * @param ep_done_cb a episode is completed | ||
550 | * @param e_done_cb the experiment is completed | ||
551 | */ | ||
552 | void | ||
553 | GNUNET_ATS_TEST_experimentation_run ( | ||
554 | struct Experiment *e, | ||
555 | GNUNET_ATS_TESTING_EpisodeDoneCallback ep_done_cb, | ||
556 | GNUNET_ATS_TESTING_ExperimentDoneCallback e_done_cb); | ||
557 | |||
558 | |||
559 | /** | ||
560 | * Load an experiment from a file | ||
561 | * | ||
562 | * @param filename the file | ||
563 | * @return the Experiment or NULL on failure | ||
564 | */ | ||
565 | struct Experiment * | ||
566 | GNUNET_ATS_TEST_experimentation_load (const char *filename); | ||
567 | |||
568 | |||
569 | /** | ||
570 | * Stop an experiment | ||
571 | * | ||
572 | * @param e the experiment | ||
573 | */ | ||
574 | void | ||
575 | GNUNET_ATS_TEST_experimentation_stop (struct Experiment *e); | ||
576 | |||
577 | |||
578 | void | ||
579 | GNUNET_ATS_TEST_traffic_handle_ping (struct BenchmarkPartner *p); | ||
580 | |||
581 | |||
582 | void | ||
583 | GNUNET_ATS_TEST_traffic_handle_pong (struct BenchmarkPartner *p); | ||
584 | |||
585 | |||
586 | /** | ||
587 | * Generate between the source master and the partner and send traffic with a | ||
588 | * maximum rate. | ||
589 | * | ||
590 | * @param src traffic source | ||
591 | * @param dest traffic partner | ||
592 | * @param type type of traffic to generate | ||
593 | * @param base_rate traffic base rate to send data with | ||
594 | * @param max_rate traffic maximum rate to send data with | ||
595 | * @param period duration of a period of traffic generation (~ 1/frequency) | ||
596 | * @param duration how long to generate traffic | ||
597 | * @return the traffic generator | ||
598 | */ | ||
599 | struct TrafficGenerator * | ||
600 | GNUNET_ATS_TEST_generate_traffic_start (struct BenchmarkPeer *src, | ||
601 | struct BenchmarkPartner *dest, | ||
602 | enum GeneratorType type, | ||
603 | unsigned int base_rate, | ||
604 | unsigned int max_rate, | ||
605 | struct GNUNET_TIME_Relative period, | ||
606 | struct GNUNET_TIME_Relative duration); | ||
607 | |||
608 | |||
609 | void | ||
610 | GNUNET_ATS_TEST_generate_traffic_stop (struct TrafficGenerator *tg); | ||
611 | |||
612 | |||
613 | /** | ||
614 | * Stop all traffic generators | ||
615 | */ | ||
616 | void | ||
617 | GNUNET_ATS_TEST_generate_traffic_stop_all (void); | ||
618 | |||
619 | |||
620 | /** | ||
621 | * Generate between the source master and the partner and set preferences with a | ||
622 | * value depending on the generator. | ||
623 | * | ||
624 | * @param src source | ||
625 | * @param dest partner | ||
626 | * @param type type of preferences to generate | ||
627 | * @param base_value traffic base rate to send data with | ||
628 | * @param value_rate traffic maximum rate to send data with | ||
629 | * @param period duration of a period of preferences generation (~ 1/frequency) | ||
630 | * @param frequency how long to generate preferences | ||
631 | * @param kind ATS preference to generate | ||
632 | * @return the traffic generator | ||
633 | */ | ||
634 | struct PreferenceGenerator * | ||
635 | GNUNET_ATS_TEST_generate_preferences_start ( | ||
636 | struct BenchmarkPeer *src, | ||
637 | struct BenchmarkPartner *dest, | ||
638 | enum GeneratorType type, | ||
639 | unsigned int base_value, | ||
640 | unsigned int value_rate, | ||
641 | struct GNUNET_TIME_Relative period, | ||
642 | struct GNUNET_TIME_Relative frequency, | ||
643 | enum GNUNET_ATS_PreferenceKind kind); | ||
644 | |||
645 | |||
646 | void | ||
647 | GNUNET_ATS_TEST_generate_preferences_stop (struct PreferenceGenerator *pg); | ||
648 | |||
649 | |||
650 | void | ||
651 | GNUNET_ATS_TEST_generate_preferences_stop_all (void); | ||
652 | |||
653 | |||
654 | /** | ||
655 | * Start logging | ||
656 | * | ||
657 | * @param log_frequency the logging frequency | ||
658 | * @param testname the testname | ||
659 | * @param masters the master peers used for benchmarking | ||
660 | * @param num_masters the number of master peers | ||
661 | * @param num_slaves the number of slave peers | ||
662 | * @param verbose verbose logging | ||
663 | * @return the logging handle or NULL on error | ||
664 | */ | ||
665 | struct LoggingHandle * | ||
666 | GNUNET_ATS_TEST_logging_start (struct GNUNET_TIME_Relative log_frequency, | ||
667 | const char *testname, | ||
668 | struct BenchmarkPeer *masters, | ||
669 | int num_masters, | ||
670 | int num_slaves, | ||
671 | int verbose); | ||
672 | |||
673 | |||
674 | /** | ||
675 | * Stop logging | ||
676 | * | ||
677 | * @param l the logging handle | ||
678 | */ | ||
679 | void | ||
680 | GNUNET_ATS_TEST_logging_clean_up (struct LoggingHandle *l); | ||
681 | |||
682 | |||
683 | /** | ||
684 | * Stop logging | ||
685 | * | ||
686 | * @param l the logging handle | ||
687 | */ | ||
688 | void | ||
689 | GNUNET_ATS_TEST_logging_stop (struct LoggingHandle *l); | ||
690 | |||
691 | |||
692 | /** | ||
693 | * Log all data now | ||
694 | * | ||
695 | * @param l logging handle to use | ||
696 | */ | ||
697 | void | ||
698 | GNUNET_ATS_TEST_logging_now (struct LoggingHandle *l); | ||
699 | |||
700 | |||
701 | /** | ||
702 | * Write logging data to file | ||
703 | * | ||
704 | * @param l logging handle to use | ||
705 | * @param test_name name of the current test | ||
706 | * @param plots create gnuplots: #GNUNET_YES or #GNUNET_NO | ||
707 | */ | ||
708 | void | ||
709 | GNUNET_ATS_TEST_logging_write_to_file (struct LoggingHandle *l, | ||
710 | const char *test_name, | ||
711 | int plots); | ||
712 | |||
713 | |||
714 | /** | ||
715 | * Topology related functions | ||
716 | */ | ||
717 | struct BenchmarkPeer * | ||
718 | GNUNET_ATS_TEST_get_peer (int src); | ||
719 | |||
720 | |||
721 | struct BenchmarkPartner * | ||
722 | GNUNET_ATS_TEST_get_partner (int src, int dest); | ||
723 | |||
724 | |||
725 | /** | ||
726 | * Create a topology for ats testing | ||
727 | * | ||
728 | * @param name test name | ||
729 | * @param cfg_file configuration file to use for the peers | ||
730 | * @param num_slaves number of slaves | ||
731 | * @param num_masters number of masters | ||
732 | * @param test_core connect to CORE service (#GNUNET_YES) or transport | ||
733 | * (#GNUNET_NO) | ||
734 | * @param done_cb function to call when topology is setup | ||
735 | * @param done_cb_cls cls for callback | ||
736 | * @param log_request_cb callback to call when logging is required | ||
737 | */ | ||
738 | void | ||
739 | GNUNET_ATS_TEST_create_topology ( | ||
740 | char *name, | ||
741 | char *cfg_file, | ||
742 | unsigned int num_slaves, | ||
743 | unsigned int num_masters, | ||
744 | int test_core, | ||
745 | GNUNET_ATS_TEST_TopologySetupDoneCallback done_cb, | ||
746 | void *done_cb_cls, | ||
747 | GNUNET_ATS_TEST_LogRequest ats_perf_cb); | ||
748 | |||
749 | |||
750 | /** | ||
751 | * Shutdown topology | ||
752 | */ | ||
753 | void | ||
754 | GNUNET_ATS_TEST_shutdown_topology (void); | ||
755 | |||
756 | |||
757 | /* end of file ats-testing.h */ | ||
diff --git a/src/ats-tests/experiments/evaluation1_dru_3_peers_1addr_1scope_prop.conf b/src/ats-tests/experiments/evaluation1_dru_3_peers_1addr_1scope_prop.conf deleted file mode 100644 index 4b66e5aea..000000000 --- a/src/ats-tests/experiments/evaluation1_dru_3_peers_1addr_1scope_prop.conf +++ /dev/null | |||
@@ -1,24 +0,0 @@ | |||
1 | @INLINE@ template_perf_ats.conf | ||
2 | |||
3 | [transport] | ||
4 | plugins = unix | ||
5 | |||
6 | [ats] | ||
7 | MODE = MLP | ||
8 | UNSPECIFIED_QUOTA_IN = 128 KiB | ||
9 | UNSPECIFIED_QUOTA_OUT = 128 KiB | ||
10 | # LOOPBACK | ||
11 | LOOPBACK_QUOTA_IN = 128 KiB | ||
12 | LOOPBACK_QUOTA_OUT = 128 KiB | ||
13 | # LAN | ||
14 | LAN_QUOTA_IN = 128 KiB | ||
15 | LAN_QUOTA_OUT = 128 KiB | ||
16 | # WAN | ||
17 | WAN_QUOTA_IN = 128 KiB | ||
18 | WAN_QUOTA_OUT = 128 KiB | ||
19 | # WLAN | ||
20 | WLAN_QUOTA_IN = 128 KiB | ||
21 | WLAN_QUOTA_OUT = 128 KiB | ||
22 | # BLUETOOTH | ||
23 | BLUETOOTH_QUOTA_IN = 128 KiB | ||
24 | BLUETOOTH_QUOTA_OUT = 128 KiB \ No newline at end of file | ||
diff --git a/src/ats-tests/experiments/evaluation1_dru_3_peers_1addr_1scope_prop.exp b/src/ats-tests/experiments/evaluation1_dru_3_peers_1addr_1scope_prop.exp deleted file mode 100644 index 6a04e7491..000000000 --- a/src/ats-tests/experiments/evaluation1_dru_3_peers_1addr_1scope_prop.exp +++ /dev/null | |||
@@ -1,46 +0,0 @@ | |||
1 | [experiment] | ||
2 | name = sc1_eval_dru_prop | ||
3 | masters = 1 | ||
4 | slaves = 3 | ||
5 | max_duration = 20 s | ||
6 | log_freq = 100 ms | ||
7 | cfg_file = experiments/evaluation1_dru_3_peers_1addr_1scope_prop.conf | ||
8 | |||
9 | [episode-0] | ||
10 | # operations = start_send, stop_send, start_preference, stop_preference | ||
11 | duration = 10 s | ||
12 | op-0-operation = start_send | ||
13 | op-0-src = 0 | ||
14 | op-0-dest = 0 | ||
15 | op-0-type = constant | ||
16 | #op-0-period = 10 s | ||
17 | op-0-base-rate= 10000 | ||
18 | #op-0-max-rate = 10000 | ||
19 | |||
20 | op-1-operation = start_send | ||
21 | op-1-src = 0 | ||
22 | op-1-dest = 1 | ||
23 | op-1-type = constant | ||
24 | #op-1-period = 10 s | ||
25 | op-1-base-rate= 10000 | ||
26 | #op-1-max-rate = 10000 | ||
27 | |||
28 | op-2-operation = start_send | ||
29 | op-2-src = 0 | ||
30 | op-2-dest = 2 | ||
31 | op-2-type = constant | ||
32 | #op-1-period = 10 s | ||
33 | op-2-base-rate= 10000 | ||
34 | #op-1-max-rate = 10000 | ||
35 | |||
36 | [episode-1] | ||
37 | duration = 10 s | ||
38 | op-0-operation = start_preference | ||
39 | op-0-src = 0 | ||
40 | op-0-dest = 2 | ||
41 | op-0-type = constant | ||
42 | #op-0-period = 10 s | ||
43 | op-0-pref = bandwidth | ||
44 | op-0-frequency = 1 s | ||
45 | op-0-base-rate= 50 | ||
46 | #op-0-max-rate = 10000 \ No newline at end of file | ||
diff --git a/src/ats-tests/experiments/send_linear_10_sec.exp b/src/ats-tests/experiments/send_linear_10_sec.exp deleted file mode 100644 index efd2c7b08..000000000 --- a/src/ats-tests/experiments/send_linear_10_sec.exp +++ /dev/null | |||
@@ -1,30 +0,0 @@ | |||
1 | [experiment] | ||
2 | name = test | ||
3 | masters = 1 | ||
4 | slaves = 3 | ||
5 | max_duration = 2 s | ||
6 | cfg_file = gnunet_ats_sim_default.conf | ||
7 | |||
8 | [episode-0] | ||
9 | # operations = set_rate, start_send, stop_send, set_preference | ||
10 | duration = 2 s | ||
11 | op-0-operation = set_rate | ||
12 | op-0-src = 0 | ||
13 | op-0-dest = 0 | ||
14 | op-0-type = constant | ||
15 | op-0-base-rate= 10000 | ||
16 | op-0-max-rate = 10000 | ||
17 | |||
18 | op-1-operation = set_rate | ||
19 | op-1-src = 0 | ||
20 | op-1-dest = 1 | ||
21 | op-1-type = constant | ||
22 | op-1-base-rate= 10000 | ||
23 | op-1-max-rate = 10000 | ||
24 | |||
25 | op-2-operation = set_rate | ||
26 | op-2-src = 0 | ||
27 | op-2-dest = 2 | ||
28 | op-2-type = constant | ||
29 | op-2-base-rate= 10000 | ||
30 | op-2-max-rate = 10000 \ No newline at end of file | ||
diff --git a/src/ats-tests/experiments/test.exp b/src/ats-tests/experiments/test.exp deleted file mode 100644 index 636139f89..000000000 --- a/src/ats-tests/experiments/test.exp +++ /dev/null | |||
@@ -1,55 +0,0 @@ | |||
1 | [experiment] | ||
2 | name = test | ||
3 | masters = 1 | ||
4 | slaves = 2 | ||
5 | max_duration = 15 s | ||
6 | log_freq = 100 ms | ||
7 | cfg_file = gnunet_ats_sim_default.conf | ||
8 | |||
9 | [episode-0] | ||
10 | # operations = start_send, stop_send, start_preference, stop_preference | ||
11 | duration = 10 s | ||
12 | op-0-operation = start_send | ||
13 | op-0-src = 0 | ||
14 | op-0-dest = 0 | ||
15 | op-0-type = constant | ||
16 | op-0-base-rate= 10000 | ||
17 | op-0-max-rate = 10000 | ||
18 | |||
19 | op-1-operation = start_send | ||
20 | op-1-src = 0 | ||
21 | op-1-dest = 1 | ||
22 | op-1-type = sinus | ||
23 | op-1-period = 5 s | ||
24 | op-1-base-rate= 10000 | ||
25 | op-1-max-rate = 15000 | ||
26 | |||
27 | op-2-operation = start_preference | ||
28 | op-2-src = 0 | ||
29 | op-2-dest = 0 | ||
30 | op-2-type = constant | ||
31 | op-2-period = 5 s | ||
32 | op-2-base-rate= 10 | ||
33 | op-2-max-rate = 5 | ||
34 | op-2-pref = latency | ||
35 | op-2-frequency = 2 s | ||
36 | |||
37 | op-3-operation = start_preference | ||
38 | op-3-src = 0 | ||
39 | op-3-dest = 1 | ||
40 | op-3-type = linear | ||
41 | op-3-period = 5 s | ||
42 | op-3-base-rate= 40 | ||
43 | op-3-max-rate = 50 | ||
44 | op-3-pref = bandwidth | ||
45 | op-3-frequency = 750 ms | ||
46 | |||
47 | [episode-1] | ||
48 | duration = 5 s | ||
49 | op-0-operation = stop_preference | ||
50 | op-0-src = 0 | ||
51 | op-0-dest = 0 | ||
52 | |||
53 | op-1-operation = stop_preference | ||
54 | op-1-src = 0 | ||
55 | op-1-dest = 1 | ||
diff --git a/src/ats-tests/gnunet-ats-sim.c b/src/ats-tests/gnunet-ats-sim.c deleted file mode 100644 index 15cd52e2f..000000000 --- a/src/ats-tests/gnunet-ats-sim.c +++ /dev/null | |||
@@ -1,399 +0,0 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet. | ||
3 | Copyright (C) 2010-2013 GNUnet e.V. | ||
4 | |||
5 | GNUnet is free software: you can redistribute it and/or modify it | ||
6 | under the terms of the GNU Affero General Public License as published | ||
7 | by the Free Software Foundation, either version 3 of the License, | ||
8 | or (at your option) any later version. | ||
9 | |||
10 | GNUnet is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Affero General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Affero General Public License | ||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | ||
19 | */ | ||
20 | /** | ||
21 | * @file ats-tests/gnunet-ats-sim.c | ||
22 | * @brief ats traffic simulator: this tool uses the ats-test library to setup a | ||
23 | * topology and generate traffic between these peers. The traffic description | ||
24 | * is loaded from a experiment description file | ||
25 | * @author Christian Grothoff | ||
26 | * @author Matthias Wachs | ||
27 | */ | ||
28 | #include "platform.h" | ||
29 | #include "gnunet_util_lib.h" | ||
30 | #include "gnunet_testbed_service.h" | ||
31 | #include "gnunet_ats_service.h" | ||
32 | #include "gnunet_core_service.h" | ||
33 | #include "ats-testing.h" | ||
34 | |||
35 | #define TEST_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, \ | ||
36 | 10) | ||
37 | |||
38 | static struct BenchmarkPeer *masters_p; | ||
39 | static struct BenchmarkPeer *slaves_p; | ||
40 | |||
41 | /** | ||
42 | * cmd option -e: experiment file | ||
43 | */ | ||
44 | static char *opt_exp_file; | ||
45 | |||
46 | /** | ||
47 | * cmd option -l: enable logging | ||
48 | */ | ||
49 | static int opt_log; | ||
50 | |||
51 | /** | ||
52 | * cmd option -p: enable plots | ||
53 | */ | ||
54 | static int opt_plot; | ||
55 | |||
56 | /** | ||
57 | * cmd option -v: verbose logs | ||
58 | */ | ||
59 | static int opt_verbose; | ||
60 | |||
61 | static struct GNUNET_SCHEDULER_Task *timeout_task; | ||
62 | |||
63 | static struct Experiment *e; | ||
64 | |||
65 | static struct LoggingHandle *l; | ||
66 | |||
67 | |||
68 | static void | ||
69 | evaluate (struct GNUNET_TIME_Relative duration_total) | ||
70 | { | ||
71 | int c_m; | ||
72 | int c_s; | ||
73 | unsigned int duration; | ||
74 | struct BenchmarkPeer *mp; | ||
75 | struct BenchmarkPartner *p; | ||
76 | |||
77 | unsigned int b_sent_sec; | ||
78 | double kb_sent_percent; | ||
79 | unsigned int b_recv_sec; | ||
80 | double kb_recv_percent; | ||
81 | unsigned int rtt; | ||
82 | |||
83 | |||
84 | duration = (duration_total.rel_value_us / (1000 * 1000)); | ||
85 | if (0 == duration) | ||
86 | duration = 1; | ||
87 | for (c_m = 0; c_m < e->num_masters; c_m++) | ||
88 | { | ||
89 | mp = &masters_p[c_m]; | ||
90 | fprintf (stderr, | ||
91 | _ ( | ||
92 | "Master [%u]: sent: %u KiB in %u sec. = %u KiB/s, received: %u KiB in %u sec. = %u KiB/s\n"), | ||
93 | mp->no, mp->total_bytes_sent / 1024, | ||
94 | duration, | ||
95 | (mp->total_bytes_sent / 1024) / duration, | ||
96 | mp->total_bytes_received / 1024, | ||
97 | duration, | ||
98 | (mp->total_bytes_received / 1024) / duration); | ||
99 | |||
100 | for (c_s = 0; c_s < e->num_slaves; c_s++) | ||
101 | { | ||
102 | p = &mp->partners[c_s]; | ||
103 | |||
104 | b_sent_sec = 0; | ||
105 | b_recv_sec = 0; | ||
106 | kb_sent_percent = 0.0; | ||
107 | kb_recv_percent = 0.0; | ||
108 | rtt = 0; | ||
109 | |||
110 | if (duration > 0) | ||
111 | { | ||
112 | b_sent_sec = p->bytes_sent / duration; | ||
113 | b_recv_sec = p->bytes_received / duration; | ||
114 | } | ||
115 | |||
116 | if (mp->total_bytes_sent > 0) | ||
117 | kb_sent_percent = ((double) p->bytes_sent * 100) / mp->total_bytes_sent; | ||
118 | if (mp->total_bytes_received > 0) | ||
119 | kb_recv_percent = ((double) p->bytes_received * 100) | ||
120 | / mp->total_bytes_received; | ||
121 | if (1000 * p->messages_sent > 0) | ||
122 | rtt = p->total_app_rtt / (1000 * p->messages_sent); | ||
123 | fprintf (stderr, | ||
124 | "%c Master [%u] -> Slave [%u]: sent %u Bips (%.2f %%), received %u Bips (%.2f %%)\n", | ||
125 | (mp->pref_partner == p->dest) ? '*' : ' ', | ||
126 | mp->no, p->dest->no, | ||
127 | b_sent_sec, kb_sent_percent, | ||
128 | b_recv_sec, kb_recv_percent); | ||
129 | fprintf (stderr, | ||
130 | "%c Master [%u] -> Slave [%u]: Average application layer RTT: %u ms\n", | ||
131 | (mp->pref_partner == p->dest) ? '*' : ' ', | ||
132 | mp->no, p->dest->no, rtt); | ||
133 | } | ||
134 | } | ||
135 | } | ||
136 | |||
137 | |||
138 | static void | ||
139 | do_shutdown (void *cls) | ||
140 | { | ||
141 | fprintf (stderr, "Shutdown\n"); | ||
142 | if (NULL != timeout_task) | ||
143 | { | ||
144 | GNUNET_SCHEDULER_cancel (timeout_task); | ||
145 | timeout_task = NULL; | ||
146 | } | ||
147 | if (NULL != l) | ||
148 | { | ||
149 | GNUNET_ATS_TEST_logging_stop (l); | ||
150 | GNUNET_ATS_TEST_logging_clean_up (l); | ||
151 | l = NULL; | ||
152 | } | ||
153 | |||
154 | /* Stop traffic generation */ | ||
155 | GNUNET_ATS_TEST_generate_traffic_stop_all (); | ||
156 | |||
157 | /* Stop all preference generations */ | ||
158 | GNUNET_ATS_TEST_generate_preferences_stop_all (); | ||
159 | |||
160 | if (NULL != e) | ||
161 | { | ||
162 | GNUNET_ATS_TEST_experimentation_stop (e); | ||
163 | e = NULL; | ||
164 | } | ||
165 | GNUNET_ATS_TEST_shutdown_topology (); | ||
166 | } | ||
167 | |||
168 | |||
169 | static void | ||
170 | do_timeout (void *cls) | ||
171 | { | ||
172 | timeout_task = NULL; | ||
173 | GNUNET_SCHEDULER_shutdown (); | ||
174 | } | ||
175 | |||
176 | |||
177 | static void | ||
178 | log_request__cb (void *cls, | ||
179 | const struct GNUNET_HELLO_Address *address, | ||
180 | int address_active, | ||
181 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, | ||
182 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, | ||
183 | const struct GNUNET_ATS_Properties *ats) | ||
184 | { | ||
185 | if (NULL != l) | ||
186 | { | ||
187 | // GNUNET_break (0); | ||
188 | // GNUNET_ATS_TEST_logging_now (l); | ||
189 | } | ||
190 | } | ||
191 | |||
192 | |||
193 | static void | ||
194 | experiment_done_cb (struct Experiment *e, | ||
195 | struct GNUNET_TIME_Relative duration, | ||
196 | int success) | ||
197 | { | ||
198 | if (GNUNET_OK == success) | ||
199 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
200 | "Experiment done successful in %s\n", | ||
201 | GNUNET_STRINGS_relative_time_to_string (duration, | ||
202 | GNUNET_YES)); | ||
203 | else | ||
204 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Experiment failed \n"); | ||
205 | |||
206 | /* Stop logging */ | ||
207 | GNUNET_ATS_TEST_logging_stop (l); | ||
208 | |||
209 | /* Stop traffic generation */ | ||
210 | GNUNET_ATS_TEST_generate_traffic_stop_all (); | ||
211 | |||
212 | /* Stop all preference generations */ | ||
213 | GNUNET_ATS_TEST_generate_preferences_stop_all (); | ||
214 | |||
215 | evaluate (duration); | ||
216 | if (opt_log) | ||
217 | GNUNET_ATS_TEST_logging_write_to_file (l, opt_exp_file, opt_plot); | ||
218 | GNUNET_SCHEDULER_shutdown (); | ||
219 | } | ||
220 | |||
221 | |||
222 | static void | ||
223 | episode_done_cb (struct Episode *ep) | ||
224 | { | ||
225 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
226 | "Episode %u done\n", | ||
227 | ep->id); | ||
228 | } | ||
229 | |||
230 | |||
231 | static void | ||
232 | topology_setup_done (void *cls, | ||
233 | struct BenchmarkPeer *masters, | ||
234 | struct BenchmarkPeer *slaves) | ||
235 | { | ||
236 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
237 | "Topology setup complete!\n"); | ||
238 | |||
239 | masters_p = masters; | ||
240 | slaves_p = slaves; | ||
241 | |||
242 | l = GNUNET_ATS_TEST_logging_start (e->log_freq, | ||
243 | e->name, | ||
244 | masters_p, | ||
245 | e->num_masters, e->num_slaves, | ||
246 | opt_verbose); | ||
247 | GNUNET_ATS_TEST_experimentation_run (e, | ||
248 | &episode_done_cb, | ||
249 | &experiment_done_cb); | ||
250 | /* | ||
251 | GNUNET_ATS_TEST_generate_preferences_start(&masters[0],&masters[0].partners[0], | ||
252 | GNUNET_ATS_TEST_TG_CONSTANT, 1, 1, GNUNET_TIME_UNIT_SECONDS, | ||
253 | GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 250), | ||
254 | GNUNET_ATS_PREFERENCE_BANDWIDTH); | ||
255 | *//* | ||
256 | GNUNET_ATS_TEST_generate_preferences_start(&masters[0],&masters[0].partners[0], | ||
257 | GNUNET_ATS_TEST_TG_LINEAR, 1, 50, | ||
258 | GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 2), | ||
259 | GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 250), | ||
260 | GNUNET_ATS_PREFERENCE_BANDWIDTH); | ||
261 | *//* | ||
262 | GNUNET_ATS_TEST_generate_preferences_start(&masters[0],&masters[0].partners[0], | ||
263 | GNUNET_ATS_TEST_TG_RANDOM, 1, 50, | ||
264 | GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 2), | ||
265 | GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 250), | ||
266 | GNUNET_ATS_PREFERENCE_BANDWIDTH); | ||
267 | *//* | ||
268 | GNUNET_ATS_TEST_generate_preferences_start(&masters[0],&masters[0].partners[0], | ||
269 | GNUNET_ATS_TEST_TG_SINUS, 10, 5, | ||
270 | GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 5), | ||
271 | GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 250), | ||
272 | GNUNET_ATS_PREFERENCE_BANDWIDTH); | ||
273 | */ | ||
274 | #if 0 | ||
275 | int c_m; | ||
276 | int c_s; | ||
277 | for (c_m = 0; c_m < e->num_masters; c_m++) | ||
278 | { | ||
279 | for (c_s = 0; c_s < e->num_slaves; c_s++) | ||
280 | { | ||
281 | /* Generate maximum traffic to all peers */ | ||
282 | /* Example: Generate traffic with constant 10,000 Bytes/s */ | ||
283 | GNUNET_ATS_TEST_generate_traffic_start (&masters[c_m], | ||
284 | &masters[c_m].partners[c_s], | ||
285 | GNUNET_ATS_TEST_TG_CONSTANT, | ||
286 | 10000, | ||
287 | GNUNET_TIME_UNIT_FOREVER_REL); | ||
288 | /* Example: Generate traffic with an increasing rate from 1000 to 2000 | ||
289 | * Bytes/s with in a minute */ | ||
290 | GNUNET_ATS_TEST_generate_traffic_start (&masters[c_m], | ||
291 | &masters[c_m].partners[c_s], | ||
292 | GNUNET_ATS_TEST_TG_LINEAR, | ||
293 | 1000, | ||
294 | 2000, | ||
295 | GNUNET_TIME_UNIT_MINUTES, | ||
296 | GNUNET_TIME_UNIT_FOREVER_REL); | ||
297 | /* Example: Generate traffic with a random rate between 1000 to 2000 | ||
298 | * Bytes/s */ | ||
299 | GNUNET_ATS_TEST_generate_traffic_start (&masters[c_m], | ||
300 | &masters[c_m].partners[c_s], | ||
301 | GNUNET_ATS_TEST_TG_RANDOM, | ||
302 | 1000, | ||
303 | 2000, | ||
304 | GNUNET_TIME_UNIT_FOREVER_REL, | ||
305 | GNUNET_TIME_UNIT_FOREVER_REL); | ||
306 | /* Example: Generate traffic with a sinus form, a base rate of | ||
307 | * 1000 Bytes/s, an amplitude of (max-base), and a period of 1 minute */ | ||
308 | GNUNET_ATS_TEST_generate_traffic_start (&masters[c_m], | ||
309 | &masters[c_m].partners[c_s], | ||
310 | GNUNET_ATS_TEST_TG_SINUS, | ||
311 | 1000, | ||
312 | 2000, | ||
313 | GNUNET_TIME_UNIT_MINUTES, | ||
314 | GNUNET_TIME_UNIT_FOREVER_REL); | ||
315 | } | ||
316 | } | ||
317 | #endif | ||
318 | |||
319 | timeout_task | ||
320 | = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_add ( | ||
321 | GNUNET_TIME_UNIT_MINUTES, | ||
322 | e->max_duration), | ||
323 | &do_timeout, | ||
324 | NULL); | ||
325 | GNUNET_SCHEDULER_add_shutdown (&do_shutdown, NULL); | ||
326 | } | ||
327 | |||
328 | |||
329 | static void | ||
330 | parse_args (int argc, char *argv[]) | ||
331 | { | ||
332 | int c; | ||
333 | |||
334 | opt_exp_file = NULL; | ||
335 | opt_log = GNUNET_NO; | ||
336 | opt_plot = GNUNET_NO; | ||
337 | |||
338 | for (c = 0; c < argc; c++) | ||
339 | { | ||
340 | if ((c < (argc - 1)) && (0 == strcmp (argv[c], "-e"))) | ||
341 | { | ||
342 | GNUNET_free (opt_exp_file); | ||
343 | opt_exp_file = GNUNET_strdup (argv[c + 1]); | ||
344 | } | ||
345 | if (0 == strcmp (argv[c], "-l")) | ||
346 | { | ||
347 | opt_log = GNUNET_YES; | ||
348 | } | ||
349 | if (0 == strcmp (argv[c], "-p")) | ||
350 | { | ||
351 | opt_plot = GNUNET_YES; | ||
352 | } | ||
353 | if (0 == strcmp (argv[c], "-v")) | ||
354 | { | ||
355 | opt_verbose = GNUNET_YES; | ||
356 | } | ||
357 | } | ||
358 | } | ||
359 | |||
360 | |||
361 | int | ||
362 | main (int argc, char *argv[]) | ||
363 | { | ||
364 | GNUNET_log_setup ("gnunet-ats-sim", "INFO", NULL); | ||
365 | |||
366 | parse_args (argc, argv); | ||
367 | if (NULL == opt_exp_file) | ||
368 | { | ||
369 | fprintf (stderr, "No experiment given...\n"); | ||
370 | return 1; | ||
371 | } | ||
372 | |||
373 | fprintf (stderr, "Loading experiment `%s' \n", opt_exp_file); | ||
374 | e = GNUNET_ATS_TEST_experimentation_load (opt_exp_file); | ||
375 | if (NULL == e) | ||
376 | { | ||
377 | fprintf (stderr, "Invalid experiment\n"); | ||
378 | return 1; | ||
379 | } | ||
380 | if (0 == e->num_episodes) | ||
381 | { | ||
382 | fprintf (stderr, "No episodes included\n"); | ||
383 | return 1; | ||
384 | } | ||
385 | |||
386 | /* Setup a topology with */ | ||
387 | GNUNET_ATS_TEST_create_topology ("gnunet-ats-sim", e->cfg_file, | ||
388 | e->num_slaves, | ||
389 | e->num_masters, | ||
390 | GNUNET_NO, | ||
391 | &topology_setup_done, | ||
392 | NULL, | ||
393 | &log_request__cb); | ||
394 | GNUNET_free (opt_exp_file); | ||
395 | return 0; | ||
396 | } | ||
397 | |||
398 | |||
399 | /* end of file gnunet-ats-sim.c */ | ||
diff --git a/src/ats-tests/gnunet-solver-eval.c b/src/ats-tests/gnunet-solver-eval.c deleted file mode 100644 index 7a3461bf7..000000000 --- a/src/ats-tests/gnunet-solver-eval.c +++ /dev/null | |||
@@ -1,1025 +0,0 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet. | ||
3 | Copyright (C) 2010-2013 GNUnet e.V. | ||
4 | |||
5 | GNUnet is free software: you can redistribute it and/or modify it | ||
6 | under the terms of the GNU Affero General Public License as published | ||
7 | by the Free Software Foundation, either version 3 of the License, | ||
8 | or (at your option) any later version. | ||
9 | |||
10 | GNUnet is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Affero General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Affero General Public License | ||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | ||
19 | */ | ||
20 | /** | ||
21 | * @file ats-tests/ats-testing-experiment.c | ||
22 | * @brief ats benchmark: controlled experiment execution | ||
23 | * @author Christian Grothoff | ||
24 | * @author Matthias Wachs | ||
25 | */ | ||
26 | #include "platform.h" | ||
27 | #include "gnunet_util_lib.h" | ||
28 | #include "gnunet_ats_plugin.h" | ||
29 | #include "gnunet_ats_service.h" | ||
30 | #include "ats-testing.h" | ||
31 | |||
32 | |||
33 | /** | ||
34 | * Experiments | ||
35 | */ | ||
36 | const char * | ||
37 | print_op (enum OperationType op) | ||
38 | { | ||
39 | switch (op) | ||
40 | { | ||
41 | case START_SEND: | ||
42 | return "START_SEND"; | ||
43 | |||
44 | case STOP_SEND: | ||
45 | return "STOP_SEND"; | ||
46 | |||
47 | case START_PREFERENCE: | ||
48 | return "START_PREFERENCE"; | ||
49 | |||
50 | case STOP_PREFERENCE: | ||
51 | return "STOP_PREFERENCE"; | ||
52 | |||
53 | default: | ||
54 | break; | ||
55 | } | ||
56 | return ""; | ||
57 | } | ||
58 | |||
59 | |||
60 | static struct Experiment * | ||
61 | create_experiment () | ||
62 | { | ||
63 | struct Experiment *e; | ||
64 | |||
65 | e = GNUNET_new (struct Experiment); | ||
66 | e->name = NULL; | ||
67 | e->num_masters = 0; | ||
68 | e->num_slaves = 0; | ||
69 | e->start = NULL; | ||
70 | e->total_duration = GNUNET_TIME_UNIT_ZERO; | ||
71 | return e; | ||
72 | } | ||
73 | |||
74 | |||
75 | static void | ||
76 | free_experiment (struct Experiment *e) | ||
77 | { | ||
78 | struct Episode *cur; | ||
79 | struct Episode *next; | ||
80 | struct GNUNET_ATS_TEST_Operation *cur_o; | ||
81 | struct GNUNET_ATS_TEST_Operation *next_o; | ||
82 | |||
83 | next = e->start; | ||
84 | for (cur = next; NULL != cur; cur = next) | ||
85 | { | ||
86 | next = cur->next; | ||
87 | |||
88 | next_o = cur->head; | ||
89 | for (cur_o = next_o; NULL != cur_o; cur_o = next_o) | ||
90 | { | ||
91 | next_o = cur_o->next; | ||
92 | GNUNET_free (cur_o); | ||
93 | } | ||
94 | GNUNET_free (cur); | ||
95 | } | ||
96 | |||
97 | GNUNET_free (e->name); | ||
98 | GNUNET_free (e->cfg_file); | ||
99 | GNUNET_free (e); | ||
100 | } | ||
101 | |||
102 | |||
103 | static int | ||
104 | load_episode (struct Experiment *e, | ||
105 | struct Episode *cur, | ||
106 | struct GNUNET_CONFIGURATION_Handle *cfg) | ||
107 | { | ||
108 | struct GNUNET_ATS_TEST_Operation *o; | ||
109 | char *sec_name; | ||
110 | char *op_name; | ||
111 | char *op; | ||
112 | char *type; | ||
113 | char *pref; | ||
114 | int op_counter = 0; | ||
115 | |||
116 | fprintf (stderr, "Parsing episode %u\n", cur->id); | ||
117 | GNUNET_asprintf (&sec_name, "episode-%u", cur->id); | ||
118 | |||
119 | while (1) | ||
120 | { | ||
121 | /* Load operation */ | ||
122 | GNUNET_asprintf (&op_name, "op-%u-operation", op_counter); | ||
123 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string (cfg, | ||
124 | sec_name, | ||
125 | op_name, &op)) | ||
126 | { | ||
127 | GNUNET_free (op_name); | ||
128 | break; | ||
129 | } | ||
130 | o = GNUNET_new (struct GNUNET_ATS_TEST_Operation); | ||
131 | /* operations = set_rate, start_send, stop_send, set_preference */ | ||
132 | if (0 == strcmp (op, "start_send")) | ||
133 | { | ||
134 | o->type = START_SEND; | ||
135 | } | ||
136 | else if (0 == strcmp (op, "stop_send")) | ||
137 | { | ||
138 | o->type = STOP_SEND; | ||
139 | } | ||
140 | else if (0 == strcmp (op, "start_preference")) | ||
141 | { | ||
142 | o->type = START_PREFERENCE; | ||
143 | } | ||
144 | else if (0 == strcmp (op, "stop_preference")) | ||
145 | { | ||
146 | o->type = STOP_PREFERENCE; | ||
147 | } | ||
148 | else | ||
149 | { | ||
150 | fprintf (stderr, "Invalid operation %u `%s' in episode %u\n", | ||
151 | op_counter, op, cur->id); | ||
152 | GNUNET_free (op); | ||
153 | GNUNET_free (op_name); | ||
154 | GNUNET_free (sec_name); | ||
155 | GNUNET_free (o); | ||
156 | return GNUNET_SYSERR; | ||
157 | } | ||
158 | GNUNET_free (op_name); | ||
159 | |||
160 | /* Get source */ | ||
161 | GNUNET_asprintf (&op_name, "op-%u-src", op_counter); | ||
162 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (cfg, | ||
163 | sec_name, | ||
164 | op_name, | ||
165 | &o->src_id)) | ||
166 | { | ||
167 | fprintf (stderr, "Missing src in operation %u `%s' in episode %u\n", | ||
168 | op_counter, op, cur->id); | ||
169 | GNUNET_free (op); | ||
170 | GNUNET_free (op_name); | ||
171 | GNUNET_free (sec_name); | ||
172 | GNUNET_free (o); | ||
173 | return GNUNET_SYSERR; | ||
174 | } | ||
175 | if (o->src_id > (e->num_masters - 1)) | ||
176 | { | ||
177 | fprintf (stderr, "Invalid src %llu in operation %u `%s' in episode %u\n", | ||
178 | o->src_id, op_counter, op, cur->id); | ||
179 | GNUNET_free (op); | ||
180 | GNUNET_free (op_name); | ||
181 | GNUNET_free (sec_name); | ||
182 | GNUNET_free (o); | ||
183 | return GNUNET_SYSERR; | ||
184 | } | ||
185 | GNUNET_free (op_name); | ||
186 | |||
187 | /* Get destination */ | ||
188 | GNUNET_asprintf (&op_name, "op-%u-dest", op_counter); | ||
189 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (cfg, | ||
190 | sec_name, | ||
191 | op_name, | ||
192 | &o->dest_id)) | ||
193 | { | ||
194 | fprintf (stderr, "Missing src in operation %u `%s' in episode %u\n", | ||
195 | op_counter, op, cur->id); | ||
196 | GNUNET_free (op); | ||
197 | GNUNET_free (op_name); | ||
198 | GNUNET_free (sec_name); | ||
199 | GNUNET_free (o); | ||
200 | return GNUNET_SYSERR; | ||
201 | } | ||
202 | if (o->dest_id > (e->num_slaves - 1)) | ||
203 | { | ||
204 | fprintf (stderr, | ||
205 | "Invalid destination %llu in operation %u `%s' in episode %u\n", | ||
206 | o->dest_id, | ||
207 | op_counter, | ||
208 | op, | ||
209 | cur->id); | ||
210 | GNUNET_free (op); | ||
211 | GNUNET_free (op_name); | ||
212 | GNUNET_free (sec_name); | ||
213 | GNUNET_free (o); | ||
214 | return GNUNET_SYSERR; | ||
215 | } | ||
216 | GNUNET_free (op_name); | ||
217 | |||
218 | GNUNET_asprintf (&op_name, "op-%u-type", op_counter); | ||
219 | if ((GNUNET_SYSERR != | ||
220 | GNUNET_CONFIGURATION_get_value_string (cfg, | ||
221 | sec_name, | ||
222 | op_name, | ||
223 | &type)) && | ||
224 | (STOP_SEND != o->type) && | ||
225 | (STOP_PREFERENCE != o->type)) | ||
226 | { | ||
227 | /* Load arguments for set_rate, start_send, set_preference */ | ||
228 | if (0 == strcmp (type, "constant")) | ||
229 | { | ||
230 | o->gen_type = GNUNET_ATS_TEST_TG_CONSTANT; | ||
231 | } | ||
232 | else if (0 == strcmp (type, "linear")) | ||
233 | { | ||
234 | o->gen_type = GNUNET_ATS_TEST_TG_LINEAR; | ||
235 | } | ||
236 | else if (0 == strcmp (type, "sinus")) | ||
237 | { | ||
238 | o->gen_type = GNUNET_ATS_TEST_TG_SINUS; | ||
239 | } | ||
240 | else if (0 == strcmp (type, "random")) | ||
241 | { | ||
242 | o->gen_type = GNUNET_ATS_TEST_TG_RANDOM; | ||
243 | } | ||
244 | else | ||
245 | { | ||
246 | fprintf (stderr, "Invalid type %u `%s' in episode %u\n", | ||
247 | op_counter, op, cur->id); | ||
248 | GNUNET_free (type); | ||
249 | GNUNET_free (op); | ||
250 | GNUNET_free (op_name); | ||
251 | GNUNET_free (sec_name); | ||
252 | GNUNET_free (o); | ||
253 | return GNUNET_SYSERR; | ||
254 | } | ||
255 | GNUNET_free (op_name); | ||
256 | |||
257 | /* Get base rate */ | ||
258 | GNUNET_asprintf (&op_name, "op-%u-base-rate", op_counter); | ||
259 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (cfg, | ||
260 | sec_name, | ||
261 | op_name, | ||
262 | &o->base_rate)) | ||
263 | { | ||
264 | fprintf (stderr, | ||
265 | "Missing base rate in operation %u `%s' in episode %u\n", | ||
266 | op_counter, op, cur->id); | ||
267 | GNUNET_free (type); | ||
268 | GNUNET_free (op); | ||
269 | GNUNET_free (op_name); | ||
270 | GNUNET_free (sec_name); | ||
271 | GNUNET_free (o); | ||
272 | return GNUNET_SYSERR; | ||
273 | } | ||
274 | GNUNET_free (op_name); | ||
275 | |||
276 | /* Get max rate */ | ||
277 | GNUNET_asprintf (&op_name, "op-%u-max-rate", op_counter); | ||
278 | if (GNUNET_SYSERR == | ||
279 | GNUNET_CONFIGURATION_get_value_number (cfg, | ||
280 | sec_name, | ||
281 | op_name, | ||
282 | &o->max_rate)) | ||
283 | { | ||
284 | if ((GNUNET_ATS_TEST_TG_LINEAR == o->gen_type) || | ||
285 | (GNUNET_ATS_TEST_TG_RANDOM == o->gen_type) || | ||
286 | (GNUNET_ATS_TEST_TG_SINUS == o->gen_type)) | ||
287 | { | ||
288 | fprintf (stderr, | ||
289 | "Missing max rate in operation %u `%s' in episode %u\n", | ||
290 | op_counter, op, cur->id); | ||
291 | GNUNET_free (type); | ||
292 | GNUNET_free (op_name); | ||
293 | GNUNET_free (op); | ||
294 | GNUNET_free (sec_name); | ||
295 | GNUNET_free (o); | ||
296 | return GNUNET_SYSERR; | ||
297 | } | ||
298 | } | ||
299 | GNUNET_free (op_name); | ||
300 | |||
301 | /* Get period */ | ||
302 | GNUNET_asprintf (&op_name, "op-%u-period", op_counter); | ||
303 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_time (cfg, | ||
304 | sec_name, | ||
305 | op_name, | ||
306 | &o->period)) | ||
307 | { | ||
308 | o->period = cur->duration; | ||
309 | } | ||
310 | GNUNET_free (op_name); | ||
311 | |||
312 | if (START_PREFERENCE == o->type) | ||
313 | { | ||
314 | /* Get frequency */ | ||
315 | GNUNET_asprintf (&op_name, "op-%u-frequency", op_counter); | ||
316 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_time (cfg, | ||
317 | sec_name, | ||
318 | op_name, | ||
319 | &o->frequency)) | ||
320 | { | ||
321 | fprintf (stderr, | ||
322 | "Missing frequency in operation %u `%s' in episode %u\n", | ||
323 | op_counter, op, cur->id); | ||
324 | GNUNET_free (type); | ||
325 | GNUNET_free (op_name); | ||
326 | GNUNET_free (op); | ||
327 | GNUNET_free (sec_name); | ||
328 | GNUNET_free (o); | ||
329 | return GNUNET_SYSERR; | ||
330 | } | ||
331 | GNUNET_free (op_name); | ||
332 | |||
333 | /* Get preference */ | ||
334 | GNUNET_asprintf (&op_name, "op-%u-pref", op_counter); | ||
335 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string (cfg, | ||
336 | sec_name, | ||
337 | op_name, | ||
338 | &pref)) | ||
339 | { | ||
340 | fprintf (stderr, | ||
341 | "Missing preference in operation %u `%s' in episode %u\n", | ||
342 | op_counter, op, cur->id); | ||
343 | GNUNET_free (type); | ||
344 | GNUNET_free (op_name); | ||
345 | GNUNET_free (op); | ||
346 | GNUNET_free (sec_name); | ||
347 | GNUNET_free (pref); | ||
348 | GNUNET_free (o); | ||
349 | return GNUNET_SYSERR; | ||
350 | } | ||
351 | |||
352 | if (0 == strcmp (pref, "bandwidth")) | ||
353 | o->pref_type = GNUNET_ATS_PREFERENCE_BANDWIDTH; | ||
354 | else if (0 == strcmp (pref, "latency")) | ||
355 | o->pref_type = GNUNET_ATS_PREFERENCE_LATENCY; | ||
356 | else | ||
357 | { | ||
358 | fprintf (stderr, | ||
359 | "Invalid preference in operation %u `%s' in episode %u\n", | ||
360 | op_counter, | ||
361 | op, | ||
362 | cur->id); | ||
363 | GNUNET_free (type); | ||
364 | GNUNET_free (op_name); | ||
365 | GNUNET_free (op); | ||
366 | GNUNET_free (sec_name); | ||
367 | GNUNET_free (pref); | ||
368 | GNUNET_free (o); | ||
369 | return GNUNET_SYSERR; | ||
370 | } | ||
371 | GNUNET_free (pref); | ||
372 | GNUNET_free (op_name); | ||
373 | } | ||
374 | } | ||
375 | |||
376 | /* Safety checks */ | ||
377 | if ((GNUNET_ATS_TEST_TG_LINEAR == o->gen_type) || | ||
378 | (GNUNET_ATS_TEST_TG_SINUS == o->gen_type)) | ||
379 | { | ||
380 | if ((o->max_rate - o->base_rate) > o->base_rate) | ||
381 | { | ||
382 | /* This will cause an underflow */ | ||
383 | GNUNET_break (0); | ||
384 | } | ||
385 | fprintf (stderr, | ||
386 | "Selected max rate and base rate cannot be used for desired traffic form!\n"); | ||
387 | } | ||
388 | |||
389 | if ((START_SEND == o->type) || (START_PREFERENCE == o->type)) | ||
390 | fprintf (stderr, | ||
391 | "Found operation %u in episode %u: %s [%llu]->[%llu] == %s, %llu -> %llu in %s\n", | ||
392 | op_counter, cur->id, print_op (o->type), o->src_id, | ||
393 | o->dest_id, (NULL != type) ? type : "", | ||
394 | o->base_rate, o->max_rate, | ||
395 | GNUNET_STRINGS_relative_time_to_string (o->period, GNUNET_YES)); | ||
396 | else | ||
397 | fprintf (stderr, "Found operation %u in episode %u: %s [%llu]->[%llu]\n", | ||
398 | op_counter, cur->id, print_op (o->type), o->src_id, o->dest_id); | ||
399 | |||
400 | GNUNET_free (type); | ||
401 | GNUNET_free (op); | ||
402 | |||
403 | GNUNET_CONTAINER_DLL_insert (cur->head, cur->tail, o); | ||
404 | op_counter++; | ||
405 | } | ||
406 | GNUNET_free (sec_name); | ||
407 | |||
408 | return GNUNET_OK; | ||
409 | } | ||
410 | |||
411 | |||
412 | static int | ||
413 | load_episodes (struct Experiment *e, struct GNUNET_CONFIGURATION_Handle *cfg) | ||
414 | { | ||
415 | int e_counter = 0; | ||
416 | char *sec_name; | ||
417 | struct GNUNET_TIME_Relative e_duration; | ||
418 | struct Episode *cur; | ||
419 | struct Episode *last; | ||
420 | |||
421 | e_counter = 0; | ||
422 | last = NULL; | ||
423 | while (1) | ||
424 | { | ||
425 | GNUNET_asprintf (&sec_name, "episode-%u", e_counter); | ||
426 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_time (cfg, | ||
427 | sec_name, | ||
428 | "duration", | ||
429 | &e_duration)) | ||
430 | { | ||
431 | GNUNET_free (sec_name); | ||
432 | break; | ||
433 | } | ||
434 | |||
435 | cur = GNUNET_new (struct Episode); | ||
436 | cur->duration = e_duration; | ||
437 | cur->id = e_counter; | ||
438 | |||
439 | if (GNUNET_OK != load_episode (e, cur, cfg)) | ||
440 | { | ||
441 | GNUNET_free (sec_name); | ||
442 | GNUNET_free (cur); | ||
443 | return GNUNET_SYSERR; | ||
444 | } | ||
445 | |||
446 | fprintf (stderr, "Found episode %u with duration %s \n", | ||
447 | e_counter, | ||
448 | GNUNET_STRINGS_relative_time_to_string (cur->duration, | ||
449 | GNUNET_YES)); | ||
450 | |||
451 | /* Update experiment */ | ||
452 | e->num_episodes++; | ||
453 | e->total_duration = GNUNET_TIME_relative_add (e->total_duration, | ||
454 | cur->duration); | ||
455 | /* Put in linked list */ | ||
456 | if (NULL == last) | ||
457 | e->start = cur; | ||
458 | else | ||
459 | last->next = cur; | ||
460 | |||
461 | GNUNET_free (sec_name); | ||
462 | e_counter++; | ||
463 | last = cur; | ||
464 | } | ||
465 | return e_counter; | ||
466 | } | ||
467 | |||
468 | |||
469 | static void | ||
470 | timeout_experiment (void *cls) | ||
471 | { | ||
472 | struct Experiment *e = cls; | ||
473 | |||
474 | e->experiment_timeout_task = NULL; | ||
475 | fprintf (stderr, "Experiment timeout!\n"); | ||
476 | |||
477 | if (NULL != e->episode_timeout_task) | ||
478 | { | ||
479 | GNUNET_SCHEDULER_cancel (e->episode_timeout_task); | ||
480 | e->episode_timeout_task = NULL; | ||
481 | } | ||
482 | |||
483 | e->e_done_cb (e, GNUNET_TIME_absolute_get_duration (e->start_time), | ||
484 | GNUNET_SYSERR); | ||
485 | } | ||
486 | |||
487 | |||
488 | static void | ||
489 | enforce_start_send (struct GNUNET_ATS_TEST_Operation *op) | ||
490 | { | ||
491 | /* | ||
492 | struct BenchmarkPeer *peer; | ||
493 | struct BenchmarkPartner *partner; | ||
494 | |||
495 | peer = GNUNET_ATS_TEST_get_peer (op->src_id); | ||
496 | if (NULL == peer) | ||
497 | { | ||
498 | GNUNET_break (0); | ||
499 | return; | ||
500 | } | ||
501 | |||
502 | partner = GNUNET_ATS_TEST_get_partner (op->src_id, op->dest_id); | ||
503 | if (NULL == partner) | ||
504 | { | ||
505 | GNUNET_break (0); | ||
506 | return; | ||
507 | } | ||
508 | |||
509 | fprintf (stderr, "Found master %llu slave %llu\n",op->src_id, op->dest_id); | ||
510 | |||
511 | if (NULL != partner->tg) | ||
512 | { | ||
513 | fprintf (stderr, "Stopping traffic between master %llu slave %llu\n",op->src_id, op->dest_id); | ||
514 | GNUNET_ATS_TEST_generate_traffic_stop(partner->tg); | ||
515 | partner->tg = NULL; | ||
516 | } | ||
517 | |||
518 | partner->tg = GNUNET_ATS_TEST_generate_traffic_start(peer, partner, | ||
519 | op->tg_type, op->base_rate, op->max_rate, op->period, | ||
520 | GNUNET_TIME_UNIT_FOREVER_REL); | ||
521 | */} | ||
522 | |||
523 | |||
524 | static void | ||
525 | enforce_stop_send (struct GNUNET_ATS_TEST_Operation *op) | ||
526 | { | ||
527 | /* | ||
528 | struct BenchmarkPartner *p; | ||
529 | p = GNUNET_ATS_TEST_get_partner (op->src_id, op->dest_id); | ||
530 | if (NULL == p) | ||
531 | { | ||
532 | GNUNET_break (0); | ||
533 | return; | ||
534 | } | ||
535 | |||
536 | fprintf (stderr, "Found master %llu slave %llu\n",op->src_id, op->dest_id); | ||
537 | |||
538 | if (NULL != p->tg) | ||
539 | { | ||
540 | fprintf (stderr, "Stopping traffic between master %llu slave %llu\n", | ||
541 | op->src_id, op->dest_id); | ||
542 | GNUNET_ATS_TEST_generate_traffic_stop(p->tg); | ||
543 | p->tg = NULL; | ||
544 | } | ||
545 | */} | ||
546 | |||
547 | |||
548 | static void | ||
549 | enforce_start_preference (struct GNUNET_ATS_TEST_Operation *op) | ||
550 | { | ||
551 | /* | ||
552 | struct BenchmarkPeer *peer; | ||
553 | struct BenchmarkPartner *partner; | ||
554 | |||
555 | peer = GNUNET_ATS_TEST_get_peer (op->src_id); | ||
556 | if (NULL == peer) | ||
557 | { | ||
558 | GNUNET_break (0); | ||
559 | return; | ||
560 | } | ||
561 | |||
562 | partner = GNUNET_ATS_TEST_get_partner (op->src_id, op->dest_id); | ||
563 | if (NULL == partner) | ||
564 | { | ||
565 | GNUNET_break (0); | ||
566 | return; | ||
567 | } | ||
568 | |||
569 | fprintf (stderr, "Found master %llu slave %llu\n",op->src_id, op->dest_id); | ||
570 | |||
571 | if (NULL != partner->pg) | ||
572 | { | ||
573 | fprintf (stderr, "Stopping traffic between master %llu slave %llu\n", | ||
574 | op->src_id, op->dest_id); | ||
575 | GNUNET_ATS_TEST_generate_preferences_stop(partner->pg); | ||
576 | partner->pg = NULL; | ||
577 | } | ||
578 | |||
579 | partner->pg = GNUNET_ATS_TEST_generate_preferences_start(peer, partner, | ||
580 | op->tg_type, op->base_rate, op->max_rate, op->period, op->frequency, | ||
581 | op->pref_type); | ||
582 | */} | ||
583 | |||
584 | |||
585 | static void | ||
586 | enforce_stop_preference (struct GNUNET_ATS_TEST_Operation *op) | ||
587 | { | ||
588 | /* | ||
589 | struct BenchmarkPartner *p; | ||
590 | p = GNUNET_ATS_TEST_get_partner (op->src_id, op->dest_id); | ||
591 | if (NULL == p) | ||
592 | { | ||
593 | GNUNET_break (0); | ||
594 | return; | ||
595 | } | ||
596 | |||
597 | fprintf (stderr, "Found master %llu slave %llu\n",op->src_id, op->dest_id); | ||
598 | |||
599 | if (NULL != p->pg) | ||
600 | { | ||
601 | fprintf (stderr, "Stopping preference between master %llu slave %llu\n", | ||
602 | op->src_id, op->dest_id); | ||
603 | GNUNET_ATS_TEST_generate_preferences_stop (p->pg); | ||
604 | p->pg = NULL; | ||
605 | } | ||
606 | */} | ||
607 | |||
608 | |||
609 | static void | ||
610 | enforce_episode (struct Episode *ep) | ||
611 | { | ||
612 | struct GNUNET_ATS_TEST_Operation *cur; | ||
613 | |||
614 | for (cur = ep->head; NULL != cur; cur = cur->next) | ||
615 | { | ||
616 | fprintf (stderr, "Enforcing operation: %s [%llu]->[%llu] == %llu\n", | ||
617 | print_op (cur->type), cur->src_id, cur->dest_id, cur->base_rate); | ||
618 | switch (cur->type) | ||
619 | { | ||
620 | case START_SEND: | ||
621 | enforce_start_send (cur); | ||
622 | break; | ||
623 | |||
624 | case STOP_SEND: | ||
625 | enforce_stop_send (cur); | ||
626 | break; | ||
627 | |||
628 | case START_PREFERENCE: | ||
629 | enforce_start_preference (cur); | ||
630 | break; | ||
631 | |||
632 | case STOP_PREFERENCE: | ||
633 | enforce_stop_preference (cur); | ||
634 | break; | ||
635 | |||
636 | default: | ||
637 | break; | ||
638 | } | ||
639 | } | ||
640 | } | ||
641 | |||
642 | |||
643 | static void | ||
644 | timeout_episode (void *cls) | ||
645 | { | ||
646 | struct Experiment *e = cls; | ||
647 | |||
648 | e->episode_timeout_task = NULL; | ||
649 | if (NULL != e->ep_done_cb) | ||
650 | e->ep_done_cb (e->cur); | ||
651 | |||
652 | /* Scheduling next */ | ||
653 | e->cur = e->cur->next; | ||
654 | if (NULL == e->cur) | ||
655 | { | ||
656 | /* done */ | ||
657 | fprintf (stderr, "Last episode done!\n"); | ||
658 | if (NULL != e->experiment_timeout_task) | ||
659 | { | ||
660 | GNUNET_SCHEDULER_cancel (e->experiment_timeout_task); | ||
661 | e->experiment_timeout_task = NULL; | ||
662 | } | ||
663 | e->e_done_cb (e, GNUNET_TIME_absolute_get_duration (e->start_time), | ||
664 | GNUNET_OK); | ||
665 | return; | ||
666 | } | ||
667 | |||
668 | fprintf (stderr, "Running episode %u with timeout %s\n", | ||
669 | e->cur->id, | ||
670 | GNUNET_STRINGS_relative_time_to_string (e->cur->duration, | ||
671 | GNUNET_YES)); | ||
672 | enforce_episode (e->cur); | ||
673 | |||
674 | e->episode_timeout_task = GNUNET_SCHEDULER_add_delayed (e->cur->duration, | ||
675 | &timeout_episode, e); | ||
676 | } | ||
677 | |||
678 | |||
679 | void | ||
680 | GNUNET_ATS_solvers_experimentation_run (struct Experiment *e, | ||
681 | GNUNET_ATS_TESTING_EpisodeDoneCallback | ||
682 | ep_done_cb, | ||
683 | GNUNET_ATS_TESTING_ExperimentDoneCallback | ||
684 | e_done_cb) | ||
685 | { | ||
686 | fprintf (stderr, "Running experiment `%s' with timeout %s\n", e->name, | ||
687 | GNUNET_STRINGS_relative_time_to_string (e->max_duration, | ||
688 | GNUNET_YES)); | ||
689 | e->e_done_cb = e_done_cb; | ||
690 | e->ep_done_cb = ep_done_cb; | ||
691 | e->start_time = GNUNET_TIME_absolute_get (); | ||
692 | |||
693 | /* Start total time out */ | ||
694 | e->experiment_timeout_task = GNUNET_SCHEDULER_add_delayed (e->max_duration, | ||
695 | &timeout_experiment, | ||
696 | e); | ||
697 | |||
698 | /* Start */ | ||
699 | e->cur = e->start; | ||
700 | fprintf (stderr, "Running episode %u with timeout %s\n", | ||
701 | e->cur->id, | ||
702 | GNUNET_STRINGS_relative_time_to_string (e->cur->duration, | ||
703 | GNUNET_YES)); | ||
704 | enforce_episode (e->cur); | ||
705 | e->episode_timeout_task = GNUNET_SCHEDULER_add_delayed (e->cur->duration, | ||
706 | &timeout_episode, e); | ||
707 | } | ||
708 | |||
709 | |||
710 | struct Experiment * | ||
711 | GNUNET_ATS_solvers_experimentation_load (char *filename) | ||
712 | { | ||
713 | struct Experiment *e; | ||
714 | struct GNUNET_CONFIGURATION_Handle *cfg; | ||
715 | |||
716 | e = NULL; | ||
717 | |||
718 | cfg = GNUNET_CONFIGURATION_create (); | ||
719 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_load (cfg, filename)) | ||
720 | { | ||
721 | fprintf (stderr, "Failed to load `%s'\n", filename); | ||
722 | GNUNET_CONFIGURATION_destroy (cfg); | ||
723 | return NULL; | ||
724 | } | ||
725 | |||
726 | e = create_experiment (); | ||
727 | |||
728 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string (cfg, "experiment", | ||
729 | "name", &e->name)) | ||
730 | { | ||
731 | fprintf (stderr, "Invalid %s", "name"); | ||
732 | free_experiment (e); | ||
733 | return NULL; | ||
734 | } | ||
735 | else | ||
736 | fprintf (stderr, "Experiment name: `%s'\n", e->name); | ||
737 | |||
738 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_filename (cfg, | ||
739 | "experiment", | ||
740 | "cfg_file", | ||
741 | &e->cfg_file)) | ||
742 | { | ||
743 | fprintf (stderr, "Invalid %s", "cfg_file"); | ||
744 | free_experiment (e); | ||
745 | return NULL; | ||
746 | } | ||
747 | else | ||
748 | fprintf (stderr, "Experiment name: `%s'\n", e->cfg_file); | ||
749 | |||
750 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (cfg, "experiment", | ||
751 | "masters", | ||
752 | &e->num_masters)) | ||
753 | { | ||
754 | fprintf (stderr, "Invalid %s", "masters"); | ||
755 | free_experiment (e); | ||
756 | return NULL; | ||
757 | } | ||
758 | else | ||
759 | fprintf (stderr, "Experiment masters: `%llu'\n", | ||
760 | e->num_masters); | ||
761 | |||
762 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (cfg, "experiment", | ||
763 | "slaves", | ||
764 | &e->num_slaves)) | ||
765 | { | ||
766 | fprintf (stderr, "Invalid %s", "slaves"); | ||
767 | free_experiment (e); | ||
768 | return NULL; | ||
769 | } | ||
770 | else | ||
771 | fprintf (stderr, "Experiment slaves: `%llu'\n", | ||
772 | e->num_slaves); | ||
773 | |||
774 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_time (cfg, "experiment", | ||
775 | "log_freq", | ||
776 | &e->log_freq)) | ||
777 | { | ||
778 | fprintf (stderr, "Invalid %s", "log_freq"); | ||
779 | free_experiment (e); | ||
780 | return NULL; | ||
781 | } | ||
782 | else | ||
783 | fprintf (stderr, "Experiment logging frequency: `%s'\n", | ||
784 | GNUNET_STRINGS_relative_time_to_string (e->log_freq, GNUNET_YES)); | ||
785 | |||
786 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_time (cfg, "experiment", | ||
787 | "max_duration", | ||
788 | &e->max_duration)) | ||
789 | { | ||
790 | fprintf (stderr, "Invalid %s", "max_duration"); | ||
791 | free_experiment (e); | ||
792 | return NULL; | ||
793 | } | ||
794 | else | ||
795 | fprintf (stderr, "Experiment duration: `%s'\n", | ||
796 | GNUNET_STRINGS_relative_time_to_string (e->max_duration, | ||
797 | GNUNET_YES)); | ||
798 | |||
799 | load_episodes (e, cfg); | ||
800 | fprintf (stderr, "Loaded %u episodes with total duration %s\n", | ||
801 | e->num_episodes, | ||
802 | GNUNET_STRINGS_relative_time_to_string (e->total_duration, | ||
803 | GNUNET_YES)); | ||
804 | |||
805 | GNUNET_CONFIGURATION_destroy (cfg); | ||
806 | return e; | ||
807 | } | ||
808 | |||
809 | |||
810 | void | ||
811 | GNUNET_ATS_solvers_experimentation_stop (struct Experiment *e) | ||
812 | { | ||
813 | if (NULL != e->experiment_timeout_task) | ||
814 | { | ||
815 | GNUNET_SCHEDULER_cancel (e->experiment_timeout_task); | ||
816 | e->experiment_timeout_task = NULL; | ||
817 | } | ||
818 | if (NULL != e->episode_timeout_task) | ||
819 | { | ||
820 | GNUNET_SCHEDULER_cancel (e->episode_timeout_task); | ||
821 | e->episode_timeout_task = NULL; | ||
822 | } | ||
823 | free_experiment (e); | ||
824 | } | ||
825 | |||
826 | |||
827 | /** | ||
828 | * Solver | ||
829 | */ | ||
830 | |||
831 | struct GNUNET_ATS_TESTING_SolverHandle | ||
832 | { | ||
833 | char *plugin; | ||
834 | struct GNUNET_ATS_PluginEnvironment env; | ||
835 | void *solver; | ||
836 | }; | ||
837 | |||
838 | enum GNUNET_ATS_Solvers | ||
839 | { | ||
840 | GNUNET_ATS_SOLVER_PROPORTIONAL, | ||
841 | GNUNET_ATS_SOLVER_MLP, | ||
842 | GNUNET_ATS_SOLVER_RIL, | ||
843 | }; | ||
844 | |||
845 | void | ||
846 | GNUNET_ATS_solvers_solver_stop (struct GNUNET_ATS_TESTING_SolverHandle *sh) | ||
847 | { | ||
848 | GNUNET_PLUGIN_unload (sh->plugin, sh->solver); | ||
849 | GNUNET_free (sh->plugin); | ||
850 | GNUNET_free (sh); | ||
851 | } | ||
852 | |||
853 | |||
854 | struct GNUNET_ATS_TESTING_SolverHandle * | ||
855 | GNUNET_ATS_solvers_solver_start (enum GNUNET_ATS_Solvers type) | ||
856 | { | ||
857 | struct GNUNET_ATS_TESTING_SolverHandle *sh; | ||
858 | char *solver_str; | ||
859 | |||
860 | switch (type) | ||
861 | { | ||
862 | case GNUNET_ATS_SOLVER_PROPORTIONAL: | ||
863 | solver_str = "proportional"; | ||
864 | break; | ||
865 | |||
866 | case GNUNET_ATS_SOLVER_MLP: | ||
867 | solver_str = "mlp"; | ||
868 | break; | ||
869 | |||
870 | case GNUNET_ATS_SOLVER_RIL: | ||
871 | solver_str = "ril"; | ||
872 | break; | ||
873 | |||
874 | default: | ||
875 | GNUNET_break (0); | ||
876 | return NULL; | ||
877 | break; | ||
878 | } | ||
879 | |||
880 | sh = GNUNET_new (struct GNUNET_ATS_TESTING_SolverHandle); | ||
881 | GNUNET_asprintf (&sh->plugin, "libgnunet_plugin_ats_%s", solver_str); | ||
882 | // sh->solver = GNUNET_PLUGIN_load (sh->plugin, &sh->env); | ||
883 | if (NULL == sh->solver) | ||
884 | { | ||
885 | fprintf (stderr, "Failed to load solver `%s'\n", sh->plugin); | ||
886 | exit (1); | ||
887 | } | ||
888 | |||
889 | return sh; | ||
890 | } | ||
891 | |||
892 | |||
893 | static struct Experiment *e; | ||
894 | |||
895 | static struct GNUNET_ATS_TESTING_SolverHandle *sh; | ||
896 | |||
897 | /** | ||
898 | * cmd option -e: experiment file | ||
899 | */ | ||
900 | static char *opt_exp_file; | ||
901 | |||
902 | static char *opt_solver; | ||
903 | |||
904 | /** | ||
905 | * cmd option -l: enable logging | ||
906 | */ | ||
907 | static int opt_log; | ||
908 | |||
909 | /** | ||
910 | * cmd option -p: enable plots | ||
911 | */ | ||
912 | static int opt_plot; | ||
913 | |||
914 | /** | ||
915 | * cmd option -v: verbose logs | ||
916 | */ | ||
917 | static int opt_verbose; | ||
918 | |||
919 | static void | ||
920 | run (void *cls, char *const *args, const char *cfgfile, | ||
921 | const struct GNUNET_CONFIGURATION_Handle *cfg) | ||
922 | { | ||
923 | enum GNUNET_ATS_Solvers solver; | ||
924 | |||
925 | if (NULL == opt_exp_file) | ||
926 | { | ||
927 | fprintf (stderr, "No experiment given ...\n"); | ||
928 | exit (1); | ||
929 | } | ||
930 | |||
931 | if (NULL == opt_solver) | ||
932 | { | ||
933 | fprintf (stderr, "No solver given ...\n"); | ||
934 | exit (1); | ||
935 | } | ||
936 | |||
937 | if (0 == strcmp (opt_solver, "mlp")) | ||
938 | { | ||
939 | solver = GNUNET_ATS_SOLVER_MLP; | ||
940 | } | ||
941 | else if (0 == strcmp (opt_solver, "proportional")) | ||
942 | { | ||
943 | solver = GNUNET_ATS_SOLVER_PROPORTIONAL; | ||
944 | } | ||
945 | else if (0 == strcmp (opt_solver, "ril")) | ||
946 | { | ||
947 | solver = GNUNET_ATS_SOLVER_RIL; | ||
948 | } | ||
949 | else | ||
950 | { | ||
951 | fprintf (stderr, "No solver given ..."); | ||
952 | return; | ||
953 | } | ||
954 | |||
955 | /* load experiment */ | ||
956 | e = GNUNET_ATS_solvers_experimentation_load (opt_exp_file); | ||
957 | if (NULL == e) | ||
958 | { | ||
959 | fprintf (stderr, "Failed to load experiment ...\n"); | ||
960 | return; | ||
961 | } | ||
962 | |||
963 | /* load solver */ | ||
964 | sh = GNUNET_ATS_solvers_solver_start (solver); | ||
965 | if (NULL == sh) | ||
966 | { | ||
967 | fprintf (stderr, "Failed to start solver ...\n"); | ||
968 | return; | ||
969 | } | ||
970 | |||
971 | /* start logging */ | ||
972 | |||
973 | /* run experiment */ | ||
974 | |||
975 | /* WAIT */ | ||
976 | } | ||
977 | |||
978 | |||
979 | /** | ||
980 | * Main function of the benchmark | ||
981 | * | ||
982 | * @param argc argument count | ||
983 | * @param argv argument values | ||
984 | */ | ||
985 | int | ||
986 | main (int argc, char *argv[]) | ||
987 | { | ||
988 | opt_exp_file = NULL; | ||
989 | opt_solver = NULL; | ||
990 | opt_log = GNUNET_NO; | ||
991 | opt_plot = GNUNET_NO; | ||
992 | |||
993 | struct GNUNET_GETOPT_CommandLineOption options[] = { | ||
994 | GNUNET_GETOPT_option_string ('s', | ||
995 | "solver", | ||
996 | NULL, | ||
997 | gettext_noop ("solver to use"), | ||
998 | &opt_solver), | ||
999 | |||
1000 | GNUNET_GETOPT_option_string ('e', | ||
1001 | "experiment", | ||
1002 | NULL, | ||
1003 | gettext_noop ("experiment to use"), | ||
1004 | &opt_exp_file), | ||
1005 | |||
1006 | GNUNET_GETOPT_option_flag ('e', | ||
1007 | "experiment", | ||
1008 | gettext_noop ("experiment to use"), | ||
1009 | &opt_verbose), | ||
1010 | GNUNET_GETOPT_OPTION_END | ||
1011 | }; | ||
1012 | |||
1013 | if (GNUNET_OK != | ||
1014 | GNUNET_PROGRAM_run (argc, | ||
1015 | argv, argv[0], | ||
1016 | NULL, | ||
1017 | options, | ||
1018 | &run, argv[0])) | ||
1019 | return 1; | ||
1020 | |||
1021 | return 0; | ||
1022 | } | ||
1023 | |||
1024 | |||
1025 | /* end of file gnunet-solver-eval.c*/ | ||
diff --git a/src/ats-tests/gnunet_ats_sim_default.conf b/src/ats-tests/gnunet_ats_sim_default.conf deleted file mode 100644 index a838306c3..000000000 --- a/src/ats-tests/gnunet_ats_sim_default.conf +++ /dev/null | |||
@@ -1,6 +0,0 @@ | |||
1 | @INLINE@ template_perf_ats.conf | ||
2 | [transport] | ||
3 | plugins = unix | ||
4 | |||
5 | [ats] | ||
6 | MODE = proportional | ||
diff --git a/src/ats-tests/perf_ats.c b/src/ats-tests/perf_ats.c deleted file mode 100644 index 64756b8aa..000000000 --- a/src/ats-tests/perf_ats.c +++ /dev/null | |||
@@ -1,601 +0,0 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet. | ||
3 | Copyright (C) 2010-2013, 2016 GNUnet e.V. | ||
4 | |||
5 | GNUnet is free software: you can redistribute it and/or modify it | ||
6 | under the terms of the GNU Affero General Public License as published | ||
7 | by the Free Software Foundation, either version 3 of the License, | ||
8 | or (at your option) any later version. | ||
9 | |||
10 | GNUnet is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Affero General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Affero General Public License | ||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | ||
19 | */ | ||
20 | /** | ||
21 | * @file ats/perf_ats.c | ||
22 | * @brief ats benchmark: start peers and modify preferences, monitor change over time | ||
23 | * @author Christian Grothoff | ||
24 | * @author Matthias Wachs | ||
25 | */ | ||
26 | #include "platform.h" | ||
27 | #include "gnunet_util_lib.h" | ||
28 | #include "gnunet_testbed_service.h" | ||
29 | #include "gnunet_ats_service.h" | ||
30 | #include "gnunet_core_service.h" | ||
31 | #include "ats-testing.h" | ||
32 | |||
33 | |||
34 | #define TEST_ATS_PREFRENCE_FREQUENCY GNUNET_TIME_relative_multiply ( \ | ||
35 | GNUNET_TIME_UNIT_SECONDS, 1) | ||
36 | #define TEST_ATS_PREFRENCE_START 1.0 | ||
37 | #define TEST_ATS_PREFRENCE_DELTA 1.0 | ||
38 | |||
39 | #define TEST_MESSAGE_FREQUENCY GNUNET_TIME_relative_multiply ( \ | ||
40 | GNUNET_TIME_UNIT_SECONDS, 1) | ||
41 | |||
42 | #define TEST_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, \ | ||
43 | 120) | ||
44 | #define BENCHMARK_DURATION GNUNET_TIME_relative_multiply ( \ | ||
45 | GNUNET_TIME_UNIT_SECONDS, 10) | ||
46 | #define LOGGING_FREQUENCY GNUNET_TIME_relative_multiply ( \ | ||
47 | GNUNET_TIME_UNIT_MILLISECONDS, 500) | ||
48 | #define TESTNAME_PREFIX "perf_ats_" | ||
49 | #define DEFAULT_SLAVES_NUM 2 | ||
50 | #define DEFAULT_MASTERS_NUM 1 | ||
51 | |||
52 | /** | ||
53 | * timeout task | ||
54 | */ | ||
55 | static struct GNUNET_SCHEDULER_Task *timeout_task; | ||
56 | |||
57 | /** | ||
58 | * Progress task | ||
59 | */ | ||
60 | static struct GNUNET_SCHEDULER_Task *progress_task; | ||
61 | |||
62 | /** | ||
63 | * Test result | ||
64 | */ | ||
65 | static int result; | ||
66 | |||
67 | /** | ||
68 | * Test result logging | ||
69 | */ | ||
70 | static int logging; | ||
71 | |||
72 | /** | ||
73 | * Test core (#GNUNET_YES) or transport (#GNUNET_NO) | ||
74 | */ | ||
75 | static int test_core; | ||
76 | |||
77 | /** | ||
78 | * Solver string | ||
79 | */ | ||
80 | static char *solver; | ||
81 | |||
82 | /** | ||
83 | * Preference string | ||
84 | */ | ||
85 | static char *testname; | ||
86 | |||
87 | /** | ||
88 | * Preference string | ||
89 | */ | ||
90 | static char *pref_str; | ||
91 | |||
92 | /** | ||
93 | * ATS preference value | ||
94 | */ | ||
95 | static int pref_val; | ||
96 | |||
97 | /** | ||
98 | * Benchmark duration | ||
99 | */ | ||
100 | static struct GNUNET_TIME_Relative perf_duration; | ||
101 | |||
102 | /** | ||
103 | * Logging frequency | ||
104 | */ | ||
105 | static struct GNUNET_TIME_Relative log_frequency; | ||
106 | |||
107 | /** | ||
108 | * Number master peers | ||
109 | */ | ||
110 | static unsigned int num_masters; | ||
111 | |||
112 | /** | ||
113 | * Array of master peers | ||
114 | */ | ||
115 | static struct BenchmarkPeer *mps; | ||
116 | |||
117 | /** | ||
118 | * Number slave peers | ||
119 | */ | ||
120 | static unsigned int num_slaves; | ||
121 | |||
122 | /** | ||
123 | * Array of master peers | ||
124 | */ | ||
125 | static struct BenchmarkPeer *sps; | ||
126 | |||
127 | static struct LoggingHandle *l; | ||
128 | |||
129 | |||
130 | static void | ||
131 | evaluate () | ||
132 | { | ||
133 | int c_m; | ||
134 | int c_s; | ||
135 | unsigned int duration; | ||
136 | struct BenchmarkPeer *mp; | ||
137 | struct BenchmarkPartner *p; | ||
138 | |||
139 | unsigned int kb_sent_sec; | ||
140 | double kb_sent_percent; | ||
141 | unsigned int kb_recv_sec; | ||
142 | double kb_recv_percent; | ||
143 | unsigned int rtt; | ||
144 | |||
145 | duration = 1 + (perf_duration.rel_value_us / (1000 * 1000)); | ||
146 | for (c_m = 0; c_m < num_masters; c_m++) | ||
147 | { | ||
148 | mp = &mps[c_m]; | ||
149 | fprintf (stderr, | ||
150 | "Master [%u]: sent: %u KiB in %u sec. = %u KiB/s, received: %u KiB in %u sec. = %u KiB/s\n", | ||
151 | mp->no, mp->total_bytes_sent / 1024, duration, | ||
152 | (mp->total_bytes_sent / 1024) / duration, | ||
153 | mp->total_bytes_received / 1024, duration, | ||
154 | (mp->total_bytes_received / 1024) / duration); | ||
155 | |||
156 | for (c_s = 0; c_s < num_slaves; c_s++) | ||
157 | { | ||
158 | p = &mp->partners[c_s]; | ||
159 | kb_sent_sec = 0; | ||
160 | kb_recv_sec = 0; | ||
161 | kb_sent_percent = 0.0; | ||
162 | kb_recv_percent = 0.0; | ||
163 | rtt = 0; | ||
164 | |||
165 | if (duration > 0) | ||
166 | { | ||
167 | kb_sent_sec = (p->bytes_sent / 1024) / duration; | ||
168 | kb_recv_sec = (p->bytes_received / 1024) / duration; | ||
169 | } | ||
170 | |||
171 | if (mp->total_bytes_sent > 0) | ||
172 | kb_sent_percent = ((double) p->bytes_sent * 100) / mp->total_bytes_sent; | ||
173 | if (mp->total_bytes_received > 0) | ||
174 | kb_recv_percent = ((double) p->bytes_received * 100) | ||
175 | / mp->total_bytes_received; | ||
176 | if (1000 * p->messages_sent > 0) | ||
177 | rtt = p->total_app_rtt / (1000 * p->messages_sent); | ||
178 | fprintf (stderr, | ||
179 | "%c Master [%u] -> Slave [%u]: sent %u KiB/s (%.2f %%), received %u KiB/s (%.2f %%)\n", | ||
180 | (mp->pref_partner == p->dest) ? '*' : ' ', | ||
181 | mp->no, p->dest->no, | ||
182 | kb_sent_sec, kb_sent_percent, | ||
183 | kb_recv_sec, kb_recv_percent); | ||
184 | fprintf (stderr, | ||
185 | "%c Master [%u] -> Slave [%u]: Average application layer RTT: %u ms\n", | ||
186 | (mp->pref_partner == p->dest) ? '*' : ' ', | ||
187 | mp->no, p->dest->no, rtt); | ||
188 | } | ||
189 | } | ||
190 | } | ||
191 | |||
192 | |||
193 | /** | ||
194 | * Shutdown nicely | ||
195 | * | ||
196 | * @param cls NULL | ||
197 | */ | ||
198 | static void | ||
199 | do_shutdown (void *cls) | ||
200 | { | ||
201 | if (GNUNET_YES == logging) | ||
202 | GNUNET_ATS_TEST_logging_clean_up (l); | ||
203 | if (NULL != timeout_task) | ||
204 | { | ||
205 | GNUNET_SCHEDULER_cancel (timeout_task); | ||
206 | timeout_task = NULL; | ||
207 | } | ||
208 | if (NULL != progress_task) | ||
209 | { | ||
210 | fprintf (stderr, "0\n"); | ||
211 | GNUNET_SCHEDULER_cancel (progress_task); | ||
212 | progress_task = NULL; | ||
213 | } | ||
214 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
215 | "Benchmarking done\n"); | ||
216 | GNUNET_ATS_TEST_shutdown_topology (); | ||
217 | } | ||
218 | |||
219 | |||
220 | /** | ||
221 | * Shutdown nicely | ||
222 | * | ||
223 | * @param cls NULL | ||
224 | */ | ||
225 | static void | ||
226 | do_timeout (void *cls) | ||
227 | { | ||
228 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
229 | "Terminating with timeout\n"); | ||
230 | timeout_task = NULL; | ||
231 | evaluate (); | ||
232 | GNUNET_SCHEDULER_shutdown (); | ||
233 | } | ||
234 | |||
235 | |||
236 | static void | ||
237 | print_progress (void *cls) | ||
238 | { | ||
239 | static int calls; | ||
240 | |||
241 | progress_task = NULL; | ||
242 | fprintf (stderr, | ||
243 | "%llu..", | ||
244 | (long long unsigned) perf_duration.rel_value_us / (1000 * 1000) | ||
245 | - calls); | ||
246 | calls++; | ||
247 | |||
248 | progress_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, | ||
249 | &print_progress, | ||
250 | NULL); | ||
251 | } | ||
252 | |||
253 | |||
254 | static void | ||
255 | ats_pref_task (void *cls) | ||
256 | { | ||
257 | struct BenchmarkPeer *me = cls; | ||
258 | |||
259 | me->ats_task = NULL; | ||
260 | |||
261 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
262 | " Master [%u] set preference for slave [%u] to %f\n", | ||
263 | me->no, me->pref_partner->no, me->pref_value); | ||
264 | GNUNET_ATS_performance_change_preference (me->ats_perf_handle, | ||
265 | &me->pref_partner->id, | ||
266 | pref_val, me->pref_value, | ||
267 | GNUNET_ATS_PREFERENCE_END); | ||
268 | me->pref_value += TEST_ATS_PREFRENCE_DELTA; | ||
269 | me->ats_task = GNUNET_SCHEDULER_add_delayed (TEST_ATS_PREFRENCE_FREQUENCY, | ||
270 | &ats_pref_task, cls); | ||
271 | } | ||
272 | |||
273 | |||
274 | static void | ||
275 | start_benchmark (void *cls) | ||
276 | { | ||
277 | int c_m; | ||
278 | int c_s; | ||
279 | |||
280 | progress_task = GNUNET_SCHEDULER_add_now (&print_progress, | ||
281 | NULL); | ||
282 | |||
283 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
284 | "Topology connected, start benchmarking...\n"); | ||
285 | |||
286 | /* Start sending test messages */ | ||
287 | for (c_m = 0; c_m < num_masters; c_m++) | ||
288 | { | ||
289 | for (c_s = 0; c_s < num_slaves; c_s++) | ||
290 | { | ||
291 | GNUNET_ATS_TEST_generate_traffic_start (&mps[c_m], | ||
292 | &mps[c_m].partners[c_s], | ||
293 | GNUNET_ATS_TEST_TG_LINEAR, | ||
294 | UINT32_MAX, | ||
295 | UINT32_MAX, | ||
296 | GNUNET_TIME_UNIT_MINUTES, | ||
297 | GNUNET_TIME_UNIT_FOREVER_REL); | ||
298 | } | ||
299 | if (pref_val != GNUNET_ATS_PREFERENCE_END) | ||
300 | mps[c_m].ats_task = GNUNET_SCHEDULER_add_now (&ats_pref_task, | ||
301 | &mps[c_m]); | ||
302 | } | ||
303 | |||
304 | if (GNUNET_YES == logging) | ||
305 | l = GNUNET_ATS_TEST_logging_start (log_frequency, | ||
306 | testname, mps, | ||
307 | num_masters, num_slaves, | ||
308 | GNUNET_NO); | ||
309 | } | ||
310 | |||
311 | |||
312 | static void | ||
313 | do_benchmark (void *cls, | ||
314 | struct BenchmarkPeer *masters, | ||
315 | struct BenchmarkPeer *slaves) | ||
316 | { | ||
317 | mps = masters; | ||
318 | sps = slaves; | ||
319 | GNUNET_SCHEDULER_add_shutdown (&do_shutdown, | ||
320 | NULL); | ||
321 | timeout_task = GNUNET_SCHEDULER_add_delayed (perf_duration, | ||
322 | &do_timeout, | ||
323 | NULL); | ||
324 | progress_task = GNUNET_SCHEDULER_add_now (&start_benchmark, | ||
325 | NULL); | ||
326 | } | ||
327 | |||
328 | |||
329 | static struct BenchmarkPartner * | ||
330 | find_partner (struct BenchmarkPeer *me, | ||
331 | const struct GNUNET_PeerIdentity *peer) | ||
332 | { | ||
333 | int c_m; | ||
334 | |||
335 | GNUNET_assert (NULL != me); | ||
336 | GNUNET_assert (NULL != peer); | ||
337 | |||
338 | for (c_m = 0; c_m < me->num_partners; c_m++) | ||
339 | { | ||
340 | /* Find a partner with other as destination */ | ||
341 | if (0 == GNUNET_memcmp (peer, &me->partners[c_m].dest->id)) | ||
342 | { | ||
343 | return &me->partners[c_m]; | ||
344 | } | ||
345 | } | ||
346 | return NULL; | ||
347 | } | ||
348 | |||
349 | |||
350 | static void | ||
351 | log_request_cb (void *cls, | ||
352 | const struct GNUNET_HELLO_Address *address, | ||
353 | int address_active, | ||
354 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, | ||
355 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, | ||
356 | const struct GNUNET_ATS_Properties *ats) | ||
357 | { | ||
358 | struct BenchmarkPeer *me = cls; | ||
359 | struct BenchmarkPartner *p; | ||
360 | char *peer_id; | ||
361 | |||
362 | p = find_partner (me, &address->peer); | ||
363 | if (NULL == p) | ||
364 | { | ||
365 | /* This is not one of my partners | ||
366 | * Will happen since the peers will connect to each other due to gossiping | ||
367 | */ | ||
368 | return; | ||
369 | } | ||
370 | peer_id = GNUNET_strdup (GNUNET_i2s (&me->id)); | ||
371 | |||
372 | if ((p->bandwidth_in != ntohl (bandwidth_in.value__)) || | ||
373 | (p->bandwidth_out != ntohl (bandwidth_out.value__))) | ||
374 | p->bandwidth_in = ntohl (bandwidth_in.value__); | ||
375 | p->bandwidth_out = ntohl (bandwidth_out.value__); | ||
376 | |||
377 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
378 | "%s [%u] received ATS information for peers `%s'\n", | ||
379 | (GNUNET_YES == p->me->master) ? "Master" : "Slave", | ||
380 | p->me->no, | ||
381 | GNUNET_i2s (&p->dest->id)); | ||
382 | |||
383 | GNUNET_free (peer_id); | ||
384 | if (NULL != l) | ||
385 | GNUNET_ATS_TEST_logging_now (l); | ||
386 | } | ||
387 | |||
388 | |||
389 | /* | ||
390 | * Start the performance test case | ||
391 | */ | ||
392 | int | ||
393 | main (int argc, char *argv[]) | ||
394 | { | ||
395 | char *tmp; | ||
396 | char *tmp_sep; | ||
397 | char *test_name; | ||
398 | char *conf_name; | ||
399 | char *comm_name; | ||
400 | char *dotexe; | ||
401 | char *prefs[] = GNUNET_ATS_PreferenceTypeString; | ||
402 | int c; | ||
403 | |||
404 | result = 0; | ||
405 | |||
406 | /* Determine testname | ||
407 | * perf_ats_<solver>_<transport>_<preference>[.exe]*/ | ||
408 | |||
409 | /* Find test prefix, store in temp */ | ||
410 | tmp = strstr (argv[0], TESTNAME_PREFIX); | ||
411 | if (NULL == tmp) | ||
412 | { | ||
413 | fprintf (stderr, "Unable to parse test name `%s'\n", argv[0]); | ||
414 | return GNUNET_SYSERR; | ||
415 | } | ||
416 | |||
417 | /* Set tmp to end of test name prefix */ | ||
418 | tmp += strlen (TESTNAME_PREFIX); | ||
419 | |||
420 | /* Determine solver name */ | ||
421 | solver = GNUNET_strdup (tmp); | ||
422 | /* Remove .exe prefix */ | ||
423 | if ((NULL != (dotexe = strstr (solver, ".exe"))) && (dotexe[4] == '\0')) | ||
424 | dotexe[0] = '\0'; | ||
425 | |||
426 | /* Determine first '_' after solver */ | ||
427 | tmp_sep = strchr (solver, '_'); | ||
428 | if (NULL == tmp_sep) | ||
429 | { | ||
430 | fprintf (stderr, "Unable to parse test name `%s'\n", argv[0]); | ||
431 | GNUNET_free (solver); | ||
432 | return GNUNET_SYSERR; | ||
433 | } | ||
434 | tmp_sep[0] = '\0'; | ||
435 | comm_name = GNUNET_strdup (&tmp_sep[1]); | ||
436 | tmp_sep = strchr (comm_name, '_'); | ||
437 | if (NULL == tmp_sep) | ||
438 | { | ||
439 | fprintf (stderr, "Unable to parse test name `%s'\n", argv[0]); | ||
440 | GNUNET_free (solver); | ||
441 | return GNUNET_SYSERR; | ||
442 | } | ||
443 | tmp_sep[0] = '\0'; | ||
444 | for (c = 0; c <= strlen (comm_name); c++) | ||
445 | comm_name[c] = toupper (comm_name[c]); | ||
446 | if (0 == strcmp (comm_name, "CORE")) | ||
447 | test_core = GNUNET_YES; | ||
448 | else if (0 == strcmp (comm_name, "TRANSPORT")) | ||
449 | test_core = GNUNET_NO; | ||
450 | else | ||
451 | { | ||
452 | GNUNET_free (comm_name); | ||
453 | GNUNET_free (solver); | ||
454 | return GNUNET_SYSERR; | ||
455 | } | ||
456 | |||
457 | pref_str = GNUNET_strdup (tmp_sep + 1); | ||
458 | |||
459 | GNUNET_asprintf (&conf_name, "%s%s_%s.conf", TESTNAME_PREFIX, solver, | ||
460 | pref_str); | ||
461 | GNUNET_asprintf (&test_name, "%s%s_%s", TESTNAME_PREFIX, solver, pref_str); | ||
462 | |||
463 | for (c = 0; c <= strlen (pref_str); c++) | ||
464 | pref_str[c] = toupper (pref_str[c]); | ||
465 | pref_val = -1; | ||
466 | |||
467 | if (0 != strcmp (pref_str, "NONE")) | ||
468 | { | ||
469 | for (c = 0; c < GNUNET_ATS_PREFERENCE_END; c++) | ||
470 | { | ||
471 | if (0 == strcmp (pref_str, prefs[c])) | ||
472 | { | ||
473 | pref_val = c; | ||
474 | break; | ||
475 | } | ||
476 | } | ||
477 | } | ||
478 | else | ||
479 | { | ||
480 | /* abuse terminator to indicate no pref */ | ||
481 | pref_val = GNUNET_ATS_PREFERENCE_END; | ||
482 | } | ||
483 | if (-1 == pref_val) | ||
484 | { | ||
485 | fprintf (stderr, "Unknown preference: `%s'\n", pref_str); | ||
486 | GNUNET_free (solver); | ||
487 | GNUNET_free (pref_str); | ||
488 | GNUNET_free (comm_name); | ||
489 | return -1; | ||
490 | } | ||
491 | |||
492 | for (c = 0; c < (argc - 1); c++) | ||
493 | { | ||
494 | if (0 == strcmp (argv[c], "-d")) | ||
495 | break; | ||
496 | } | ||
497 | if (c < argc - 1) | ||
498 | { | ||
499 | if (GNUNET_OK != GNUNET_STRINGS_fancy_time_to_relative (argv[c + 1], | ||
500 | &perf_duration)) | ||
501 | fprintf (stderr, "Failed to parse duration `%s'\n", argv[c + 1]); | ||
502 | } | ||
503 | else | ||
504 | { | ||
505 | perf_duration = BENCHMARK_DURATION; | ||
506 | } | ||
507 | fprintf (stderr, "Running benchmark for %llu secs\n", (unsigned long | ||
508 | long) (perf_duration. | ||
509 | rel_value_us) | ||
510 | / (1000 * 1000)); | ||
511 | |||
512 | for (c = 0; c < (argc - 1); c++) | ||
513 | { | ||
514 | if (0 == strcmp (argv[c], "-s")) | ||
515 | break; | ||
516 | } | ||
517 | if (c < argc - 1) | ||
518 | { | ||
519 | if ((0L != (num_slaves = strtol (argv[c + 1], NULL, 10))) | ||
520 | && (num_slaves >= 1)) | ||
521 | fprintf (stderr, "Starting %u slave peers\n", num_slaves); | ||
522 | else | ||
523 | num_slaves = DEFAULT_SLAVES_NUM; | ||
524 | } | ||
525 | else | ||
526 | num_slaves = DEFAULT_SLAVES_NUM; | ||
527 | |||
528 | for (c = 0; c < (argc - 1); c++) | ||
529 | { | ||
530 | if (0 == strcmp (argv[c], "-m")) | ||
531 | break; | ||
532 | } | ||
533 | if (c < argc - 1) | ||
534 | { | ||
535 | if ((0L != (num_masters = strtol (argv[c + 1], NULL, 10))) | ||
536 | && (num_masters >= 2)) | ||
537 | fprintf (stderr, "Starting %u master peers\n", num_masters); | ||
538 | else | ||
539 | num_masters = DEFAULT_MASTERS_NUM; | ||
540 | } | ||
541 | else | ||
542 | num_masters = DEFAULT_MASTERS_NUM; | ||
543 | |||
544 | logging = GNUNET_NO; | ||
545 | for (c = 0; c < argc; c++) | ||
546 | { | ||
547 | if (0 == strcmp (argv[c], "-l")) | ||
548 | logging = GNUNET_YES; | ||
549 | } | ||
550 | |||
551 | if (GNUNET_YES == logging) | ||
552 | { | ||
553 | for (c = 0; c < (argc - 1); c++) | ||
554 | { | ||
555 | if (0 == strcmp (argv[c], "-f")) | ||
556 | break; | ||
557 | } | ||
558 | if (c < argc - 1) | ||
559 | { | ||
560 | if (GNUNET_OK != GNUNET_STRINGS_fancy_time_to_relative (argv[c + 1], | ||
561 | &log_frequency)) | ||
562 | fprintf (stderr, "Failed to parse duration `%s'\n", argv[c + 1]); | ||
563 | } | ||
564 | else | ||
565 | { | ||
566 | log_frequency = LOGGING_FREQUENCY; | ||
567 | } | ||
568 | fprintf (stderr, "Using log frequency %llu ms\n", | ||
569 | (unsigned long long) (log_frequency.rel_value_us) / (1000)); | ||
570 | } | ||
571 | |||
572 | GNUNET_asprintf (&testname, "%s_%s_%s", solver, comm_name, pref_str); | ||
573 | |||
574 | if (num_slaves < num_masters) | ||
575 | { | ||
576 | fprintf (stderr, | ||
577 | "Number of master peers is lower than slaves! exit...\n"); | ||
578 | GNUNET_free (test_name); | ||
579 | GNUNET_free (solver); | ||
580 | GNUNET_free (pref_str); | ||
581 | GNUNET_free (comm_name); | ||
582 | return GNUNET_SYSERR; | ||
583 | } | ||
584 | |||
585 | /** | ||
586 | * Setup the topology | ||
587 | */ | ||
588 | GNUNET_ATS_TEST_create_topology ("perf-ats", | ||
589 | conf_name, | ||
590 | num_slaves, | ||
591 | num_masters, | ||
592 | test_core, | ||
593 | &do_benchmark, | ||
594 | NULL, | ||
595 | &log_request_cb); | ||
596 | |||
597 | return result; | ||
598 | } | ||
599 | |||
600 | |||
601 | /* end of file perf_ats.c */ | ||
diff --git a/src/ats-tests/perf_ats.h b/src/ats-tests/perf_ats.h deleted file mode 100644 index 6460aa098..000000000 --- a/src/ats-tests/perf_ats.h +++ /dev/null | |||
@@ -1,256 +0,0 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet. | ||
3 | Copyright (C) 2010-2013 GNUnet e.V. | ||
4 | |||
5 | GNUnet is free software: you can redistribute it and/or modify it | ||
6 | under the terms of the GNU Affero General Public License as published | ||
7 | by the Free Software Foundation, either version 3 of the License, | ||
8 | or (at your option) any later version. | ||
9 | |||
10 | GNUnet is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Affero General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Affero General Public License | ||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | ||
19 | */ | ||
20 | /** | ||
21 | * @file ats/perf_ats.c | ||
22 | * @brief ats benchmark: start peers and modify preferences, monitor change over time | ||
23 | * @author Christian Grothoff | ||
24 | * @author Matthias Wachs | ||
25 | */ | ||
26 | #include "platform.h" | ||
27 | #include "gnunet_util_lib.h" | ||
28 | #include "gnunet_testbed_service.h" | ||
29 | #include "gnunet_ats_service.h" | ||
30 | #include "gnunet_core_service.h" | ||
31 | #include "ats-testing.h" | ||
32 | |||
33 | #define TEST_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, \ | ||
34 | 120) | ||
35 | #define BENCHMARK_DURATION GNUNET_TIME_relative_multiply ( \ | ||
36 | GNUNET_TIME_UNIT_SECONDS, 10) | ||
37 | #define LOGGING_FREQUENCY GNUNET_TIME_relative_multiply ( \ | ||
38 | GNUNET_TIME_UNIT_MILLISECONDS, 500) | ||
39 | #define TESTNAME_PREFIX "perf_ats_" | ||
40 | #define DEFAULT_SLAVES_NUM 2 | ||
41 | #define DEFAULT_MASTERS_NUM 1 | ||
42 | |||
43 | #define TEST_ATS_PREFRENCE_FREQUENCY GNUNET_TIME_relative_multiply ( \ | ||
44 | GNUNET_TIME_UNIT_SECONDS, 1) | ||
45 | #define TEST_ATS_PREFRENCE_START 1.0 | ||
46 | #define TEST_ATS_PREFRENCE_DELTA 1.0 | ||
47 | |||
48 | #define TEST_MESSAGE_TYPE_PING 12345 | ||
49 | #define TEST_MESSAGE_TYPE_PONG 12346 | ||
50 | #define TEST_MESSAGE_SIZE 1000 | ||
51 | #define TEST_MESSAGE_FREQUENCY GNUNET_TIME_relative_multiply ( \ | ||
52 | GNUNET_TIME_UNIT_SECONDS, 1) | ||
53 | |||
54 | /** | ||
55 | * Information about a benchmarking partner | ||
56 | */ | ||
57 | struct BenchmarkPartner | ||
58 | { | ||
59 | /** | ||
60 | * The peer itself this partner belongs to | ||
61 | */ | ||
62 | struct BenchmarkPeer *me; | ||
63 | |||
64 | /** | ||
65 | * The partner peer | ||
66 | */ | ||
67 | struct BenchmarkPeer *dest; | ||
68 | |||
69 | /** | ||
70 | * Core transmit handles | ||
71 | */ | ||
72 | struct GNUNET_CORE_TransmitHandle *cth; | ||
73 | |||
74 | /** | ||
75 | * Transport transmit handles | ||
76 | */ | ||
77 | struct GNUNET_TRANSPORT_TransmitHandle *tth; | ||
78 | |||
79 | /** | ||
80 | * Timestamp to calculate communication layer delay | ||
81 | */ | ||
82 | struct GNUNET_TIME_Absolute last_message_sent; | ||
83 | |||
84 | /** | ||
85 | * Accumulated RTT for all messages | ||
86 | */ | ||
87 | unsigned int total_app_rtt; | ||
88 | |||
89 | /** | ||
90 | * Number of messages sent to this partner | ||
91 | */ | ||
92 | unsigned int messages_sent; | ||
93 | |||
94 | /** | ||
95 | * Number of bytes sent to this partner | ||
96 | */ | ||
97 | unsigned int bytes_sent; | ||
98 | |||
99 | /** | ||
100 | * Number of messages received from this partner | ||
101 | */ | ||
102 | unsigned int messages_received; | ||
103 | |||
104 | /** | ||
105 | * Number of bytes received from this partner | ||
106 | */ | ||
107 | unsigned int bytes_received; | ||
108 | |||
109 | /* Current ATS properties */ | ||
110 | |||
111 | uint32_t ats_distance; | ||
112 | |||
113 | uint32_t ats_delay; | ||
114 | |||
115 | uint32_t bandwidth_in; | ||
116 | |||
117 | uint32_t bandwidth_out; | ||
118 | |||
119 | uint32_t ats_utilization_up; | ||
120 | |||
121 | uint32_t ats_utilization_down; | ||
122 | |||
123 | uint32_t ats_network_type; | ||
124 | |||
125 | uint32_t ats_cost_wan; | ||
126 | |||
127 | uint32_t ats_cost_lan; | ||
128 | |||
129 | uint32_t ats_cost_wlan; | ||
130 | }; | ||
131 | |||
132 | |||
133 | /** | ||
134 | * Information we track for a peer in the testbed. | ||
135 | */ | ||
136 | struct BenchmarkPeer | ||
137 | { | ||
138 | /** | ||
139 | * Handle with testbed. | ||
140 | */ | ||
141 | struct GNUNET_TESTBED_Peer *peer; | ||
142 | |||
143 | /** | ||
144 | * Unique identifier | ||
145 | */ | ||
146 | int no; | ||
147 | |||
148 | /** | ||
149 | * Is this peer a measter: GNUNET_YES/GNUNET_NO | ||
150 | */ | ||
151 | int master; | ||
152 | |||
153 | /** | ||
154 | * Peer ID | ||
155 | */ | ||
156 | struct GNUNET_PeerIdentity id; | ||
157 | |||
158 | /** | ||
159 | * Testbed operation to get peer information | ||
160 | */ | ||
161 | struct GNUNET_TESTBED_Operation *peer_id_op; | ||
162 | |||
163 | /** | ||
164 | * Testbed operation to connect to ATS performance service | ||
165 | */ | ||
166 | struct GNUNET_TESTBED_Operation *ats_perf_op; | ||
167 | |||
168 | /** | ||
169 | * Testbed operation to connect to core | ||
170 | */ | ||
171 | struct GNUNET_TESTBED_Operation *comm_op; | ||
172 | |||
173 | /** | ||
174 | * ATS performance handle | ||
175 | */ | ||
176 | struct GNUNET_ATS_PerformanceHandle *ats_perf_handle; | ||
177 | |||
178 | /** | ||
179 | * Masters only: | ||
180 | * Testbed connect operations to connect masters to slaves | ||
181 | */ | ||
182 | struct TestbedConnectOperation *core_connect_ops; | ||
183 | |||
184 | /** | ||
185 | * Core handle | ||
186 | */ | ||
187 | struct GNUNET_CORE_Handle *ch; | ||
188 | |||
189 | /** | ||
190 | * Core handle | ||
191 | */ | ||
192 | struct GNUNET_TRANSPORT_Handle *th; | ||
193 | |||
194 | /** | ||
195 | * Masters only: | ||
196 | * Peer to set ATS preferences for | ||
197 | */ | ||
198 | struct BenchmarkPeer *pref_partner; | ||
199 | |||
200 | /** | ||
201 | * Masters only | ||
202 | * Progress task | ||
203 | */ | ||
204 | struct GNUNET_SCHEDULER_Task *ats_task; | ||
205 | |||
206 | /** | ||
207 | * Masters only | ||
208 | * Progress task | ||
209 | */ | ||
210 | double pref_value; | ||
211 | |||
212 | /** | ||
213 | * Array of partners with num_slaves entries (if master) or | ||
214 | * num_master entries (if slave) | ||
215 | */ | ||
216 | struct BenchmarkPartner *partners; | ||
217 | |||
218 | /** | ||
219 | * Number of partners | ||
220 | */ | ||
221 | int num_partners; | ||
222 | |||
223 | /** | ||
224 | * Number of core connections | ||
225 | */ | ||
226 | int core_connections; | ||
227 | |||
228 | /** | ||
229 | * Masters only: | ||
230 | * Number of connections to slave peers | ||
231 | */ | ||
232 | int core_slave_connections; | ||
233 | |||
234 | /** | ||
235 | * Total number of messages this peer has sent | ||
236 | */ | ||
237 | unsigned int total_messages_sent; | ||
238 | |||
239 | /** | ||
240 | * Total number of bytes this peer has sent | ||
241 | */ | ||
242 | unsigned int total_bytes_sent; | ||
243 | |||
244 | /** | ||
245 | * Total number of messages this peer has received | ||
246 | */ | ||
247 | unsigned int total_messages_received; | ||
248 | |||
249 | /** | ||
250 | * Total number of bytes this peer has received | ||
251 | */ | ||
252 | unsigned int total_bytes_received; | ||
253 | }; | ||
254 | |||
255 | |||
256 | /* end of file perf_ats.h */ | ||
diff --git a/src/ats-tests/perf_ats_logging.c b/src/ats-tests/perf_ats_logging.c deleted file mode 100644 index ac8fa8950..000000000 --- a/src/ats-tests/perf_ats_logging.c +++ /dev/null | |||
@@ -1,780 +0,0 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet. | ||
3 | Copyright (C) 2010-2013 GNUnet e.V. | ||
4 | |||
5 | GNUnet is free software: you can redistribute it and/or modify it | ||
6 | under the terms of the GNU Affero General Public License as published | ||
7 | by the Free Software Foundation, either version 3 of the License, | ||
8 | or (at your option) any later version. | ||
9 | |||
10 | GNUnet is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Affero General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Affero General Public License | ||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | ||
19 | */ | ||
20 | /** | ||
21 | * @file ats/perf_ats_logging.c | ||
22 | * @brief ats benchmark: logging for performance tests | ||
23 | * @author Christian Grothoff | ||
24 | * @author Matthias Wachs | ||
25 | */ | ||
26 | #include "platform.h" | ||
27 | #include "gnunet_util_lib.h" | ||
28 | #include "perf_ats.h" | ||
29 | |||
30 | #define THROUGHPUT_TEMPLATE "#!/usr/bin/gnuplot \n" \ | ||
31 | "set datafile separator ';' \n" \ | ||
32 | "set title \"Throughput between Master and Slaves\" \n" \ | ||
33 | "set xlabel \"Time in ms\" \n" \ | ||
34 | "set ylabel \"Bytes/s\" \n" \ | ||
35 | "set grid \n" | ||
36 | |||
37 | #define RTT_TEMPLATE "#!/usr/bin/gnuplot \n" \ | ||
38 | "set datafile separator ';' \n" \ | ||
39 | "set title \"Application level roundtrip time between Master and Slaves\" \n" \ | ||
40 | "set xlabel \"Time in ms\" \n" \ | ||
41 | "set ylabel \"ms\" \n" \ | ||
42 | "set grid \n" | ||
43 | |||
44 | #define BW_TEMPLATE "#!/usr/bin/gnuplot \n" \ | ||
45 | "set datafile separator ';' \n" \ | ||
46 | "set title \"Bandwidth inbound and outbound between Master and Slaves\" \n" \ | ||
47 | "set xlabel \"Time in ms\" \n" \ | ||
48 | "set ylabel \"Bytes / s \" \n" \ | ||
49 | "set grid \n" | ||
50 | |||
51 | #define LOG_ITEMS_TIME 2 | ||
52 | #define LOG_ITEMS_PER_PEER 17 | ||
53 | |||
54 | #define LOG_ITEM_BYTES_SENT 1 | ||
55 | #define LOG_ITEM_MSGS_SENT 2 | ||
56 | #define LOG_ITEM_THROUGHPUT_SENT 3 | ||
57 | #define LOG_ITEM_BYTES_RECV 4 | ||
58 | #define LOG_ITEM_MSGS_RECV 5 | ||
59 | #define LOG_ITEM_THROUGHPUT_RECV 6 | ||
60 | #define LOG_ITEM_APP_RTT 7 | ||
61 | #define LOG_ITEM_ATS_BW_IN 8 | ||
62 | #define LOG_ITEM_ATS_BW_OUT 9 | ||
63 | #define LOG_ITEM_ATS_COSTS_LAN 10 | ||
64 | #define LOG_ITEM_ATS_WAN 11 | ||
65 | #define LOG_ITEM_ATS_WLAN 12 | ||
66 | #define LOG_ITEM_ATS_DELAY 13 | ||
67 | #define LOG_ITEM_ATS_DISTANCE 14 | ||
68 | #define LOG_ITEM_ATS_NETWORKTYPE 15 | ||
69 | #define LOG_ITEM_ATS_UTIL_UP 16 | ||
70 | #define LOG_ITEM_ATS_UTIL_DOWN 17 | ||
71 | |||
72 | /** | ||
73 | * Logging task | ||
74 | */ | ||
75 | static struct GNUNET_SCHEDULER_Task *log_task; | ||
76 | |||
77 | /** | ||
78 | * Reference to perf_ats' masters | ||
79 | */ | ||
80 | static int num_peers; | ||
81 | static int running; | ||
82 | static char *name; | ||
83 | static struct GNUNET_TIME_Relative frequency; | ||
84 | |||
85 | /** | ||
86 | * A single logging time step for a partner | ||
87 | */ | ||
88 | struct PartnerLoggingTimestep | ||
89 | { | ||
90 | /** | ||
91 | * Peer | ||
92 | */ | ||
93 | struct BenchmarkPeer *slave; | ||
94 | |||
95 | /** | ||
96 | * Total number of messages this peer has sent | ||
97 | */ | ||
98 | unsigned int total_messages_sent; | ||
99 | |||
100 | /** | ||
101 | * Total number of bytes this peer has sent | ||
102 | */ | ||
103 | unsigned int total_bytes_sent; | ||
104 | |||
105 | /** | ||
106 | * Total number of messages this peer has received | ||
107 | */ | ||
108 | unsigned int total_messages_received; | ||
109 | |||
110 | /** | ||
111 | * Total number of bytes this peer has received | ||
112 | */ | ||
113 | unsigned int total_bytes_received; | ||
114 | |||
115 | /** | ||
116 | * Total outbound throughput for master in Bytes / s | ||
117 | */ | ||
118 | unsigned int throughput_sent; | ||
119 | |||
120 | /** | ||
121 | * Total inbound throughput for master in Bytes / s | ||
122 | */ | ||
123 | unsigned int throughput_recv; | ||
124 | |||
125 | /** | ||
126 | * Accumulated RTT for all messages | ||
127 | */ | ||
128 | unsigned int total_app_rtt; | ||
129 | |||
130 | /** | ||
131 | * Current application level delay | ||
132 | */ | ||
133 | unsigned int app_rtt; | ||
134 | |||
135 | /* Current ATS properties */ | ||
136 | |||
137 | uint32_t ats_distance; | ||
138 | |||
139 | uint32_t ats_delay; | ||
140 | |||
141 | uint32_t bandwidth_in; | ||
142 | |||
143 | uint32_t bandwidth_out; | ||
144 | |||
145 | uint32_t ats_utilization_up; | ||
146 | |||
147 | uint32_t ats_utilization_down; | ||
148 | |||
149 | uint32_t ats_network_type; | ||
150 | |||
151 | uint32_t ats_cost_wan; | ||
152 | |||
153 | uint32_t ats_cost_lan; | ||
154 | |||
155 | uint32_t ats_cost_wlan; | ||
156 | }; | ||
157 | |||
158 | |||
159 | /** | ||
160 | * A single logging time step for a peer | ||
161 | */ | ||
162 | struct PeerLoggingTimestep | ||
163 | { | ||
164 | /** | ||
165 | * Next in DLL | ||
166 | */ | ||
167 | struct PeerLoggingTimestep *next; | ||
168 | |||
169 | /** | ||
170 | * Prev in DLL | ||
171 | */ | ||
172 | struct PeerLoggingTimestep *prev; | ||
173 | |||
174 | /** | ||
175 | * Logging timestamp | ||
176 | */ | ||
177 | struct GNUNET_TIME_Absolute timestamp; | ||
178 | |||
179 | /** | ||
180 | * Total number of messages this peer has sent | ||
181 | */ | ||
182 | unsigned int total_messages_sent; | ||
183 | |||
184 | /** | ||
185 | * Total number of bytes this peer has sent | ||
186 | */ | ||
187 | unsigned int total_bytes_sent; | ||
188 | |||
189 | /** | ||
190 | * Total number of messages this peer has received | ||
191 | */ | ||
192 | unsigned int total_messages_received; | ||
193 | |||
194 | /** | ||
195 | * Total number of bytes this peer has received | ||
196 | */ | ||
197 | unsigned int total_bytes_received; | ||
198 | |||
199 | /** | ||
200 | * Total outbound throughput for master in Bytes / s | ||
201 | */ | ||
202 | unsigned int total_throughput_send; | ||
203 | |||
204 | /** | ||
205 | * Total inbound throughput for master in Bytes / s | ||
206 | */ | ||
207 | unsigned int total_throughput_recv; | ||
208 | |||
209 | /** | ||
210 | * Logs for slaves | ||
211 | */ | ||
212 | struct PartnerLoggingTimestep *slaves_log; | ||
213 | }; | ||
214 | |||
215 | /** | ||
216 | * Entry for a benchmark peer | ||
217 | */ | ||
218 | struct LoggingPeer | ||
219 | { | ||
220 | /** | ||
221 | * Peer | ||
222 | */ | ||
223 | struct BenchmarkPeer *peer; | ||
224 | |||
225 | /** | ||
226 | * Start time | ||
227 | */ | ||
228 | struct GNUNET_TIME_Absolute start; | ||
229 | |||
230 | /** | ||
231 | * DLL for logging entries: head | ||
232 | */ | ||
233 | struct PeerLoggingTimestep *head; | ||
234 | |||
235 | /** | ||
236 | * DLL for logging entries: tail | ||
237 | */ | ||
238 | struct PeerLoggingTimestep *tail; | ||
239 | }; | ||
240 | |||
241 | /** | ||
242 | * Log structure of length num_peers | ||
243 | */ | ||
244 | static struct LoggingPeer *lp; | ||
245 | |||
246 | |||
247 | static void | ||
248 | write_throughput_gnuplot_script (char *fn, struct LoggingPeer *lp) | ||
249 | { | ||
250 | struct GNUNET_DISK_FileHandle *f; | ||
251 | char *gfn; | ||
252 | char *data; | ||
253 | int c_s; | ||
254 | int peer_index; | ||
255 | |||
256 | GNUNET_asprintf (&gfn, "gnuplot_throughput_%s", fn); | ||
257 | f = GNUNET_DISK_file_open (gfn, | ||
258 | GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE, | ||
259 | GNUNET_DISK_PERM_USER_EXEC | ||
260 | | GNUNET_DISK_PERM_USER_READ | ||
261 | | GNUNET_DISK_PERM_USER_WRITE); | ||
262 | if (NULL == f) | ||
263 | { | ||
264 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot open gnuplot file `%s'\n", | ||
265 | gfn); | ||
266 | GNUNET_free (gfn); | ||
267 | return; | ||
268 | } | ||
269 | |||
270 | /* Write header */ | ||
271 | |||
272 | if (GNUNET_SYSERR == GNUNET_DISK_file_write (f, THROUGHPUT_TEMPLATE, strlen ( | ||
273 | THROUGHPUT_TEMPLATE))) | ||
274 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
275 | "Cannot write data to plot file `%s'\n", gfn); | ||
276 | |||
277 | /* Write master data */ | ||
278 | peer_index = LOG_ITEMS_TIME; | ||
279 | GNUNET_asprintf (&data, | ||
280 | "plot '%s' using 2:%u with lines title 'Master %u send total', \\\n" \ | ||
281 | "'%s' using 2:%u with lines title 'Master %u receive total', \\\n", | ||
282 | fn, peer_index + LOG_ITEM_THROUGHPUT_SENT, lp->peer->no, | ||
283 | fn, peer_index + LOG_ITEM_THROUGHPUT_RECV, lp->peer->no); | ||
284 | if (GNUNET_SYSERR == GNUNET_DISK_file_write (f, data, strlen (data))) | ||
285 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
286 | "Cannot write data to plot file `%s'\n", gfn); | ||
287 | GNUNET_free (data); | ||
288 | |||
289 | peer_index = LOG_ITEMS_TIME + LOG_ITEMS_PER_PEER; | ||
290 | for (c_s = 0; c_s < lp->peer->num_partners; c_s++) | ||
291 | { | ||
292 | GNUNET_asprintf (&data, | ||
293 | "'%s' using 2:%u with lines title 'Master %u - Slave %u send', \\\n" \ | ||
294 | "'%s' using 2:%u with lines title 'Master %u - Slave %u receive'%s\n", | ||
295 | fn, peer_index + LOG_ITEM_THROUGHPUT_SENT, lp->peer->no, | ||
296 | lp->peer->partners[c_s].dest->no, | ||
297 | fn, peer_index + LOG_ITEM_THROUGHPUT_RECV, lp->peer->no, | ||
298 | lp->peer->partners[c_s].dest->no, | ||
299 | (c_s < lp->peer->num_partners - 1) ? ", \\" : | ||
300 | "\n pause -1"); | ||
301 | if (GNUNET_SYSERR == GNUNET_DISK_file_write (f, data, strlen (data))) | ||
302 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
303 | "Cannot write data to plot file `%s'\n", gfn); | ||
304 | GNUNET_free (data); | ||
305 | peer_index += LOG_ITEMS_PER_PEER; | ||
306 | } | ||
307 | |||
308 | if (GNUNET_SYSERR == GNUNET_DISK_file_close (f)) | ||
309 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot close gnuplot file `%s'\n", | ||
310 | gfn); | ||
311 | else | ||
312 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
313 | "Data successfully written to plot file `%s'\n", gfn); | ||
314 | |||
315 | GNUNET_free (gfn); | ||
316 | } | ||
317 | |||
318 | |||
319 | static void | ||
320 | write_rtt_gnuplot_script (char *fn, struct LoggingPeer *lp) | ||
321 | { | ||
322 | struct GNUNET_DISK_FileHandle *f; | ||
323 | char *gfn; | ||
324 | char *data; | ||
325 | int c_s; | ||
326 | int index; | ||
327 | |||
328 | GNUNET_asprintf (&gfn, "gnuplot_rtt_%s", fn); | ||
329 | f = GNUNET_DISK_file_open (gfn, | ||
330 | GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE, | ||
331 | GNUNET_DISK_PERM_USER_EXEC | ||
332 | | GNUNET_DISK_PERM_USER_READ | ||
333 | | GNUNET_DISK_PERM_USER_WRITE); | ||
334 | if (NULL == f) | ||
335 | { | ||
336 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot open gnuplot file `%s'\n", | ||
337 | gfn); | ||
338 | GNUNET_free (gfn); | ||
339 | return; | ||
340 | } | ||
341 | |||
342 | /* Write header */ | ||
343 | |||
344 | if (GNUNET_SYSERR == GNUNET_DISK_file_write (f, RTT_TEMPLATE, strlen ( | ||
345 | RTT_TEMPLATE))) | ||
346 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
347 | "Cannot write data to plot file `%s'\n", gfn); | ||
348 | |||
349 | index = LOG_ITEMS_TIME + LOG_ITEMS_PER_PEER; | ||
350 | for (c_s = 0; c_s < lp->peer->num_partners; c_s++) | ||
351 | { | ||
352 | GNUNET_asprintf (&data, | ||
353 | "%s'%s' using 2:%u with lines title 'Master %u - Slave %u '%s\n", | ||
354 | (0 == c_s) ? "plot " : "", | ||
355 | fn, index + LOG_ITEM_APP_RTT, lp->peer->no, | ||
356 | lp->peer->partners[c_s].dest->no, | ||
357 | (c_s < lp->peer->num_partners - 1) ? ", \\" : | ||
358 | "\n pause -1"); | ||
359 | if (GNUNET_SYSERR == GNUNET_DISK_file_write (f, data, strlen (data))) | ||
360 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
361 | "Cannot write data to plot file `%s'\n", gfn); | ||
362 | GNUNET_free (data); | ||
363 | index += LOG_ITEMS_PER_PEER; | ||
364 | } | ||
365 | |||
366 | if (GNUNET_SYSERR == GNUNET_DISK_file_close (f)) | ||
367 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot close gnuplot file `%s'\n", | ||
368 | gfn); | ||
369 | else | ||
370 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
371 | "Data successfully written to plot file `%s'\n", gfn); | ||
372 | GNUNET_free (gfn); | ||
373 | } | ||
374 | |||
375 | |||
376 | static void | ||
377 | write_bw_gnuplot_script (char *fn, struct LoggingPeer *lp) | ||
378 | { | ||
379 | struct GNUNET_DISK_FileHandle *f; | ||
380 | char *gfn; | ||
381 | char *data; | ||
382 | int c_s; | ||
383 | int index; | ||
384 | |||
385 | GNUNET_asprintf (&gfn, "gnuplot_bw_%s", fn); | ||
386 | f = GNUNET_DISK_file_open (gfn, | ||
387 | GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE, | ||
388 | GNUNET_DISK_PERM_USER_EXEC | ||
389 | | GNUNET_DISK_PERM_USER_READ | ||
390 | | GNUNET_DISK_PERM_USER_WRITE); | ||
391 | if (NULL == f) | ||
392 | { | ||
393 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot open gnuplot file `%s'\n", | ||
394 | gfn); | ||
395 | GNUNET_free (gfn); | ||
396 | return; | ||
397 | } | ||
398 | |||
399 | /* Write header */ | ||
400 | |||
401 | if (GNUNET_SYSERR == GNUNET_DISK_file_write (f, BW_TEMPLATE, strlen ( | ||
402 | BW_TEMPLATE))) | ||
403 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
404 | "Cannot write data to plot file `%s'\n", gfn); | ||
405 | |||
406 | index = LOG_ITEMS_TIME + LOG_ITEMS_PER_PEER; | ||
407 | for (c_s = 0; c_s < lp->peer->num_partners; c_s++) | ||
408 | { | ||
409 | GNUNET_asprintf (&data, "%s" \ | ||
410 | "'%s' using 2:%u with lines title 'BW out master %u - Slave %u ', \\\n" \ | ||
411 | "'%s' using 2:%u with lines title 'BW in master %u - Slave %u '" \ | ||
412 | "%s\n", | ||
413 | (0 == c_s) ? "plot " : "", | ||
414 | fn, index + LOG_ITEM_ATS_BW_OUT, lp->peer->no, | ||
415 | lp->peer->partners[c_s].dest->no, | ||
416 | fn, index + LOG_ITEM_ATS_BW_IN, lp->peer->no, | ||
417 | lp->peer->partners[c_s].dest->no, | ||
418 | (c_s < lp->peer->num_partners - 1) ? ", \\" : | ||
419 | "\n pause -1"); | ||
420 | if (GNUNET_SYSERR == GNUNET_DISK_file_write (f, data, strlen (data))) | ||
421 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
422 | "Cannot write data to plot file `%s'\n", gfn); | ||
423 | GNUNET_free (data); | ||
424 | index += LOG_ITEMS_PER_PEER; | ||
425 | } | ||
426 | |||
427 | if (GNUNET_SYSERR == GNUNET_DISK_file_close (f)) | ||
428 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot close gnuplot file `%s'\n", | ||
429 | gfn); | ||
430 | else | ||
431 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
432 | "Data successfully written to plot file `%s'\n", gfn); | ||
433 | GNUNET_free (gfn); | ||
434 | } | ||
435 | |||
436 | |||
437 | static void | ||
438 | write_to_file () | ||
439 | { | ||
440 | struct GNUNET_DISK_FileHandle *f; | ||
441 | |||
442 | char *filename; | ||
443 | char *data; | ||
444 | char *slave_string; | ||
445 | char *slave_string_tmp; | ||
446 | struct PeerLoggingTimestep *cur_lt; | ||
447 | struct PartnerLoggingTimestep *plt; | ||
448 | int c_m; | ||
449 | int c_s; | ||
450 | |||
451 | for (c_m = 0; c_m < num_peers; c_m++) | ||
452 | { | ||
453 | GNUNET_asprintf (&filename, "%llu_master_%u_%s_%s.data", | ||
454 | GNUNET_TIME_absolute_get ().abs_value_us, | ||
455 | lp[c_m].peer->no, GNUNET_i2s (&lp[c_m].peer->id), name); | ||
456 | |||
457 | f = GNUNET_DISK_file_open (filename, | ||
458 | GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE, | ||
459 | GNUNET_DISK_PERM_USER_READ | ||
460 | | GNUNET_DISK_PERM_USER_WRITE); | ||
461 | if (NULL == f) | ||
462 | { | ||
463 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot open log file `%s'\n", | ||
464 | filename); | ||
465 | GNUNET_free (filename); | ||
466 | return; | ||
467 | } | ||
468 | |||
469 | for (cur_lt = lp[c_m].head; NULL != cur_lt; cur_lt = cur_lt->next) | ||
470 | { | ||
471 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
472 | "Master [%u]: timestamp %llu %llu ; %u %u %u ; %u %u %u\n", | ||
473 | lp[c_m].peer->no, | ||
474 | cur_lt->timestamp, GNUNET_TIME_absolute_get_difference ( | ||
475 | lp[c_m].start, cur_lt->timestamp).rel_value_us / 1000, | ||
476 | cur_lt->total_messages_sent, cur_lt->total_bytes_sent, | ||
477 | cur_lt->total_throughput_send, | ||
478 | cur_lt->total_messages_received, cur_lt->total_bytes_received, | ||
479 | cur_lt->total_throughput_recv); | ||
480 | |||
481 | slave_string = GNUNET_strdup (";"); | ||
482 | for (c_s = 0; c_s < lp[c_m].peer->num_partners; c_s++) | ||
483 | { | ||
484 | plt = &cur_lt->slaves_log[c_s]; | ||
485 | /* Log partners */ | ||
486 | |||
487 | /* Assembling slave string */ | ||
488 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
489 | "\t Slave [%u]: %u %u %u ; %u %u %u rtt %u delay %u bw_in %u bw_out %u \n", | ||
490 | plt->slave->no, | ||
491 | plt->total_messages_sent, plt->total_bytes_sent, | ||
492 | plt->throughput_sent, | ||
493 | plt->total_messages_received, plt->total_bytes_received, | ||
494 | plt->throughput_recv, | ||
495 | plt->app_rtt, plt->ats_delay, | ||
496 | plt->bandwidth_in, plt->bandwidth_out); | ||
497 | |||
498 | GNUNET_asprintf (&slave_string_tmp, | ||
499 | "%s%u;%u;%u;%u;%u;%u;%.3f;%u;%u;%u;%u;%u;%u;%u;%u;%u;%u;", | ||
500 | slave_string, | ||
501 | plt->total_messages_sent, plt->total_bytes_sent, | ||
502 | plt->throughput_sent, | ||
503 | plt->total_messages_received, | ||
504 | plt->total_bytes_received, plt->throughput_sent, | ||
505 | (double) plt->app_rtt / 1000, | ||
506 | plt->bandwidth_in, plt->bandwidth_out, | ||
507 | plt->ats_cost_lan, plt->ats_cost_wan, | ||
508 | plt->ats_cost_wlan, | ||
509 | plt->ats_delay, plt->ats_distance, | ||
510 | plt->ats_network_type, | ||
511 | plt->ats_utilization_up, plt->ats_utilization_down); | ||
512 | GNUNET_free (slave_string); | ||
513 | slave_string = slave_string_tmp; | ||
514 | } | ||
515 | /* Assembling master string */ | ||
516 | |||
517 | |||
518 | GNUNET_asprintf (&data, "%llu;%llu;%u;%u;%u;%u;%u;%u;;;;;;;;;;;%s\n", | ||
519 | cur_lt->timestamp, | ||
520 | GNUNET_TIME_absolute_get_difference (lp[c_m].start, | ||
521 | cur_lt->timestamp). | ||
522 | rel_value_us / 1000, | ||
523 | cur_lt->total_messages_sent, cur_lt->total_bytes_sent, | ||
524 | cur_lt->total_throughput_send, | ||
525 | cur_lt->total_messages_received, | ||
526 | cur_lt->total_bytes_received, | ||
527 | cur_lt->total_throughput_recv, | ||
528 | slave_string); | ||
529 | GNUNET_free (slave_string); | ||
530 | |||
531 | if (GNUNET_SYSERR == GNUNET_DISK_file_write (f, data, strlen (data))) | ||
532 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
533 | "Cannot write data to log file `%s'\n", filename); | ||
534 | GNUNET_free (data); | ||
535 | } | ||
536 | if (GNUNET_SYSERR == GNUNET_DISK_file_close (f)) | ||
537 | { | ||
538 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot close log file `%s'\n", | ||
539 | filename); | ||
540 | GNUNET_free (filename); | ||
541 | return; | ||
542 | } | ||
543 | |||
544 | write_throughput_gnuplot_script (filename, lp); | ||
545 | write_rtt_gnuplot_script (filename, lp); | ||
546 | write_bw_gnuplot_script (filename, lp); | ||
547 | |||
548 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
549 | "Data file successfully written to log file `%s'\n", filename); | ||
550 | GNUNET_free (filename); | ||
551 | } | ||
552 | } | ||
553 | |||
554 | |||
555 | void | ||
556 | collect_log_now (void) | ||
557 | { | ||
558 | struct LoggingPeer *bp; | ||
559 | struct PeerLoggingTimestep *mlt; | ||
560 | struct PeerLoggingTimestep *prev_log_mlt; | ||
561 | struct PartnerLoggingTimestep *slt; | ||
562 | struct PartnerLoggingTimestep *prev_log_slt; | ||
563 | struct BenchmarkPartner *p; | ||
564 | struct GNUNET_TIME_Relative delta; | ||
565 | int c_s; | ||
566 | int c_m; | ||
567 | unsigned int app_rtt; | ||
568 | double mult; | ||
569 | |||
570 | if (GNUNET_YES != running) | ||
571 | return; | ||
572 | |||
573 | for (c_m = 0; c_m < num_peers; c_m++) | ||
574 | { | ||
575 | bp = &lp[c_m]; | ||
576 | mlt = GNUNET_new (struct PeerLoggingTimestep); | ||
577 | GNUNET_CONTAINER_DLL_insert_tail (bp->head, bp->tail, mlt); | ||
578 | prev_log_mlt = mlt->prev; | ||
579 | |||
580 | /* Collect data */ | ||
581 | |||
582 | /* Current master state */ | ||
583 | mlt->timestamp = GNUNET_TIME_absolute_get (); | ||
584 | mlt->total_bytes_sent = bp->peer->total_bytes_sent; | ||
585 | mlt->total_messages_sent = bp->peer->total_messages_sent; | ||
586 | mlt->total_bytes_received = bp->peer->total_bytes_received; | ||
587 | mlt->total_messages_received = bp->peer->total_messages_received; | ||
588 | |||
589 | /* Throughput */ | ||
590 | if (NULL == prev_log_mlt) | ||
591 | { | ||
592 | /* Get difference to start */ | ||
593 | delta = GNUNET_TIME_absolute_get_difference (lp[c_m].start, | ||
594 | mlt->timestamp); | ||
595 | } | ||
596 | else | ||
597 | { | ||
598 | /* Get difference to last timestep */ | ||
599 | delta = GNUNET_TIME_absolute_get_difference (mlt->prev->timestamp, | ||
600 | mlt->timestamp); | ||
601 | } | ||
602 | |||
603 | /* Multiplication factor for throughput calculation */ | ||
604 | mult = (1.0 * 1000 * 1000) / (delta.rel_value_us); | ||
605 | |||
606 | /* Total throughput */ | ||
607 | if (NULL != prev_log_mlt) | ||
608 | { | ||
609 | if (mlt->total_bytes_sent - mlt->prev->total_bytes_sent > 0) | ||
610 | mlt->total_throughput_send = mult * (mlt->total_bytes_sent | ||
611 | - mlt->prev->total_bytes_sent); | ||
612 | else | ||
613 | mlt->total_throughput_send = prev_log_mlt->total_throughput_send; /* no msgs send */ | ||
614 | |||
615 | if (mlt->total_bytes_received - mlt->prev->total_bytes_received > 0) | ||
616 | mlt->total_throughput_recv = mult * (mlt->total_bytes_received | ||
617 | - mlt->prev->total_bytes_received); | ||
618 | else | ||
619 | mlt->total_throughput_recv = prev_log_mlt->total_throughput_recv; /* no msgs received */ | ||
620 | } | ||
621 | else | ||
622 | { | ||
623 | mlt->total_throughput_send = mult * mlt->total_bytes_sent; | ||
624 | mlt->total_throughput_send = mult * mlt->total_bytes_received; | ||
625 | } | ||
626 | |||
627 | mlt->slaves_log = GNUNET_malloc (bp->peer->num_partners | ||
628 | * sizeof(struct PartnerLoggingTimestep)); | ||
629 | |||
630 | for (c_s = 0; c_s < bp->peer->num_partners; c_s++) | ||
631 | { | ||
632 | p = &bp->peer->partners[c_s]; | ||
633 | slt = &mlt->slaves_log[c_s]; | ||
634 | |||
635 | slt->slave = p->dest; | ||
636 | /* Bytes sent from master to this slave */ | ||
637 | slt->total_bytes_sent = p->bytes_sent; | ||
638 | /* Messages sent from master to this slave */ | ||
639 | slt->total_messages_sent = p->messages_sent; | ||
640 | /* Bytes master received from this slave */ | ||
641 | slt->total_bytes_received = p->bytes_received; | ||
642 | /* Messages master received from this slave */ | ||
643 | slt->total_messages_received = p->messages_received; | ||
644 | slt->total_app_rtt = p->total_app_rtt; | ||
645 | /* ats performance information */ | ||
646 | slt->ats_cost_lan = p->ats_cost_lan; | ||
647 | slt->ats_cost_wan = p->ats_cost_wan; | ||
648 | slt->ats_cost_wlan = p->ats_cost_wlan; | ||
649 | slt->ats_delay = p->ats_delay; | ||
650 | slt->ats_distance = p->ats_distance; | ||
651 | slt->ats_network_type = p->ats_network_type; | ||
652 | slt->ats_utilization_down = p->ats_utilization_down; | ||
653 | slt->ats_utilization_up = p->ats_utilization_up; | ||
654 | slt->bandwidth_in = p->bandwidth_in; | ||
655 | slt->bandwidth_out = p->bandwidth_out; | ||
656 | |||
657 | /* Total application level rtt */ | ||
658 | if (NULL == prev_log_mlt) | ||
659 | { | ||
660 | if (0 != slt->total_messages_sent) | ||
661 | app_rtt = slt->total_app_rtt / slt->total_messages_sent; | ||
662 | else | ||
663 | app_rtt = 0; | ||
664 | } | ||
665 | else | ||
666 | { | ||
667 | prev_log_slt = &prev_log_mlt->slaves_log[c_s]; | ||
668 | if ((slt->total_messages_sent - prev_log_slt->total_messages_sent) > 0) | ||
669 | app_rtt = (slt->total_app_rtt - prev_log_slt->total_app_rtt) | ||
670 | / (slt->total_messages_sent | ||
671 | - prev_log_slt->total_messages_sent); | ||
672 | else | ||
673 | app_rtt = prev_log_slt->app_rtt; /* No messages were */ | ||
674 | } | ||
675 | slt->app_rtt = app_rtt; | ||
676 | |||
677 | /* Partner throughput */ | ||
678 | if (NULL != prev_log_mlt) | ||
679 | { | ||
680 | prev_log_slt = &prev_log_mlt->slaves_log[c_s]; | ||
681 | if (slt->total_bytes_sent - prev_log_slt->total_bytes_sent > 0) | ||
682 | slt->throughput_sent = mult * (slt->total_bytes_sent | ||
683 | - prev_log_slt->total_bytes_sent); | ||
684 | else | ||
685 | slt->throughput_sent = prev_log_slt->throughput_sent; /* no msgs send */ | ||
686 | |||
687 | if (slt->total_bytes_received - prev_log_slt->total_bytes_received > 0) | ||
688 | slt->throughput_recv = mult * (slt->total_bytes_received | ||
689 | - prev_log_slt->total_bytes_received); | ||
690 | else | ||
691 | slt->throughput_recv = prev_log_slt->throughput_recv; /* no msgs received */ | ||
692 | } | ||
693 | else | ||
694 | { | ||
695 | slt->throughput_sent = mult * slt->total_bytes_sent; | ||
696 | slt->throughput_sent = mult * slt->total_bytes_received; | ||
697 | } | ||
698 | |||
699 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
700 | "Master [%u]: slave [%u]\n", | ||
701 | bp->peer->no, p->dest->no); | ||
702 | } | ||
703 | } | ||
704 | } | ||
705 | |||
706 | |||
707 | static void | ||
708 | collect_log_task (void *cls) | ||
709 | { | ||
710 | log_task = NULL; | ||
711 | collect_log_now (); | ||
712 | log_task = GNUNET_SCHEDULER_add_delayed (frequency, | ||
713 | &collect_log_task, NULL); | ||
714 | } | ||
715 | |||
716 | |||
717 | void | ||
718 | perf_logging_stop () | ||
719 | { | ||
720 | int c_m; | ||
721 | struct PeerLoggingTimestep *cur; | ||
722 | |||
723 | if (GNUNET_YES != running) | ||
724 | return; | ||
725 | |||
726 | if (NULL != log_task) | ||
727 | { | ||
728 | GNUNET_SCHEDULER_cancel (log_task); | ||
729 | log_task = NULL; | ||
730 | } | ||
731 | collect_log_task (NULL); | ||
732 | |||
733 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
734 | _ ("Stop logging\n")); | ||
735 | |||
736 | write_to_file (); | ||
737 | |||
738 | for (c_m = 0; c_m < num_peers; c_m++) | ||
739 | { | ||
740 | while (NULL != (cur = lp[c_m].head)) | ||
741 | { | ||
742 | GNUNET_CONTAINER_DLL_remove (lp[c_m].head, lp[c_m].tail, cur); | ||
743 | GNUNET_free (cur->slaves_log); | ||
744 | GNUNET_free (cur); | ||
745 | } | ||
746 | } | ||
747 | |||
748 | GNUNET_free (lp); | ||
749 | } | ||
750 | |||
751 | |||
752 | void | ||
753 | perf_logging_start (struct GNUNET_TIME_Relative log_frequency, | ||
754 | char *testname, struct BenchmarkPeer *masters, int | ||
755 | num_masters) | ||
756 | { | ||
757 | int c_m; | ||
758 | |||
759 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
760 | _ ("Start logging `%s'\n"), testname); | ||
761 | |||
762 | num_peers = num_masters; | ||
763 | name = testname; | ||
764 | frequency = log_frequency; | ||
765 | |||
766 | lp = GNUNET_malloc (num_masters * sizeof(struct LoggingPeer)); | ||
767 | |||
768 | for (c_m = 0; c_m < num_masters; c_m++) | ||
769 | { | ||
770 | lp[c_m].peer = &masters[c_m]; | ||
771 | lp[c_m].start = GNUNET_TIME_absolute_get (); | ||
772 | } | ||
773 | |||
774 | /* Schedule logging task */ | ||
775 | log_task = GNUNET_SCHEDULER_add_now (&collect_log_task, NULL); | ||
776 | running = GNUNET_YES; | ||
777 | } | ||
778 | |||
779 | |||
780 | /* end of file perf_ats_logging.c */ | ||
diff --git a/src/ats-tests/perf_ats_proportional_bandwidth.conf b/src/ats-tests/perf_ats_proportional_bandwidth.conf deleted file mode 100644 index dba96c0fe..000000000 --- a/src/ats-tests/perf_ats_proportional_bandwidth.conf +++ /dev/null | |||
@@ -1,4 +0,0 @@ | |||
1 | @INLINE@ template_perf_ats.conf | ||
2 | |||
3 | [ats] | ||
4 | MODE = proportional | ||
diff --git a/src/ats-tests/perf_ats_proportional_latency.conf b/src/ats-tests/perf_ats_proportional_latency.conf deleted file mode 100644 index dba96c0fe..000000000 --- a/src/ats-tests/perf_ats_proportional_latency.conf +++ /dev/null | |||
@@ -1,4 +0,0 @@ | |||
1 | @INLINE@ template_perf_ats.conf | ||
2 | |||
3 | [ats] | ||
4 | MODE = proportional | ||
diff --git a/src/ats-tests/perf_ats_proportional_none.conf b/src/ats-tests/perf_ats_proportional_none.conf deleted file mode 100644 index dba96c0fe..000000000 --- a/src/ats-tests/perf_ats_proportional_none.conf +++ /dev/null | |||
@@ -1,4 +0,0 @@ | |||
1 | @INLINE@ template_perf_ats.conf | ||
2 | |||
3 | [ats] | ||
4 | MODE = proportional | ||
diff --git a/src/ats-tests/template_perf_ats.conf b/src/ats-tests/template_perf_ats.conf deleted file mode 100644 index 74f608bfb..000000000 --- a/src/ats-tests/template_perf_ats.conf +++ /dev/null | |||
@@ -1,52 +0,0 @@ | |||
1 | @INLINE@ ../../contrib/conf/gnunet/no_forcestart.conf | ||
2 | |||
3 | [testbed] | ||
4 | # How long should operations wait? | ||
5 | OPERATION_TIMEOUT = 60 s | ||
6 | |||
7 | [transport-udp] | ||
8 | BROADCAST = NO | ||
9 | |||
10 | [peerinfo] | ||
11 | USE_INCLUDED_HELLOS = NO | ||
12 | |||
13 | [transport] | ||
14 | #PREFIX = valgrind --leak-check=yes | ||
15 | |||
16 | [ats] | ||
17 | # PREFIX = valgrind | ||
18 | |||
19 | # Network specific inbound/outbound quotas | ||
20 | UNSPECIFIED_QUOTA_IN = 128 KiB | ||
21 | UNSPECIFIED_QUOTA_OUT = 128 KiB | ||
22 | # LOOPBACK | ||
23 | LOOPBACK_QUOTA_IN = 128 KiB | ||
24 | LOOPBACK_QUOTA_OUT = 128 KiB | ||
25 | # LAN | ||
26 | LAN_QUOTA_IN = 128 KiB | ||
27 | LAN_QUOTA_OUT = 128 KiB | ||
28 | # WAN | ||
29 | WAN_QUOTA_IN = 128 KiB | ||
30 | WAN_QUOTA_OUT = 128 KiB | ||
31 | # WLAN | ||
32 | WLAN_QUOTA_IN = 128 KiB | ||
33 | WLAN_QUOTA_OUT = 128 KiB | ||
34 | # BLUETOOTH | ||
35 | BLUETOOTH_QUOTA_IN = 128 KiB | ||
36 | BLUETOOTH_QUOTA_OUT = 128 KiB | ||
37 | |||
38 | [transport-blacklist-M1RGJB4FQSM17JJ3M9BF7Q0I8MCO8C462NMOHI26RLT7C7A2KE6HCOPRA4ARM5HPL1J9IDDK5G8SFU5GUSHCTBH90ECETK1BFQD76R0] | ||
39 | HIJN5O404QNUR37OSJUTNJ6H2KJS198DHI2J3I8SE3DMKVRG1RNQPODN1IJBF14KEMPPPRM0B9F9ILFKHOFCA655CH6M5OCNCMR0FE0 = | ||
40 | CDTU8QQ8UPLGHR3B91V0CLTDOHONLB8QGHGUEM2JM1GANTEV0O6T20SD2N2HDN2QSHDG6IDTBR48KRDCS601FI6VHG59E7DQA98JD2O = | ||
41 | |||
42 | [transport-blacklist-93ARIS6Q347RPU9EFPS9LA00VPHQLG3RBLKEKTHV4D6UVGEAC75KIIBFB5U9KK9P9P1RU1CBPV4BSSDUTB2AL2N2LG9KSO9APQNLS0O] | ||
43 | HIJN5O404QNUR37OSJUTNJ6H2KJS198DHI2J3I8SE3DMKVRG1RNQPODN1IJBF14KEMPPPRM0B9F9ILFKHOFCA655CH6M5OCNCMR0FE0 = | ||
44 | CDTU8QQ8UPLGHR3B91V0CLTDOHONLB8QGHGUEM2JM1GANTEV0O6T20SD2N2HDN2QSHDG6IDTBR48KRDCS601FI6VHG59E7DQA98JD2O = | ||
45 | |||
46 | [transport-blacklist-OF84RAOAU2B1SOSEHJH6350MA0F7C98U55RI76LGIQOM7O33TFHPNUFB47CDBSCOLIINMVJ2U82445ABOBQRIVREG20L31KVDV5HG60] | ||
47 | HIJN5O404QNUR37OSJUTNJ6H2KJS198DHI2J3I8SE3DMKVRG1RNQPODN1IJBF14KEMPPPRM0B9F9ILFKHOFCA655CH6M5OCNCMR0FE0 = | ||
48 | CDTU8QQ8UPLGHR3B91V0CLTDOHONLB8QGHGUEM2JM1GANTEV0O6T20SD2N2HDN2QSHDG6IDTBR48KRDCS601FI6VHG59E7DQA98JD2O = | ||
49 | |||
50 | [transport-blacklist-548J7M14O4I0F8I84U0UFARVJ97DB6QOT3MCA8O8SNAIT5JJ8TR95LUVAP3N5L7DN33IB49SNMF3Q3C0VPLTGP9ASCULA9S2OIMHHH8] | ||
51 | HIJN5O404QNUR37OSJUTNJ6H2KJS198DHI2J3I8SE3DMKVRG1RNQPODN1IJBF14KEMPPPRM0B9F9ILFKHOFCA655CH6M5OCNCMR0FE0 = | ||
52 | CDTU8QQ8UPLGHR3B91V0CLTDOHONLB8QGHGUEM2JM1GANTEV0O6T20SD2N2HDN2QSHDG6IDTBR48KRDCS601FI6VHG59E7DQA98JD2O = | ||
diff --git a/src/block/Makefile.am b/src/block/Makefile.am index ceeff4c66..ea796bf8f 100644 --- a/src/block/Makefile.am +++ b/src/block/Makefile.am | |||
@@ -26,10 +26,6 @@ libgnunet_plugin_block_template_la_LIBADD = \ | |||
26 | libgnunetblock.la \ | 26 | libgnunetblock.la \ |
27 | $(top_builddir)/src/util/libgnunetutil.la \ | 27 | $(top_builddir)/src/util/libgnunetutil.la \ |
28 | $(LTLIBINTL) | 28 | $(LTLIBINTL) |
29 | libgnunet_plugin_block_template_la_DEPENDENCIES = \ | ||
30 | libgnunetblockgroup.la \ | ||
31 | libgnunetblock.la \ | ||
32 | $(top_builddir)/src/util/libgnunetutil.la | ||
33 | libgnunet_plugin_block_template_la_LDFLAGS = \ | 29 | libgnunet_plugin_block_template_la_LDFLAGS = \ |
34 | $(GN_PLUGIN_LDFLAGS) | 30 | $(GN_PLUGIN_LDFLAGS) |
35 | 31 | ||
@@ -40,10 +36,6 @@ libgnunet_plugin_block_test_la_LIBADD = \ | |||
40 | libgnunetblock.la \ | 36 | libgnunetblock.la \ |
41 | $(top_builddir)/src/util/libgnunetutil.la \ | 37 | $(top_builddir)/src/util/libgnunetutil.la \ |
42 | $(LTLIBINTL) | 38 | $(LTLIBINTL) |
43 | libgnunet_plugin_block_test_la_DEPENDENCIES = \ | ||
44 | libgnunetblockgroup.la \ | ||
45 | libgnunetblock.la \ | ||
46 | $(top_builddir)/src/util/libgnunetutil.la | ||
47 | libgnunet_plugin_block_test_la_LDFLAGS = \ | 39 | libgnunet_plugin_block_test_la_LDFLAGS = \ |
48 | $(GN_PLUGIN_LDFLAGS) | 40 | $(GN_PLUGIN_LDFLAGS) |
49 | 41 | ||
@@ -51,8 +43,6 @@ libgnunetblock_la_SOURCES = \ | |||
51 | block.c | 43 | block.c |
52 | libgnunetblock_la_LIBADD = \ | 44 | libgnunetblock_la_LIBADD = \ |
53 | $(top_builddir)/src/util/libgnunetutil.la | 45 | $(top_builddir)/src/util/libgnunetutil.la |
54 | libgnunetblock_la_DEPENDENCIES = \ | ||
55 | $(top_builddir)/src/util/libgnunetutil.la | ||
56 | libgnunetblock_la_LDFLAGS = \ | 46 | libgnunetblock_la_LDFLAGS = \ |
57 | $(GN_LIB_LDFLAGS) \ | 47 | $(GN_LIB_LDFLAGS) \ |
58 | $(GN_LIBINTL) \ | 48 | $(GN_LIBINTL) \ |
@@ -63,9 +53,6 @@ libgnunetblockgroup_la_SOURCES = \ | |||
63 | libgnunetblockgroup_la_LIBADD = \ | 53 | libgnunetblockgroup_la_LIBADD = \ |
64 | libgnunetblock.la \ | 54 | libgnunetblock.la \ |
65 | $(top_builddir)/src/util/libgnunetutil.la | 55 | $(top_builddir)/src/util/libgnunetutil.la |
66 | libgnunetblockgroup_la_DEPENDENCIES = \ | ||
67 | libgnunetblock.la \ | ||
68 | $(top_builddir)/src/util/libgnunetutil.la | ||
69 | libgnunetblockgroup_la_LDFLAGS = \ | 56 | libgnunetblockgroup_la_LDFLAGS = \ |
70 | $(GN_LIB_LDFLAGS) \ | 57 | $(GN_LIB_LDFLAGS) \ |
71 | $(GN_LIBINTL) \ | 58 | $(GN_LIBINTL) \ |
diff --git a/src/dns/Makefile.am b/src/dns/Makefile.am index 45107304b..f8672d55e 100644 --- a/src/dns/Makefile.am +++ b/src/dns/Makefile.am | |||
@@ -83,10 +83,6 @@ libgnunet_plugin_block_dns_la_LIBADD = \ | |||
83 | $(top_builddir)/src/block/libgnunetblockgroup.la \ | 83 | $(top_builddir)/src/block/libgnunetblockgroup.la \ |
84 | $(top_builddir)/src/block/libgnunetblock.la \ | 84 | $(top_builddir)/src/block/libgnunetblock.la \ |
85 | $(top_builddir)/src/util/libgnunetutil.la | 85 | $(top_builddir)/src/util/libgnunetutil.la |
86 | libgnunet_plugin_block_dns_la_DEPENDENCIES = \ | ||
87 | $(top_builddir)/src/block/libgnunetblockgroup.la \ | ||
88 | $(top_builddir)/src/block/libgnunetblock.la \ | ||
89 | $(top_builddir)/src/util/libgnunetutil.la | ||
90 | libgnunet_plugin_block_dns_la_LDFLAGS = \ | 86 | libgnunet_plugin_block_dns_la_LDFLAGS = \ |
91 | $(GN_LIBINTL) \ | 87 | $(GN_LIBINTL) \ |
92 | $(top_builddir)/src/block/$(GN_PLUGIN_LDFLAGS) | 88 | $(top_builddir)/src/block/$(GN_PLUGIN_LDFLAGS) |
@@ -99,5 +95,3 @@ endif | |||
99 | 95 | ||
100 | EXTRA_DIST = \ | 96 | EXTRA_DIST = \ |
101 | $(check_SCRIPTS) | 97 | $(check_SCRIPTS) |
102 | |||
103 | |||
diff --git a/src/fs/Makefile.am b/src/fs/Makefile.am index 2400d412e..5b6ba2376 100644 --- a/src/fs/Makefile.am +++ b/src/fs/Makefile.am | |||
@@ -49,10 +49,6 @@ libgnunetfs_la_LIBADD = \ | |||
49 | $(top_builddir)/src/statistics/libgnunetstatistics.la \ | 49 | $(top_builddir)/src/statistics/libgnunetstatistics.la \ |
50 | $(top_builddir)/src/util/libgnunetutil.la \ | 50 | $(top_builddir)/src/util/libgnunetutil.la \ |
51 | $(GN_LIBINTL) $(XLIB) $(LIBGCRYPT_LIBS) -lunistring | 51 | $(GN_LIBINTL) $(XLIB) $(LIBGCRYPT_LIBS) -lunistring |
52 | libgnunetfs_la_DEPENDENCIES = \ | ||
53 | $(top_builddir)/src/datastore/libgnunetdatastore.la \ | ||
54 | $(top_builddir)/src/statistics/libgnunetstatistics.la \ | ||
55 | $(top_builddir)/src/util/libgnunetutil.la | ||
56 | 52 | ||
57 | if HAVE_LIBEXTRACTOR | 53 | if HAVE_LIBEXTRACTOR |
58 | libgnunetfs_la_LIBADD += \ | 54 | libgnunetfs_la_LIBADD += \ |
diff --git a/src/gnsrecord/Makefile.am b/src/gnsrecord/Makefile.am index 27f5446a1..42ac4ede4 100644 --- a/src/gnsrecord/Makefile.am +++ b/src/gnsrecord/Makefile.am | |||
@@ -53,8 +53,6 @@ libgnunetgnsrecord_la_LIBADD = \ | |||
53 | $(LIBGCRYPT_LIBS) \ | 53 | $(LIBGCRYPT_LIBS) \ |
54 | -lsodium \ | 54 | -lsodium \ |
55 | $(GN_LIBINTL) | 55 | $(GN_LIBINTL) |
56 | libgnunetgnsrecord_la_DEPENDENCIES = \ | ||
57 | $(top_builddir)/src/identity/libgnunetidentity.la | ||
58 | libgnunetgnsrecord_la_LDFLAGS = \ | 56 | libgnunetgnsrecord_la_LDFLAGS = \ |
59 | $(GN_LIB_LDFLAGS) \ | 57 | $(GN_LIB_LDFLAGS) \ |
60 | -version-info 0:0:0 | 58 | -version-info 0:0:0 |
diff --git a/src/peerinfo-tool/Makefile.am b/src/peerinfo-tool/Makefile.am index 74af5890b..825ad5452 100644 --- a/src/peerinfo-tool/Makefile.am +++ b/src/peerinfo-tool/Makefile.am | |||
@@ -26,14 +26,6 @@ libgnunet_plugin_rest_peerinfo_la_LIBADD = \ | |||
26 | $(top_builddir)/src/json/libgnunetjson.la \ | 26 | $(top_builddir)/src/json/libgnunetjson.la \ |
27 | $(top_builddir)/src/util/libgnunetutil.la $(XLIBS) \ | 27 | $(top_builddir)/src/util/libgnunetutil.la $(XLIBS) \ |
28 | $(LTLIBINTL) -ljansson $(MHD_LIBS) | 28 | $(LTLIBINTL) -ljansson $(MHD_LIBS) |
29 | libgnunet_plugin_rest_peerinfo_la_DEPENDENCIES = \ | ||
30 | $(top_builddir)/src/hello/libgnunethello.la \ | ||
31 | $(top_builddir)/src/peerinfo/libgnunetpeerinfo.la \ | ||
32 | $(top_builddir)/src/transport/libgnunettransport.la \ | ||
33 | $(top_builddir)/src/ats/libgnunetats.la \ | ||
34 | $(top_builddir)/src/rest/libgnunetrest.la \ | ||
35 | $(top_builddir)/src/json/libgnunetjson.la \ | ||
36 | $(top_builddir)/src/util/libgnunetutil.la | ||
37 | libgnunet_plugin_rest_peerinfo_la_LDFLAGS = \ | 29 | libgnunet_plugin_rest_peerinfo_la_LDFLAGS = \ |
38 | $(GN_PLUGIN_LDFLAGS) | 30 | $(GN_PLUGIN_LDFLAGS) |
39 | libgnunet_plugin_rest_peerinfo_la_CFLAGS = $(MHD_CFLAGS) $(AM_CFLAGS) | 31 | libgnunet_plugin_rest_peerinfo_la_CFLAGS = $(MHD_CFLAGS) $(AM_CFLAGS) |
diff --git a/src/reclaim/Makefile.am b/src/reclaim/Makefile.am index 1a0b7fae4..350d77d4b 100644 --- a/src/reclaim/Makefile.am +++ b/src/reclaim/Makefile.am | |||
@@ -61,14 +61,6 @@ libgnunet_plugin_rest_reclaim_la_LIBADD = \ | |||
61 | $(top_builddir)/src/namestore/libgnunetnamestore.la \ | 61 | $(top_builddir)/src/namestore/libgnunetnamestore.la \ |
62 | $(top_builddir)/src/util/libgnunetutil.la $(XLIBS) \ | 62 | $(top_builddir)/src/util/libgnunetutil.la $(XLIBS) \ |
63 | $(LTLIBINTL) -ljansson $(MHD_LIBS) | 63 | $(LTLIBINTL) -ljansson $(MHD_LIBS) |
64 | libgnunet_plugin_rest_reclaim_la_DEPENDENCIES = \ | ||
65 | $(top_builddir)/src/identity/libgnunetidentity.la \ | ||
66 | libgnunetreclaim.la \ | ||
67 | $(top_builddir)/src/json/libgnunetjson.la \ | ||
68 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ | ||
69 | $(top_builddir)/src/rest/libgnunetrest.la \ | ||
70 | $(top_builddir)/src/namestore/libgnunetnamestore.la \ | ||
71 | $(top_builddir)/src/util/libgnunetutil.la | ||
72 | libgnunet_plugin_rest_reclaim_la_LDFLAGS = \ | 64 | libgnunet_plugin_rest_reclaim_la_LDFLAGS = \ |
73 | $(GN_PLUGIN_LDFLAGS) | 65 | $(GN_PLUGIN_LDFLAGS) |
74 | libgnunet_plugin_rest_reclaim_la_CFLAGS = $(MHD_CFLAGS) $(AM_CFLAGS) | 66 | libgnunet_plugin_rest_reclaim_la_CFLAGS = $(MHD_CFLAGS) $(AM_CFLAGS) |
@@ -102,11 +94,6 @@ libgnunet_plugin_rest_pabc_la_LIBADD = \ | |||
102 | $(top_builddir)/src/rest/libgnunetrest.la \ | 94 | $(top_builddir)/src/rest/libgnunetrest.la \ |
103 | $(top_builddir)/src/util/libgnunetutil.la $(XLIBS) \ | 95 | $(top_builddir)/src/util/libgnunetutil.la $(XLIBS) \ |
104 | $(LTLIBINTL) -ljansson -lpabc $(MHD_LIBS) | 96 | $(LTLIBINTL) -ljansson -lpabc $(MHD_LIBS) |
105 | libgnunet_plugin_rest_pabc_la_DEPENDENCIES = \ | ||
106 | libgnunetreclaim.la \ | ||
107 | $(top_builddir)/src/json/libgnunetjson.la \ | ||
108 | $(top_builddir)/src/rest/libgnunetrest.la \ | ||
109 | $(top_builddir)/src/util/libgnunetutil.la | ||
110 | libgnunet_plugin_rest_pabc_la_LDFLAGS = \ | 97 | libgnunet_plugin_rest_pabc_la_LDFLAGS = \ |
111 | $(GN_PLUGIN_LDFLAGS) | 98 | $(GN_PLUGIN_LDFLAGS) |
112 | libgnunet_plugin_rest_pabc_la_CFLAGS = $(MHD_CFLAGS) $(AM_CFLAGS) | 99 | libgnunet_plugin_rest_pabc_la_CFLAGS = $(MHD_CFLAGS) $(AM_CFLAGS) |
diff --git a/src/regex/Makefile.am b/src/regex/Makefile.am index 0b55d134f..9a7466cb2 100644 --- a/src/regex/Makefile.am +++ b/src/regex/Makefile.am | |||
@@ -53,9 +53,6 @@ libgnunetregex_internal_a_SOURCES = \ | |||
53 | regex_internal_lib.h \ | 53 | regex_internal_lib.h \ |
54 | regex_internal.h regex_internal.c \ | 54 | regex_internal.h regex_internal.c \ |
55 | regex_internal_dht.c | 55 | regex_internal_dht.c |
56 | libgnunetregex_internal_a_DEPENDENCIES = \ | ||
57 | libgnunetregexblock.la | ||
58 | |||
59 | 56 | ||
60 | libgnunetregex_la_SOURCES = \ | 57 | libgnunetregex_la_SOURCES = \ |
61 | regex_api_announce.c \ | 58 | regex_api_announce.c \ |
diff --git a/src/revocation/Makefile.am b/src/revocation/Makefile.am index b1a079a0d..d0c58584e 100644 --- a/src/revocation/Makefile.am +++ b/src/revocation/Makefile.am | |||
@@ -32,11 +32,6 @@ libgnunet_plugin_block_revocation_la_LIBADD = \ | |||
32 | $(top_builddir)/src/util/libgnunetutil.la \ | 32 | $(top_builddir)/src/util/libgnunetutil.la \ |
33 | $(top_builddir)/src/identity/libgnunetidentity.la \ | 33 | $(top_builddir)/src/identity/libgnunetidentity.la \ |
34 | $(LTLIBINTL) | 34 | $(LTLIBINTL) |
35 | libgnunet_plugin_block_revocation_la_DEPENDENCIES = \ | ||
36 | libgnunetrevocation.la \ | ||
37 | $(top_builddir)/src/block/libgnunetblockgroup.la \ | ||
38 | $(top_builddir)/src/block/libgnunetblock.la \ | ||
39 | $(top_builddir)/src/util/libgnunetutil.la | ||
40 | libgnunet_plugin_block_revocation_la_LDFLAGS = \ | 35 | libgnunet_plugin_block_revocation_la_LDFLAGS = \ |
41 | $(GN_PLUGIN_LDFLAGS) | 36 | $(GN_PLUGIN_LDFLAGS) |
42 | 37 | ||
diff --git a/src/testbed/Makefile.am b/src/testbed/Makefile.am index d1f43f0f6..11399e77c 100644 --- a/src/testbed/Makefile.am +++ b/src/testbed/Makefile.am | |||
@@ -115,12 +115,6 @@ libgnunettestbed_la_LIBADD = $(XLIB) \ | |||
115 | $(top_builddir)/src/arm/libgnunetarm.la \ | 115 | $(top_builddir)/src/arm/libgnunetarm.la \ |
116 | $(top_builddir)/src/util/libgnunetutil.la \ | 116 | $(top_builddir)/src/util/libgnunetutil.la \ |
117 | $(LTLIBINTL) | 117 | $(LTLIBINTL) |
118 | libgnunettestbed_la_DEPENDENCIES = \ | ||
119 | $(top_builddir)/src/statistics/libgnunetstatistics.la \ | ||
120 | $(top_builddir)/src/transport/libgnunettransport.la \ | ||
121 | $(top_builddir)/src/hello/libgnunethello.la \ | ||
122 | $(top_builddir)/src/testing/libgnunettesting.la \ | ||
123 | $(top_builddir)/src/util/libgnunetutil.la | ||
124 | libgnunettestbed_la_LDFLAGS = \ | 118 | libgnunettestbed_la_LDFLAGS = \ |
125 | $(GN_LIB_LDFLAGS) \ | 119 | $(GN_LIB_LDFLAGS) \ |
126 | -version-info 0:0:0 | 120 | -version-info 0:0:0 |
diff --git a/src/testing/Makefile.am b/src/testing/Makefile.am index c01e9bdbd..6e0f29c4e 100644 --- a/src/testing/Makefile.am +++ b/src/testing/Makefile.am | |||
@@ -62,9 +62,6 @@ libgnunettesting_la_LIBADD = \ | |||
62 | $(top_builddir)/src/arm/libgnunetarm.la \ | 62 | $(top_builddir)/src/arm/libgnunetarm.la \ |
63 | $(top_builddir)/src/util/libgnunetutil.la \ | 63 | $(top_builddir)/src/util/libgnunetutil.la \ |
64 | $(LTLIBINTL) | 64 | $(LTLIBINTL) |
65 | libgnunettesting_la_DEPENDENCIES = \ | ||
66 | $(top_builddir)/src/arm/libgnunetarm.la \ | ||
67 | $(top_builddir)/src/util/libgnunetutil.la | ||
68 | libgnunettesting_la_LDFLAGS = \ | 65 | libgnunettesting_la_LDFLAGS = \ |
69 | $(GN_LIB_LDFLAGS) \ | 66 | $(GN_LIB_LDFLAGS) \ |
70 | -version-info 2:0:1 | 67 | -version-info 2:0:1 |
diff --git a/src/testing/testing_api_cmd_netjail_start_testsystem.c b/src/testing/testing_api_cmd_netjail_start_testsystem.c index 01bac9b05..0fe0541b0 100644 --- a/src/testing/testing_api_cmd_netjail_start_testsystem.c +++ b/src/testing/testing_api_cmd_netjail_start_testsystem.c | |||
@@ -191,7 +191,7 @@ struct TestingSystemCount | |||
191 | }; | 191 | }; |
192 | 192 | ||
193 | /** | 193 | /** |
194 | * Code to clean up ressource this cmd used. | 194 | * Code to clean up resource this cmd used. |
195 | * | 195 | * |
196 | * @param cls closure | 196 | * @param cls closure |
197 | * @param cmd current CMD being cleaned up. | 197 | * @param cmd current CMD being cleaned up. |
@@ -276,6 +276,7 @@ GNUNET_TESTING_get_trait_helper_handles (const struct | |||
276 | (unsigned int) 0); | 276 | (unsigned int) 0); |
277 | } | 277 | } |
278 | 278 | ||
279 | |||
279 | /** | 280 | /** |
280 | * Offer messages received via testing cmd helper from trait | 281 | * Offer messages received via testing cmd helper from trait |
281 | * | 282 | * |
@@ -362,6 +363,7 @@ helper_mst (void *cls, const struct GNUNET_MessageHeader *message) | |||
362 | return GNUNET_OK; | 363 | return GNUNET_OK; |
363 | } | 364 | } |
364 | 365 | ||
366 | |||
365 | /** | 367 | /** |
366 | * Callback called if there was an exception during execution of the helper. | 368 | * Callback called if there was an exception during execution of the helper. |
367 | * | 369 | * |
@@ -374,6 +376,7 @@ exp_cb (void *cls) | |||
374 | *ns->rv = 1; | 376 | *ns->rv = 1; |
375 | } | 377 | } |
376 | 378 | ||
379 | |||
377 | /** | 380 | /** |
378 | * Function to initialize a init message for the helper. | 381 | * Function to initialize a init message for the helper. |
379 | * | 382 | * |
@@ -506,7 +509,8 @@ netjail_exec_run (void *cls, | |||
506 | struct GNUNET_CONFIGURATION_Handle *config = | 509 | struct GNUNET_CONFIGURATION_Handle *config = |
507 | GNUNET_CONFIGURATION_create (); | 510 | GNUNET_CONFIGURATION_create (); |
508 | 511 | ||
509 | for (int i = 1; i <= atoi (ns->global_n); i++) { | 512 | for (int i = 1; i <= atoi (ns->global_n); i++) |
513 | { | ||
510 | for (int j = 1; j <= atoi (ns->local_m); j++) | 514 | for (int j = 1; j <= atoi (ns->local_m); j++) |
511 | { | 515 | { |
512 | sprintf (str_n, "%d", i); | 516 | sprintf (str_n, "%d", i); |
@@ -554,7 +558,8 @@ netjail_start_finish (void *cls, | |||
554 | 558 | ||
555 | if (ns->number_of_peers_started == total_number) | 559 | if (ns->number_of_peers_started == total_number) |
556 | { | 560 | { |
557 | for (int i = 1; i <= atoi (ns->global_n); i++) { | 561 | for (int i = 1; i <= atoi (ns->global_n); i++) |
562 | { | ||
558 | for (int j = 1; j <= atoi (ns->local_m); j++) | 563 | for (int j = 1; j <= atoi (ns->local_m); j++) |
559 | { | 564 | { |
560 | tbc = GNUNET_new (struct TestingSystemCount); | 565 | tbc = GNUNET_new (struct TestingSystemCount); |
diff --git a/src/testing/testing_api_cmd_netjail_stop_testsystem.c b/src/testing/testing_api_cmd_netjail_stop_testsystem.c index d6e733e05..0ae82a26a 100644 --- a/src/testing/testing_api_cmd_netjail_stop_testsystem.c +++ b/src/testing/testing_api_cmd_netjail_stop_testsystem.c | |||
@@ -49,7 +49,7 @@ struct StopHelperState | |||
49 | 49 | ||
50 | 50 | ||
51 | /** | 51 | /** |
52 | * Code to clean up ressource this cmd used. | 52 | * Code to clean up resource this cmd used. |
53 | * | 53 | * |
54 | * @param cls closure | 54 | * @param cls closure |
55 | * @param cmd current CMD being cleaned up. | 55 | * @param cmd current CMD being cleaned up. |
@@ -97,7 +97,8 @@ stop_testing_system_run (void *cls, | |||
97 | GNUNET_TESTING_get_trait_helper_handles (start_helper_cmd, | 97 | GNUNET_TESTING_get_trait_helper_handles (start_helper_cmd, |
98 | &helper); | 98 | &helper); |
99 | 99 | ||
100 | for (int i = 1; i <= atoi (shs->global_n); i++) { | 100 | for (int i = 1; i <= atoi (shs->global_n); i++) |
101 | { | ||
101 | for (int j = 1; j <= atoi (shs->local_m); j++) | 102 | for (int j = 1; j <= atoi (shs->local_m); j++) |
102 | { | 103 | { |
103 | GNUNET_HELPER_stop (helper[(i - 1) * atoi (shs->local_m) + j - 1], | 104 | GNUNET_HELPER_stop (helper[(i - 1) * atoi (shs->local_m) + j - 1], |
diff --git a/src/transport/Makefile.am b/src/transport/Makefile.am index afa37bac5..70687f7b5 100644 --- a/src/transport/Makefile.am +++ b/src/transport/Makefile.am | |||
@@ -156,13 +156,6 @@ libgnunettransporttesting_la_LIBADD = \ | |||
156 | $(top_builddir)/src/testing/libgnunettesting.la \ | 156 | $(top_builddir)/src/testing/libgnunettesting.la \ |
157 | $(top_builddir)/src/arm/libgnunetarm.la \ | 157 | $(top_builddir)/src/arm/libgnunetarm.la \ |
158 | $(GN_LIBINTL) | 158 | $(GN_LIBINTL) |
159 | libgnunettransporttesting_la_DEPENDENCIES = \ | ||
160 | libgnunettransport.la \ | ||
161 | $(top_builddir)/src/hello/libgnunethello.la \ | ||
162 | $(top_builddir)/src/ats/libgnunetats.la \ | ||
163 | $(top_builddir)/src/util/libgnunetutil.la \ | ||
164 | $(top_builddir)/src/testing/libgnunettesting.la \ | ||
165 | $(top_builddir)/src/arm/libgnunetarm.la | ||
166 | libgnunettransporttesting_la_LDFLAGS = \ | 159 | libgnunettransporttesting_la_LDFLAGS = \ |
167 | $(GN_LIB_LDFLAGS) | 160 | $(GN_LIB_LDFLAGS) |
168 | 161 | ||
@@ -190,7 +183,8 @@ libgnunettransporttesting2_la_LIBADD = \ | |||
190 | $(top_builddir)/src/util/libgnunetutil.la | 183 | $(top_builddir)/src/util/libgnunetutil.la |
191 | libgnunettransporttesting2_la_LDFLAGS = \ | 184 | libgnunettransporttesting2_la_LDFLAGS = \ |
192 | $(GN_LIBINTL) \ | 185 | $(GN_LIBINTL) \ |
193 | $(GN_LIB_LDFLAGS) | 186 | $(GN_LIB_LDFLAGS) \ |
187 | -version-info 0:0:0 | ||
194 | 188 | ||
195 | libgnunettransport_la_SOURCES = \ | 189 | libgnunettransport_la_SOURCES = \ |
196 | transport.h \ | 190 | transport.h \ |
@@ -208,10 +202,6 @@ libgnunettransport_la_LIBADD = \ | |||
208 | $(top_builddir)/src/ats/libgnunetats.la \ | 202 | $(top_builddir)/src/ats/libgnunetats.la \ |
209 | $(top_builddir)/src/util/libgnunetutil.la \ | 203 | $(top_builddir)/src/util/libgnunetutil.la \ |
210 | $(GN_LIBINTL) | 204 | $(GN_LIBINTL) |
211 | libgnunettransport_la_DEPENDENCIES = \ | ||
212 | $(top_builddir)/src/hello/libgnunethello.la \ | ||
213 | $(top_builddir)/src/ats/libgnunetats.la \ | ||
214 | $(top_builddir)/src/util/libgnunetutil.la | ||
215 | libgnunettransport_la_LDFLAGS = \ | 205 | libgnunettransport_la_LDFLAGS = \ |
216 | $(GN_LIB_LDFLAGS) \ | 206 | $(GN_LIB_LDFLAGS) \ |
217 | -version-info 4:0:2 | 207 | -version-info 4:0:2 |
@@ -406,16 +396,23 @@ plugin_LTLIBRARIES = \ | |||
406 | libgnunet_test_transport_plugin_cmd_simple_send_la_SOURCES = \ | 396 | libgnunet_test_transport_plugin_cmd_simple_send_la_SOURCES = \ |
407 | test_transport_plugin_cmd_simple_send.c | 397 | test_transport_plugin_cmd_simple_send.c |
408 | libgnunet_test_transport_plugin_cmd_simple_send_la_LIBADD = \ | 398 | libgnunet_test_transport_plugin_cmd_simple_send_la_LIBADD = \ |
409 | $(top_builddir)/src/util/libgnunetutil.la \ | 399 | libgnunettransporttesting2.la \ |
400 | libgnunettransportapplication.la \ | ||
401 | libgnunettransport.la \ | ||
410 | $(top_builddir)/src/testing/libgnunettesting.la \ | 402 | $(top_builddir)/src/testing/libgnunettesting.la \ |
403 | $(top_builddir)/src/peerstore/libgnunetpeerstore.la \ | ||
411 | $(top_builddir)/src/statistics/libgnunetstatistics.la \ | 404 | $(top_builddir)/src/statistics/libgnunetstatistics.la \ |
412 | libgnunettransporttesting2.la \ | 405 | $(top_builddir)/src/hello/libgnunethello.la \ |
406 | $(top_builddir)/src/ats/libgnunetats.la \ | ||
407 | $(top_builddir)/src/arm/libgnunetarm.la \ | ||
408 | $(top_builddir)/src/util/libgnunetutil.la \ | ||
413 | $(LTLIBINTL) | 409 | $(LTLIBINTL) |
414 | libgnunet_test_transport_plugin_cmd_simple_send_la_LDFLAGS = \ | 410 | libgnunet_test_transport_plugin_cmd_simple_send_la_LDFLAGS = \ |
415 | $(GN_PLUGIN_LDFLAGS) | 411 | $(GN_PLUGIN_LDFLAGS) |
416 | 412 | ||
417 | if HAVE_EXPERIMENTAL | 413 | if HAVE_EXPERIMENTAL |
418 | plugin_LTLIBRARIES += libgnunet_plugin_transport_udp.la | 414 | plugin_LTLIBRARIES += \ |
415 | libgnunet_plugin_transport_udp.la | ||
419 | endif | 416 | endif |
420 | 417 | ||
421 | # Note: real plugins of course need to be added | 418 | # Note: real plugins of course need to be added |
@@ -731,8 +728,8 @@ test_transport_api_cmd_simple_send_LDADD = \ | |||
731 | $(top_builddir)/src/testing/libgnunettesting.la \ | 728 | $(top_builddir)/src/testing/libgnunettesting.la \ |
732 | $(top_builddir)/src/util/libgnunetutil.la \ | 729 | $(top_builddir)/src/util/libgnunetutil.la \ |
733 | $(top_builddir)/src/testbed/libgnunettestbed.la \ | 730 | $(top_builddir)/src/testbed/libgnunettestbed.la \ |
734 | libgnunettransport.la \ | ||
735 | $(top_builddir)/src/hello/libgnunethello.la \ | 731 | $(top_builddir)/src/hello/libgnunethello.la \ |
732 | libgnunettransport.la \ | ||
736 | libgnunettransporttesting.la | 733 | libgnunettransporttesting.la |
737 | 734 | ||
738 | test_transport_testing_startstop_SOURCES = \ | 735 | test_transport_testing_startstop_SOURCES = \ |
diff --git a/src/transport/transport_api_cmd_start_peer.c b/src/transport/transport_api_cmd_start_peer.c index 9277bc346..729d981c0 100644 --- a/src/transport/transport_api_cmd_start_peer.c +++ b/src/transport/transport_api_cmd_start_peer.c | |||
@@ -69,9 +69,9 @@ hello_iter_cb (void *cb_cls, | |||
69 | } | 69 | } |
70 | 70 | ||
71 | 71 | ||
72 | |||
73 | /** | 72 | /** |
74 | * Function to start the retrival task to retrieve the hello of this peer from the peerstore. | 73 | * Function to start the retrieval task to retrieve the hello of this peer |
74 | * from the peerstore. | ||
75 | * | 75 | * |
76 | */ | 76 | */ |
77 | static void | 77 | static void |
@@ -170,6 +170,7 @@ notify_connect (void *cls, | |||
170 | return ret; | 170 | return ret; |
171 | } | 171 | } |
172 | 172 | ||
173 | |||
173 | /** | 174 | /** |
174 | * The run method of this cmd will start all services of a peer to test the transport service. | 175 | * The run method of this cmd will start all services of a peer to test the transport service. |
175 | * | 176 | * |
@@ -309,6 +310,7 @@ start_peer_run (void *cls, | |||
309 | sps->rh_task = GNUNET_SCHEDULER_add_now (retrieve_hello, sps); | 310 | sps->rh_task = GNUNET_SCHEDULER_add_now (retrieve_hello, sps); |
310 | } | 311 | } |
311 | 312 | ||
313 | |||
312 | /** | 314 | /** |
313 | * The cleanup function of this cmd frees resources the cmd allocated. | 315 | * The cleanup function of this cmd frees resources the cmd allocated. |
314 | * | 316 | * |
@@ -434,6 +436,7 @@ GNUNET_TRANSPORT_get_trait_hello_size (const struct | |||
434 | (unsigned int) 4); | 436 | (unsigned int) 4); |
435 | } | 437 | } |
436 | 438 | ||
439 | |||
437 | /** | 440 | /** |
438 | * Function to get the trait with the hello. | 441 | * Function to get the trait with the hello. |
439 | * | 442 | * |
diff --git a/src/util/Makefile.am b/src/util/Makefile.am index 89d040a0c..6d5307235 100644 --- a/src/util/Makefile.am +++ b/src/util/Makefile.am | |||
@@ -361,8 +361,6 @@ test_os_start_process_SOURCES = \ | |||
361 | test_os_start_process.c | 361 | test_os_start_process.c |
362 | test_os_start_process_LDADD = \ | 362 | test_os_start_process_LDADD = \ |
363 | libgnunetutil.la | 363 | libgnunetutil.la |
364 | test_os_start_process_DEPENDENCIES = \ | ||
365 | libgnunetutil.la | ||
366 | 364 | ||
367 | test_client_nc_SOURCES = \ | 365 | test_client_nc_SOURCES = \ |
368 | test_client.c | 366 | test_client.c |