diff options
author | ng0 <ng0@n0.is> | 2019-09-08 12:33:09 +0000 |
---|---|---|
committer | ng0 <ng0@n0.is> | 2019-09-08 12:33:09 +0000 |
commit | d41ed82a4ea0cc8e1674b6d5d2c49fd6462610bb (patch) | |
tree | 9efd18ea7d425652085ed0bd5e8e45604bc5f6b9 /src/ats-tests | |
parent | a0fce305c565c0937d917a92712f15e9c5736260 (diff) | |
download | gnunet-d41ed82a4ea0cc8e1674b6d5d2c49fd6462610bb.tar.gz gnunet-d41ed82a4ea0cc8e1674b6d5d2c49fd6462610bb.zip |
uncrustify as demanded.
Diffstat (limited to 'src/ats-tests')
-rw-r--r-- | src/ats-tests/ats-testing-experiment.c | 1023 | ||||
-rw-r--r-- | src/ats-tests/ats-testing-log.c | 979 | ||||
-rw-r--r-- | src/ats-tests/ats-testing-preferences.c | 196 | ||||
-rw-r--r-- | src/ats-tests/ats-testing-traffic.c | 359 | ||||
-rw-r--r-- | src/ats-tests/ats-testing.c | 1081 | ||||
-rw-r--r-- | src/ats-tests/ats-testing.h | 128 | ||||
-rw-r--r-- | src/ats-tests/gnunet-ats-sim.c | 427 | ||||
-rw-r--r-- | src/ats-tests/gnunet-solver-eval.c | 1244 | ||||
-rw-r--r-- | src/ats-tests/perf_ats.c | 571 | ||||
-rw-r--r-- | src/ats-tests/perf_ats.h | 40 | ||||
-rw-r--r-- | src/ats-tests/perf_ats_logging.c | 678 |
11 files changed, 3381 insertions, 3345 deletions
diff --git a/src/ats-tests/ats-testing-experiment.c b/src/ats-tests/ats-testing-experiment.c index b91c652b0..db5f411dd 100644 --- a/src/ats-tests/ats-testing-experiment.c +++ b/src/ats-tests/ats-testing-experiment.c | |||
@@ -1,19 +1,19 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2010-2013 GNUnet e.V. | 3 | Copyright (C) 2010-2013 GNUnet e.V. |
4 | 4 | ||
5 | GNUnet is free software: you can redistribute it and/or modify it | 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 | 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, | 7 | by the Free Software Foundation, either version 3 of the License, |
8 | or (at your option) any later version. | 8 | or (at your option) any later version. |
9 | 9 | ||
10 | GNUnet is distributed in the hope that it will be useful, but | 10 | GNUnet is distributed in the hope that it will be useful, but |
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Affero General Public License for more details. | 13 | Affero General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Affero General Public License | 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/>. | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | 17 | ||
18 | SPDX-License-Identifier: AGPL3.0-or-later | 18 | SPDX-License-Identifier: AGPL3.0-or-later |
19 | */ | 19 | */ |
@@ -28,29 +28,35 @@ | |||
28 | #include "ats-testing.h" | 28 | #include "ats-testing.h" |
29 | 29 | ||
30 | const char * | 30 | const char * |
31 | print_op (enum OperationType op) | 31 | print_op(enum OperationType op) |
32 | { | 32 | { |
33 | switch (op) { | 33 | switch (op) |
34 | { | ||
34 | case START_SEND: | 35 | case START_SEND: |
35 | return "START_SEND"; | 36 | return "START_SEND"; |
37 | |||
36 | case STOP_SEND: | 38 | case STOP_SEND: |
37 | return "STOP_SEND"; | 39 | return "STOP_SEND"; |
40 | |||
38 | case START_PREFERENCE: | 41 | case START_PREFERENCE: |
39 | return "START_PREFERENCE"; | 42 | return "START_PREFERENCE"; |
43 | |||
40 | case STOP_PREFERENCE: | 44 | case STOP_PREFERENCE: |
41 | return "STOP_PREFERENCE"; | 45 | return "STOP_PREFERENCE"; |
46 | |||
42 | default: | 47 | default: |
43 | break; | 48 | break; |
44 | } | 49 | } |
45 | return ""; | 50 | return ""; |
46 | } | 51 | } |
47 | 52 | ||
48 | 53 | ||
49 | static struct Experiment * | 54 | static struct Experiment * |
50 | create_experiment () | 55 | create_experiment() |
51 | { | 56 | { |
52 | struct Experiment *e; | 57 | struct Experiment *e; |
53 | e = GNUNET_new (struct Experiment); | 58 | |
59 | e = GNUNET_new(struct Experiment); | ||
54 | e->name = NULL; | 60 | e->name = NULL; |
55 | e->num_masters = 0; | 61 | e->num_masters = 0; |
56 | e->num_slaves = 0; | 62 | e->num_slaves = 0; |
@@ -60,7 +66,7 @@ create_experiment () | |||
60 | } | 66 | } |
61 | 67 | ||
62 | static void | 68 | static void |
63 | free_experiment (struct Experiment *e) | 69 | free_experiment(struct Experiment *e) |
64 | { | 70 | { |
65 | struct Episode *cur; | 71 | struct Episode *cur; |
66 | struct Episode *next; | 72 | struct Episode *next; |
@@ -69,28 +75,28 @@ free_experiment (struct Experiment *e) | |||
69 | 75 | ||
70 | next = e->start; | 76 | next = e->start; |
71 | for (cur = next; NULL != cur; cur = next) | 77 | for (cur = next; NULL != cur; cur = next) |
72 | { | ||
73 | next = cur->next; | ||
74 | |||
75 | next_o = cur->head; | ||
76 | for (cur_o = next_o; NULL != cur_o; cur_o = next_o) | ||
77 | { | 78 | { |
78 | next_o = cur_o->next; | 79 | next = cur->next; |
79 | GNUNET_free (cur_o); | 80 | |
81 | next_o = cur->head; | ||
82 | for (cur_o = next_o; NULL != cur_o; cur_o = next_o) | ||
83 | { | ||
84 | next_o = cur_o->next; | ||
85 | GNUNET_free(cur_o); | ||
86 | } | ||
87 | GNUNET_free(cur); | ||
80 | } | 88 | } |
81 | GNUNET_free (cur); | ||
82 | } | ||
83 | 89 | ||
84 | GNUNET_free_non_null (e->name); | 90 | GNUNET_free_non_null(e->name); |
85 | GNUNET_free_non_null (e->cfg_file); | 91 | GNUNET_free_non_null(e->cfg_file); |
86 | GNUNET_free (e); | 92 | GNUNET_free(e); |
87 | } | 93 | } |
88 | 94 | ||
89 | 95 | ||
90 | static int | 96 | static int |
91 | load_episode (struct Experiment *e, | 97 | load_episode(struct Experiment *e, |
92 | struct Episode *cur, | 98 | struct Episode *cur, |
93 | struct GNUNET_CONFIGURATION_Handle *cfg) | 99 | struct GNUNET_CONFIGURATION_Handle *cfg) |
94 | { | 100 | { |
95 | struct GNUNET_ATS_TEST_Operation *o; | 101 | struct GNUNET_ATS_TEST_Operation *o; |
96 | char *sec_name; | 102 | char *sec_name; |
@@ -100,272 +106,272 @@ load_episode (struct Experiment *e, | |||
100 | char *pref; | 106 | char *pref; |
101 | int op_counter = 0; | 107 | int op_counter = 0; |
102 | 108 | ||
103 | fprintf (stderr, "Parsing episode %u\n",cur->id); | 109 | fprintf(stderr, "Parsing episode %u\n", cur->id); |
104 | GNUNET_asprintf (&sec_name, "episode-%u", cur->id); | 110 | GNUNET_asprintf(&sec_name, "episode-%u", cur->id); |
105 | 111 | ||
106 | while (1) | 112 | while (1) |
107 | { | ||
108 | /* Load operation */ | ||
109 | GNUNET_asprintf (&op_name, "op-%u-operation", op_counter); | ||
110 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string(cfg, | ||
111 | sec_name, op_name, &op)) | ||
112 | { | 113 | { |
113 | GNUNET_free (op_name); | 114 | /* Load operation */ |
114 | break; | 115 | GNUNET_asprintf(&op_name, "op-%u-operation", op_counter); |
115 | } | 116 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string(cfg, |
116 | o = GNUNET_new (struct GNUNET_ATS_TEST_Operation); | 117 | sec_name, op_name, &op)) |
117 | /* operations = set_rate, start_send, stop_send, set_preference */ | 118 | { |
118 | if (0 == strcmp (op, "start_send")) | 119 | GNUNET_free(op_name); |
119 | { | 120 | break; |
120 | o->type = START_SEND; | 121 | } |
121 | } | 122 | o = GNUNET_new(struct GNUNET_ATS_TEST_Operation); |
122 | else if (0 == strcmp (op, "stop_send")) | 123 | /* operations = set_rate, start_send, stop_send, set_preference */ |
123 | { | 124 | if (0 == strcmp(op, "start_send")) |
124 | o->type = STOP_SEND; | 125 | { |
125 | } | 126 | o->type = START_SEND; |
126 | else if (0 == strcmp (op, "start_preference")) | 127 | } |
127 | { | 128 | else if (0 == strcmp(op, "stop_send")) |
128 | o->type = START_PREFERENCE; | 129 | { |
129 | } | 130 | o->type = STOP_SEND; |
130 | else if (0 == strcmp (op, "stop_preference")) | 131 | } |
131 | { | 132 | else if (0 == strcmp(op, "start_preference")) |
132 | o->type = STOP_PREFERENCE; | 133 | { |
133 | } | 134 | o->type = START_PREFERENCE; |
134 | else | 135 | } |
135 | { | 136 | else if (0 == strcmp(op, "stop_preference")) |
136 | fprintf (stderr, "Invalid operation %u `%s' in episode %u\n", | 137 | { |
137 | op_counter, op, cur->id); | 138 | o->type = STOP_PREFERENCE; |
138 | GNUNET_free (op); | 139 | } |
139 | GNUNET_free (op_name); | ||
140 | GNUNET_free (o); | ||
141 | GNUNET_free (sec_name); | ||
142 | return GNUNET_SYSERR; | ||
143 | } | ||
144 | GNUNET_free (op_name); | ||
145 | |||
146 | /* Get source */ | ||
147 | GNUNET_asprintf(&op_name, "op-%u-src", op_counter); | ||
148 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (cfg, | ||
149 | sec_name, op_name, &o->src_id)) | ||
150 | { | ||
151 | fprintf (stderr, "Missing src in operation %u `%s' in episode %u\n", | ||
152 | op_counter, op, cur->id); | ||
153 | GNUNET_free (op); | ||
154 | GNUNET_free (op_name); | ||
155 | GNUNET_free (o); | ||
156 | GNUNET_free (sec_name); | ||
157 | return GNUNET_SYSERR; | ||
158 | } | ||
159 | if (o->src_id > (e->num_masters - 1)) | ||
160 | { | ||
161 | fprintf (stderr, "Invalid src %llu in operation %u `%s' in episode %u\n", | ||
162 | o->src_id, 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 | GNUNET_free (op_name); | ||
170 | |||
171 | /* Get destination */ | ||
172 | GNUNET_asprintf(&op_name, "op-%u-dest", op_counter); | ||
173 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (cfg, | ||
174 | sec_name, op_name, &o->dest_id)) | ||
175 | { | ||
176 | fprintf (stderr, "Missing src in operation %u `%s' in episode %u\n", | ||
177 | op_counter, op, cur->id); | ||
178 | GNUNET_free (op); | ||
179 | GNUNET_free (op_name); | ||
180 | GNUNET_free (o); | ||
181 | GNUNET_free (sec_name); | ||
182 | return GNUNET_SYSERR; | ||
183 | } | ||
184 | if (o->dest_id > (e->num_slaves - 1)) | ||
185 | { | ||
186 | fprintf (stderr, "Invalid destination %llu in operation %u `%s' in episode %u\n", | ||
187 | o->dest_id, op_counter, op, cur->id); | ||
188 | GNUNET_free (op); | ||
189 | GNUNET_free (op_name); | ||
190 | GNUNET_free (o); | ||
191 | GNUNET_free (sec_name); | ||
192 | return GNUNET_SYSERR; | ||
193 | } | ||
194 | GNUNET_free (op_name); | ||
195 | |||
196 | GNUNET_asprintf(&op_name, "op-%u-type", op_counter); | ||
197 | if ( (GNUNET_SYSERR != GNUNET_CONFIGURATION_get_value_string(cfg, | ||
198 | sec_name, op_name, &type)) && | ||
199 | (STOP_SEND != o->type) && | ||
200 | (STOP_PREFERENCE != o->type) ) | ||
201 | { | ||
202 | /* Load arguments for set_rate, start_send, set_preference */ | ||
203 | if (0 == strcmp (type, "constant")) | ||
204 | { | ||
205 | o->gen_type = GNUNET_ATS_TEST_TG_CONSTANT; | ||
206 | } | ||
207 | else if (0 == strcmp (type, "linear")) | ||
208 | { | ||
209 | o->gen_type = GNUNET_ATS_TEST_TG_LINEAR; | ||
210 | } | ||
211 | else if (0 == strcmp (type, "sinus")) | ||
212 | { | ||
213 | o->gen_type = GNUNET_ATS_TEST_TG_SINUS; | ||
214 | } | ||
215 | else if (0 == strcmp (type, "random")) | ||
216 | { | ||
217 | o->gen_type = GNUNET_ATS_TEST_TG_RANDOM; | ||
218 | } | ||
219 | else | 140 | else |
220 | { | ||
221 | fprintf (stderr, "Invalid type %u `%s' in episode %u\n", | ||
222 | op_counter, op, cur->id); | ||
223 | GNUNET_free (type); | ||
224 | GNUNET_free (op); | ||
225 | GNUNET_free (op_name); | ||
226 | GNUNET_free (sec_name); | ||
227 | GNUNET_free (o); | ||
228 | return GNUNET_SYSERR; | ||
229 | } | ||
230 | GNUNET_free (op_name); | ||
231 | |||
232 | /* Get base rate */ | ||
233 | GNUNET_asprintf(&op_name, "op-%u-base-rate", op_counter); | ||
234 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (cfg, | ||
235 | sec_name, op_name, &o->base_rate)) | ||
236 | { | ||
237 | fprintf (stderr, "Missing base rate in operation %u `%s' in episode %u\n", | ||
238 | op_counter, op, cur->id); | ||
239 | GNUNET_free (type); | ||
240 | GNUNET_free (op); | ||
241 | GNUNET_free (op_name); | ||
242 | GNUNET_free (sec_name); | ||
243 | GNUNET_free (o); | ||
244 | return GNUNET_SYSERR; | ||
245 | } | ||
246 | GNUNET_free (op_name); | ||
247 | |||
248 | /* Get max rate */ | ||
249 | GNUNET_asprintf(&op_name, "op-%u-max-rate", op_counter); | ||
250 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (cfg, | ||
251 | sec_name, op_name, &o->max_rate)) | ||
252 | { | ||
253 | if ((GNUNET_ATS_TEST_TG_LINEAR == o->gen_type) || | ||
254 | (GNUNET_ATS_TEST_TG_RANDOM == o->gen_type) || | ||
255 | (GNUNET_ATS_TEST_TG_SINUS == o->gen_type)) | ||
256 | { | 141 | { |
257 | fprintf (stderr, "Missing max rate in operation %u `%s' in episode %u\n", | 142 | fprintf(stderr, "Invalid operation %u `%s' in episode %u\n", |
258 | op_counter, op, cur->id); | 143 | op_counter, op, cur->id); |
259 | GNUNET_free (type); | 144 | GNUNET_free(op); |
260 | GNUNET_free (op_name); | 145 | GNUNET_free(op_name); |
261 | GNUNET_free (op); | 146 | GNUNET_free(o); |
262 | GNUNET_free (o); | 147 | GNUNET_free(sec_name); |
263 | GNUNET_free (sec_name); | ||
264 | return GNUNET_SYSERR; | 148 | return GNUNET_SYSERR; |
265 | } | 149 | } |
266 | } | 150 | GNUNET_free(op_name); |
267 | GNUNET_free (op_name); | 151 | |
268 | 152 | /* Get source */ | |
269 | /* Get period */ | 153 | GNUNET_asprintf(&op_name, "op-%u-src", op_counter); |
270 | GNUNET_asprintf(&op_name, "op-%u-period", op_counter); | 154 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number(cfg, |
271 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_time (cfg, | 155 | sec_name, op_name, &o->src_id)) |
272 | sec_name, op_name, &o->period)) | 156 | { |
273 | { | 157 | fprintf(stderr, "Missing src in operation %u `%s' in episode %u\n", |
274 | o->period = cur->duration; | ||
275 | } | ||
276 | GNUNET_free (op_name); | ||
277 | |||
278 | if (START_PREFERENCE == o->type) | ||
279 | { | ||
280 | /* Get frequency */ | ||
281 | GNUNET_asprintf(&op_name, "op-%u-frequency", op_counter); | ||
282 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_time (cfg, | ||
283 | sec_name, op_name, &o->frequency)) | ||
284 | { | ||
285 | fprintf (stderr, "Missing frequency in operation %u `%s' in episode %u\n", | ||
286 | op_counter, op, cur->id); | 158 | op_counter, op, cur->id); |
287 | GNUNET_free (type); | 159 | GNUNET_free(op); |
288 | GNUNET_free (op_name); | 160 | GNUNET_free(op_name); |
289 | GNUNET_free (op); | 161 | GNUNET_free(o); |
290 | GNUNET_free (o); | 162 | GNUNET_free(sec_name); |
291 | GNUNET_free (sec_name); | 163 | return GNUNET_SYSERR; |
292 | return GNUNET_SYSERR; | 164 | } |
293 | } | 165 | if (o->src_id > (e->num_masters - 1)) |
294 | GNUNET_free (op_name); | 166 | { |
295 | 167 | fprintf(stderr, "Invalid src %llu in operation %u `%s' in episode %u\n", | |
296 | /* Get preference */ | 168 | o->src_id, op_counter, op, cur->id); |
297 | GNUNET_asprintf(&op_name, "op-%u-pref", op_counter); | 169 | GNUNET_free(op); |
298 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string (cfg, | 170 | GNUNET_free(op_name); |
299 | sec_name, op_name, &pref)) | 171 | GNUNET_free(o); |
300 | { | 172 | GNUNET_free(sec_name); |
301 | fprintf (stderr, "Missing preference in operation %u `%s' in episode %u\n", | 173 | return GNUNET_SYSERR; |
174 | } | ||
175 | GNUNET_free(op_name); | ||
176 | |||
177 | /* Get destination */ | ||
178 | GNUNET_asprintf(&op_name, "op-%u-dest", op_counter); | ||
179 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number(cfg, | ||
180 | sec_name, op_name, &o->dest_id)) | ||
181 | { | ||
182 | fprintf(stderr, "Missing src in operation %u `%s' in episode %u\n", | ||
302 | op_counter, op, cur->id); | 183 | op_counter, op, cur->id); |
303 | GNUNET_free (type); | 184 | GNUNET_free(op); |
304 | GNUNET_free (op_name); | 185 | GNUNET_free(op_name); |
305 | GNUNET_free (op); | 186 | GNUNET_free(o); |
306 | GNUNET_free_non_null (pref); | 187 | GNUNET_free(sec_name); |
307 | GNUNET_free (o); | 188 | return GNUNET_SYSERR; |
308 | GNUNET_free (sec_name); | 189 | } |
309 | return GNUNET_SYSERR; | 190 | if (o->dest_id > (e->num_slaves - 1)) |
310 | } | 191 | { |
192 | fprintf(stderr, "Invalid destination %llu in operation %u `%s' in episode %u\n", | ||
193 | o->dest_id, op_counter, op, cur->id); | ||
194 | GNUNET_free(op); | ||
195 | GNUNET_free(op_name); | ||
196 | GNUNET_free(o); | ||
197 | GNUNET_free(sec_name); | ||
198 | return GNUNET_SYSERR; | ||
199 | } | ||
200 | GNUNET_free(op_name); | ||
311 | 201 | ||
312 | if (0 == strcmp(pref, "bandwidth")) | 202 | GNUNET_asprintf(&op_name, "op-%u-type", op_counter); |
313 | o->pref_type = GNUNET_ATS_PREFERENCE_BANDWIDTH; | 203 | if ((GNUNET_SYSERR != GNUNET_CONFIGURATION_get_value_string(cfg, |
314 | else if (0 == strcmp(pref, "latency")) | 204 | sec_name, op_name, &type)) && |
315 | o->pref_type = GNUNET_ATS_PREFERENCE_LATENCY; | 205 | (STOP_SEND != o->type) && |
206 | (STOP_PREFERENCE != o->type)) | ||
207 | { | ||
208 | /* Load arguments for set_rate, start_send, set_preference */ | ||
209 | if (0 == strcmp(type, "constant")) | ||
210 | { | ||
211 | o->gen_type = GNUNET_ATS_TEST_TG_CONSTANT; | ||
212 | } | ||
213 | else if (0 == strcmp(type, "linear")) | ||
214 | { | ||
215 | o->gen_type = GNUNET_ATS_TEST_TG_LINEAR; | ||
216 | } | ||
217 | else if (0 == strcmp(type, "sinus")) | ||
218 | { | ||
219 | o->gen_type = GNUNET_ATS_TEST_TG_SINUS; | ||
220 | } | ||
221 | else if (0 == strcmp(type, "random")) | ||
222 | { | ||
223 | o->gen_type = GNUNET_ATS_TEST_TG_RANDOM; | ||
224 | } | ||
316 | else | 225 | else |
317 | { | 226 | { |
318 | fprintf (stderr, "Invalid preference in operation %u `%s' in episode %u\n", | 227 | fprintf(stderr, "Invalid type %u `%s' in episode %u\n", |
319 | op_counter, op, cur->id); | 228 | op_counter, op, cur->id); |
320 | GNUNET_free (type); | 229 | GNUNET_free(type); |
321 | GNUNET_free (op_name); | 230 | GNUNET_free(op); |
322 | GNUNET_free (op); | 231 | GNUNET_free(op_name); |
323 | GNUNET_free_non_null (pref); | 232 | GNUNET_free(sec_name); |
324 | GNUNET_free (o); | 233 | GNUNET_free(o); |
325 | GNUNET_free (sec_name); | ||
326 | return GNUNET_SYSERR; | 234 | return GNUNET_SYSERR; |
327 | } | 235 | } |
328 | GNUNET_free (pref); | 236 | GNUNET_free(op_name); |
329 | GNUNET_free (op_name); | 237 | |
330 | } | 238 | /* Get base rate */ |
331 | } | 239 | GNUNET_asprintf(&op_name, "op-%u-base-rate", op_counter); |
240 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number(cfg, | ||
241 | sec_name, op_name, &o->base_rate)) | ||
242 | { | ||
243 | fprintf(stderr, "Missing base rate in operation %u `%s' in episode %u\n", | ||
244 | op_counter, op, cur->id); | ||
245 | GNUNET_free(type); | ||
246 | GNUNET_free(op); | ||
247 | GNUNET_free(op_name); | ||
248 | GNUNET_free(sec_name); | ||
249 | GNUNET_free(o); | ||
250 | return GNUNET_SYSERR; | ||
251 | } | ||
252 | GNUNET_free(op_name); | ||
253 | |||
254 | /* Get max rate */ | ||
255 | GNUNET_asprintf(&op_name, "op-%u-max-rate", op_counter); | ||
256 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number(cfg, | ||
257 | sec_name, op_name, &o->max_rate)) | ||
258 | { | ||
259 | if ((GNUNET_ATS_TEST_TG_LINEAR == o->gen_type) || | ||
260 | (GNUNET_ATS_TEST_TG_RANDOM == o->gen_type) || | ||
261 | (GNUNET_ATS_TEST_TG_SINUS == o->gen_type)) | ||
262 | { | ||
263 | fprintf(stderr, "Missing max rate in operation %u `%s' in episode %u\n", | ||
264 | op_counter, op, cur->id); | ||
265 | GNUNET_free(type); | ||
266 | GNUNET_free(op_name); | ||
267 | GNUNET_free(op); | ||
268 | GNUNET_free(o); | ||
269 | GNUNET_free(sec_name); | ||
270 | return GNUNET_SYSERR; | ||
271 | } | ||
272 | } | ||
273 | GNUNET_free(op_name); | ||
274 | |||
275 | /* Get period */ | ||
276 | GNUNET_asprintf(&op_name, "op-%u-period", op_counter); | ||
277 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_time(cfg, | ||
278 | sec_name, op_name, &o->period)) | ||
279 | { | ||
280 | o->period = cur->duration; | ||
281 | } | ||
282 | GNUNET_free(op_name); | ||
283 | |||
284 | if (START_PREFERENCE == o->type) | ||
285 | { | ||
286 | /* Get frequency */ | ||
287 | GNUNET_asprintf(&op_name, "op-%u-frequency", op_counter); | ||
288 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_time(cfg, | ||
289 | sec_name, op_name, &o->frequency)) | ||
290 | { | ||
291 | fprintf(stderr, "Missing frequency in operation %u `%s' in episode %u\n", | ||
292 | op_counter, op, cur->id); | ||
293 | GNUNET_free(type); | ||
294 | GNUNET_free(op_name); | ||
295 | GNUNET_free(op); | ||
296 | GNUNET_free(o); | ||
297 | GNUNET_free(sec_name); | ||
298 | return GNUNET_SYSERR; | ||
299 | } | ||
300 | GNUNET_free(op_name); | ||
301 | |||
302 | /* Get preference */ | ||
303 | GNUNET_asprintf(&op_name, "op-%u-pref", op_counter); | ||
304 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string(cfg, | ||
305 | sec_name, op_name, &pref)) | ||
306 | { | ||
307 | fprintf(stderr, "Missing preference in operation %u `%s' in episode %u\n", | ||
308 | op_counter, op, cur->id); | ||
309 | GNUNET_free(type); | ||
310 | GNUNET_free(op_name); | ||
311 | GNUNET_free(op); | ||
312 | GNUNET_free_non_null(pref); | ||
313 | GNUNET_free(o); | ||
314 | GNUNET_free(sec_name); | ||
315 | return GNUNET_SYSERR; | ||
316 | } | ||
317 | |||
318 | if (0 == strcmp(pref, "bandwidth")) | ||
319 | o->pref_type = GNUNET_ATS_PREFERENCE_BANDWIDTH; | ||
320 | else if (0 == strcmp(pref, "latency")) | ||
321 | o->pref_type = GNUNET_ATS_PREFERENCE_LATENCY; | ||
322 | else | ||
323 | { | ||
324 | fprintf(stderr, "Invalid preference in operation %u `%s' in episode %u\n", | ||
325 | op_counter, op, cur->id); | ||
326 | GNUNET_free(type); | ||
327 | GNUNET_free(op_name); | ||
328 | GNUNET_free(op); | ||
329 | GNUNET_free_non_null(pref); | ||
330 | GNUNET_free(o); | ||
331 | GNUNET_free(sec_name); | ||
332 | return GNUNET_SYSERR; | ||
333 | } | ||
334 | GNUNET_free(pref); | ||
335 | GNUNET_free(op_name); | ||
336 | } | ||
337 | } | ||
332 | 338 | ||
333 | /* Safety checks */ | 339 | /* Safety checks */ |
334 | if ((GNUNET_ATS_TEST_TG_LINEAR == o->gen_type) || | 340 | if ((GNUNET_ATS_TEST_TG_LINEAR == o->gen_type) || |
335 | (GNUNET_ATS_TEST_TG_SINUS == o->gen_type)) | 341 | (GNUNET_ATS_TEST_TG_SINUS == o->gen_type)) |
336 | { | 342 | { |
337 | if ((o->max_rate - o->base_rate) > o->base_rate) | 343 | if ((o->max_rate - o->base_rate) > o->base_rate) |
338 | { | 344 | { |
339 | /* This will cause an underflow */ | 345 | /* This will cause an underflow */ |
340 | GNUNET_break (0); | 346 | GNUNET_break(0); |
341 | } | 347 | } |
342 | fprintf (stderr, "Selected max rate and base rate cannot be used for desired traffic form!\n"); | 348 | fprintf(stderr, "Selected max rate and base rate cannot be used for desired traffic form!\n"); |
343 | } | 349 | } |
344 | 350 | ||
345 | if ((START_SEND == o->type) || (START_PREFERENCE == o->type)) | 351 | if ((START_SEND == o->type) || (START_PREFERENCE == o->type)) |
346 | fprintf (stderr, "Found operation %u in episode %u: %s [%llu]->[%llu] == %s, %llu -> %llu in %s\n", | 352 | fprintf(stderr, "Found operation %u in episode %u: %s [%llu]->[%llu] == %s, %llu -> %llu in %s\n", |
347 | op_counter, cur->id, print_op (o->type), o->src_id, | 353 | op_counter, cur->id, print_op(o->type), o->src_id, |
348 | o->dest_id, (NULL != type) ? type : "", | 354 | o->dest_id, (NULL != type) ? type : "", |
349 | o->base_rate, o->max_rate, | 355 | o->base_rate, o->max_rate, |
350 | GNUNET_STRINGS_relative_time_to_string (o->period, GNUNET_YES)); | 356 | GNUNET_STRINGS_relative_time_to_string(o->period, GNUNET_YES)); |
351 | else | 357 | else |
352 | fprintf (stderr, "Found operation %u in episode %u: %s [%llu]->[%llu]\n", | 358 | fprintf(stderr, "Found operation %u in episode %u: %s [%llu]->[%llu]\n", |
353 | op_counter, cur->id, print_op (o->type), o->src_id, o->dest_id); | 359 | op_counter, cur->id, print_op(o->type), o->src_id, o->dest_id); |
354 | 360 | ||
355 | GNUNET_free_non_null (type); | 361 | GNUNET_free_non_null(type); |
356 | GNUNET_free (op); | 362 | GNUNET_free(op); |
357 | 363 | ||
358 | GNUNET_CONTAINER_DLL_insert (cur->head,cur->tail, o); | 364 | GNUNET_CONTAINER_DLL_insert(cur->head, cur->tail, o); |
359 | op_counter++; | 365 | op_counter++; |
360 | } | 366 | } |
361 | GNUNET_free (sec_name); | 367 | GNUNET_free(sec_name); |
362 | 368 | ||
363 | return GNUNET_OK; | 369 | return GNUNET_OK; |
364 | } | 370 | } |
365 | 371 | ||
366 | 372 | ||
367 | static int | 373 | static int |
368 | load_episodes (struct Experiment *e, struct GNUNET_CONFIGURATION_Handle *cfg) | 374 | load_episodes(struct Experiment *e, struct GNUNET_CONFIGURATION_Handle *cfg) |
369 | { | 375 | { |
370 | int e_counter = 0; | 376 | int e_counter = 0; |
371 | char *sec_name; | 377 | char *sec_name; |
@@ -376,373 +382,380 @@ load_episodes (struct Experiment *e, struct GNUNET_CONFIGURATION_Handle *cfg) | |||
376 | e_counter = 0; | 382 | e_counter = 0; |
377 | last = NULL; | 383 | last = NULL; |
378 | while (1) | 384 | while (1) |
379 | { | ||
380 | GNUNET_asprintf(&sec_name, "episode-%u", e_counter); | ||
381 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_time(cfg, | ||
382 | sec_name, "duration", &e_duration)) | ||
383 | { | 385 | { |
384 | GNUNET_free (sec_name); | 386 | GNUNET_asprintf(&sec_name, "episode-%u", e_counter); |
385 | break; | 387 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_time(cfg, |
386 | } | 388 | sec_name, "duration", &e_duration)) |
389 | { | ||
390 | GNUNET_free(sec_name); | ||
391 | break; | ||
392 | } | ||
387 | 393 | ||
388 | cur = GNUNET_new (struct Episode); | 394 | cur = GNUNET_new(struct Episode); |
389 | cur->duration = e_duration; | 395 | cur->duration = e_duration; |
390 | cur->id = e_counter; | 396 | cur->id = e_counter; |
391 | 397 | ||
392 | if (GNUNET_OK != load_episode (e, cur, cfg)) | 398 | if (GNUNET_OK != load_episode(e, cur, cfg)) |
393 | { | 399 | { |
394 | GNUNET_free (sec_name); | 400 | GNUNET_free(sec_name); |
395 | GNUNET_free (cur); | 401 | GNUNET_free(cur); |
396 | return GNUNET_SYSERR; | 402 | return GNUNET_SYSERR; |
397 | } | 403 | } |
398 | 404 | ||
399 | fprintf (stderr, "Found episode %u with duration %s \n", | 405 | fprintf(stderr, "Found episode %u with duration %s \n", |
400 | e_counter, | 406 | e_counter, |
401 | GNUNET_STRINGS_relative_time_to_string(cur->duration, GNUNET_YES)); | 407 | GNUNET_STRINGS_relative_time_to_string(cur->duration, GNUNET_YES)); |
402 | 408 | ||
403 | /* Update experiment */ | 409 | /* Update experiment */ |
404 | e->num_episodes ++; | 410 | e->num_episodes++; |
405 | e->total_duration = GNUNET_TIME_relative_add(e->total_duration, cur->duration); | 411 | e->total_duration = GNUNET_TIME_relative_add(e->total_duration, cur->duration); |
406 | /* Put in linked list */ | 412 | /* Put in linked list */ |
407 | if (NULL == last) | 413 | if (NULL == last) |
408 | e->start = cur; | 414 | e->start = cur; |
409 | else | 415 | else |
410 | last->next = cur; | 416 | last->next = cur; |
411 | 417 | ||
412 | GNUNET_free (sec_name); | 418 | GNUNET_free(sec_name); |
413 | e_counter ++; | 419 | e_counter++; |
414 | last = cur; | 420 | last = cur; |
415 | } | 421 | } |
416 | return e_counter; | 422 | return e_counter; |
417 | } | 423 | } |
418 | 424 | ||
419 | 425 | ||
420 | static void | 426 | static void |
421 | timeout_experiment (void *cls) | 427 | timeout_experiment(void *cls) |
422 | { | 428 | { |
423 | struct Experiment *e = cls; | 429 | struct Experiment *e = cls; |
430 | |||
424 | e->experiment_timeout_task = NULL; | 431 | e->experiment_timeout_task = NULL; |
425 | fprintf (stderr, "Experiment timeout!\n"); | 432 | fprintf(stderr, "Experiment timeout!\n"); |
426 | 433 | ||
427 | if (NULL != e->episode_timeout_task) | 434 | if (NULL != e->episode_timeout_task) |
428 | { | 435 | { |
429 | GNUNET_SCHEDULER_cancel (e->episode_timeout_task); | 436 | GNUNET_SCHEDULER_cancel(e->episode_timeout_task); |
430 | e->episode_timeout_task = NULL; | 437 | e->episode_timeout_task = NULL; |
431 | } | 438 | } |
432 | 439 | ||
433 | e->e_done_cb (e, GNUNET_TIME_absolute_get_duration(e->start_time), | 440 | e->e_done_cb(e, GNUNET_TIME_absolute_get_duration(e->start_time), |
434 | GNUNET_SYSERR); | 441 | GNUNET_SYSERR); |
435 | } | 442 | } |
436 | 443 | ||
437 | 444 | ||
438 | static void | 445 | static void |
439 | enforce_start_send (struct GNUNET_ATS_TEST_Operation *op) | 446 | enforce_start_send(struct GNUNET_ATS_TEST_Operation *op) |
440 | { | 447 | { |
441 | struct BenchmarkPeer *peer; | 448 | struct BenchmarkPeer *peer; |
442 | struct BenchmarkPartner *partner; | 449 | struct BenchmarkPartner *partner; |
443 | 450 | ||
444 | peer = GNUNET_ATS_TEST_get_peer (op->src_id); | 451 | peer = GNUNET_ATS_TEST_get_peer(op->src_id); |
445 | if (NULL == peer) | 452 | if (NULL == peer) |
446 | { | 453 | { |
447 | GNUNET_break (0); | 454 | GNUNET_break(0); |
448 | return; | 455 | return; |
449 | } | 456 | } |
450 | 457 | ||
451 | partner = GNUNET_ATS_TEST_get_partner (op->src_id, op->dest_id); | 458 | partner = GNUNET_ATS_TEST_get_partner(op->src_id, op->dest_id); |
452 | if (NULL == partner) | 459 | if (NULL == partner) |
453 | { | 460 | { |
454 | GNUNET_break (0); | 461 | GNUNET_break(0); |
455 | return; | 462 | return; |
456 | } | 463 | } |
457 | 464 | ||
458 | fprintf (stderr, "Found master %llu slave %llu\n",op->src_id, op->dest_id); | 465 | fprintf(stderr, "Found master %llu slave %llu\n", op->src_id, op->dest_id); |
459 | 466 | ||
460 | if (NULL != partner->tg) | 467 | if (NULL != partner->tg) |
461 | { | 468 | { |
462 | fprintf (stderr, "Stopping traffic between master %llu slave %llu\n",op->src_id, op->dest_id); | 469 | fprintf(stderr, "Stopping traffic between master %llu slave %llu\n", op->src_id, op->dest_id); |
463 | GNUNET_ATS_TEST_generate_traffic_stop(partner->tg); | 470 | GNUNET_ATS_TEST_generate_traffic_stop(partner->tg); |
464 | partner->tg = NULL; | 471 | partner->tg = NULL; |
465 | } | 472 | } |
466 | 473 | ||
467 | partner->tg = GNUNET_ATS_TEST_generate_traffic_start(peer, partner, | 474 | partner->tg = GNUNET_ATS_TEST_generate_traffic_start(peer, partner, |
468 | op->gen_type, op->base_rate, op->max_rate, op->period, | 475 | op->gen_type, op->base_rate, op->max_rate, op->period, |
469 | GNUNET_TIME_UNIT_FOREVER_REL); | 476 | GNUNET_TIME_UNIT_FOREVER_REL); |
470 | } | 477 | } |
471 | 478 | ||
472 | static void | 479 | static void |
473 | enforce_stop_send (struct GNUNET_ATS_TEST_Operation *op) | 480 | enforce_stop_send(struct GNUNET_ATS_TEST_Operation *op) |
474 | { | 481 | { |
475 | struct BenchmarkPartner *p; | 482 | struct BenchmarkPartner *p; |
476 | p = GNUNET_ATS_TEST_get_partner (op->src_id, op->dest_id); | 483 | |
484 | p = GNUNET_ATS_TEST_get_partner(op->src_id, op->dest_id); | ||
477 | if (NULL == p) | 485 | if (NULL == p) |
478 | { | 486 | { |
479 | GNUNET_break (0); | 487 | GNUNET_break(0); |
480 | return; | 488 | return; |
481 | } | 489 | } |
482 | 490 | ||
483 | fprintf (stderr, "Found master %llu slave %llu\n",op->src_id, op->dest_id); | 491 | fprintf(stderr, "Found master %llu slave %llu\n", op->src_id, op->dest_id); |
484 | 492 | ||
485 | if (NULL != p->tg) | 493 | if (NULL != p->tg) |
486 | { | 494 | { |
487 | fprintf (stderr, "Stopping traffic between master %llu slave %llu\n", | 495 | fprintf(stderr, "Stopping traffic between master %llu slave %llu\n", |
488 | op->src_id, op->dest_id); | 496 | op->src_id, op->dest_id); |
489 | GNUNET_ATS_TEST_generate_traffic_stop(p->tg); | 497 | GNUNET_ATS_TEST_generate_traffic_stop(p->tg); |
490 | p->tg = NULL; | 498 | p->tg = NULL; |
491 | } | 499 | } |
492 | } | 500 | } |
493 | 501 | ||
494 | 502 | ||
495 | static void | 503 | static void |
496 | enforce_start_preference (struct GNUNET_ATS_TEST_Operation *op) | 504 | enforce_start_preference(struct GNUNET_ATS_TEST_Operation *op) |
497 | { | 505 | { |
498 | struct BenchmarkPeer *peer; | 506 | struct BenchmarkPeer *peer; |
499 | struct BenchmarkPartner *partner; | 507 | struct BenchmarkPartner *partner; |
500 | 508 | ||
501 | peer = GNUNET_ATS_TEST_get_peer (op->src_id); | 509 | peer = GNUNET_ATS_TEST_get_peer(op->src_id); |
502 | if (NULL == peer) | 510 | if (NULL == peer) |
503 | { | 511 | { |
504 | GNUNET_break (0); | 512 | GNUNET_break(0); |
505 | return; | 513 | return; |
506 | } | 514 | } |
507 | 515 | ||
508 | partner = GNUNET_ATS_TEST_get_partner (op->src_id, op->dest_id); | 516 | partner = GNUNET_ATS_TEST_get_partner(op->src_id, op->dest_id); |
509 | if (NULL == partner) | 517 | if (NULL == partner) |
510 | { | 518 | { |
511 | GNUNET_break (0); | 519 | GNUNET_break(0); |
512 | return; | 520 | return; |
513 | } | 521 | } |
514 | 522 | ||
515 | fprintf (stderr, "Found master %llu slave %llu\n",op->src_id, op->dest_id); | 523 | fprintf(stderr, "Found master %llu slave %llu\n", op->src_id, op->dest_id); |
516 | 524 | ||
517 | if (NULL != partner->pg) | 525 | if (NULL != partner->pg) |
518 | { | 526 | { |
519 | fprintf (stderr, "Stopping traffic between master %llu slave %llu\n", | 527 | fprintf(stderr, "Stopping traffic between master %llu slave %llu\n", |
520 | op->src_id, op->dest_id); | 528 | op->src_id, op->dest_id); |
521 | GNUNET_ATS_TEST_generate_preferences_stop(partner->pg); | 529 | GNUNET_ATS_TEST_generate_preferences_stop(partner->pg); |
522 | partner->pg = NULL; | 530 | partner->pg = NULL; |
523 | } | 531 | } |
524 | 532 | ||
525 | partner->pg = GNUNET_ATS_TEST_generate_preferences_start(peer, partner, | 533 | partner->pg = GNUNET_ATS_TEST_generate_preferences_start(peer, partner, |
526 | op->gen_type, op->base_rate, op->max_rate, op->period, op->frequency, | 534 | op->gen_type, op->base_rate, op->max_rate, op->period, op->frequency, |
527 | op->pref_type); | 535 | op->pref_type); |
528 | } | 536 | } |
529 | 537 | ||
530 | static void | 538 | static void |
531 | enforce_stop_preference (struct GNUNET_ATS_TEST_Operation *op) | 539 | enforce_stop_preference(struct GNUNET_ATS_TEST_Operation *op) |
532 | { | 540 | { |
533 | struct BenchmarkPartner *p; | 541 | struct BenchmarkPartner *p; |
534 | p = GNUNET_ATS_TEST_get_partner (op->src_id, op->dest_id); | 542 | |
543 | p = GNUNET_ATS_TEST_get_partner(op->src_id, op->dest_id); | ||
535 | if (NULL == p) | 544 | if (NULL == p) |
536 | { | 545 | { |
537 | GNUNET_break (0); | 546 | GNUNET_break(0); |
538 | return; | 547 | return; |
539 | } | 548 | } |
540 | 549 | ||
541 | fprintf (stderr, "Found master %llu slave %llu\n",op->src_id, op->dest_id); | 550 | fprintf(stderr, "Found master %llu slave %llu\n", op->src_id, op->dest_id); |
542 | 551 | ||
543 | if (NULL != p->pg) | 552 | if (NULL != p->pg) |
544 | { | 553 | { |
545 | fprintf (stderr, "Stopping preference between master %llu slave %llu\n", | 554 | fprintf(stderr, "Stopping preference between master %llu slave %llu\n", |
546 | op->src_id, op->dest_id); | 555 | op->src_id, op->dest_id); |
547 | GNUNET_ATS_TEST_generate_preferences_stop (p->pg); | 556 | GNUNET_ATS_TEST_generate_preferences_stop(p->pg); |
548 | p->pg = NULL; | 557 | p->pg = NULL; |
549 | } | 558 | } |
550 | } | 559 | } |
551 | 560 | ||
552 | static void enforce_episode (struct Episode *ep) | 561 | static void enforce_episode(struct Episode *ep) |
553 | { | 562 | { |
554 | struct GNUNET_ATS_TEST_Operation *cur; | 563 | struct GNUNET_ATS_TEST_Operation *cur; |
564 | |||
555 | for (cur = ep->head; NULL != cur; cur = cur->next) | 565 | for (cur = ep->head; NULL != cur; cur = cur->next) |
556 | { | 566 | { |
557 | 567 | fprintf(stderr, "Enforcing operation: %s [%llu]->[%llu] == %llu\n", | |
558 | fprintf (stderr, "Enforcing operation: %s [%llu]->[%llu] == %llu\n", | 568 | print_op(cur->type), cur->src_id, cur->dest_id, cur->base_rate); |
559 | print_op (cur->type), cur->src_id, cur->dest_id, cur->base_rate); | 569 | switch (cur->type) |
560 | switch (cur->type) { | 570 | { |
561 | case START_SEND: | 571 | case START_SEND: |
562 | enforce_start_send (cur); | 572 | enforce_start_send(cur); |
563 | break; | 573 | break; |
564 | case STOP_SEND: | 574 | |
565 | enforce_stop_send (cur); | 575 | case STOP_SEND: |
566 | break; | 576 | enforce_stop_send(cur); |
567 | case START_PREFERENCE: | 577 | break; |
568 | enforce_start_preference (cur); | 578 | |
569 | break; | 579 | case START_PREFERENCE: |
570 | case STOP_PREFERENCE: | 580 | enforce_start_preference(cur); |
571 | enforce_stop_preference (cur); | 581 | break; |
572 | break; | 582 | |
573 | default: | 583 | case STOP_PREFERENCE: |
574 | break; | 584 | enforce_stop_preference(cur); |
585 | break; | ||
586 | |||
587 | default: | ||
588 | break; | ||
589 | } | ||
575 | } | 590 | } |
576 | } | ||
577 | } | 591 | } |
578 | 592 | ||
579 | 593 | ||
580 | static void | 594 | static void |
581 | timeout_episode (void *cls) | 595 | timeout_episode(void *cls) |
582 | { | 596 | { |
583 | struct Experiment *e = cls; | 597 | struct Experiment *e = cls; |
584 | 598 | ||
585 | e->episode_timeout_task = NULL; | 599 | e->episode_timeout_task = NULL; |
586 | if (NULL != e->ep_done_cb) | 600 | if (NULL != e->ep_done_cb) |
587 | e->ep_done_cb (e->cur); | 601 | e->ep_done_cb(e->cur); |
588 | 602 | ||
589 | /* Scheduling next */ | 603 | /* Scheduling next */ |
590 | e->cur = e->cur->next; | 604 | e->cur = e->cur->next; |
591 | if (NULL == e->cur) | 605 | if (NULL == e->cur) |
592 | { | ||
593 | /* done */ | ||
594 | fprintf (stderr, "Last episode done!\n"); | ||
595 | if (NULL != e->experiment_timeout_task) | ||
596 | { | 606 | { |
597 | GNUNET_SCHEDULER_cancel (e->experiment_timeout_task); | 607 | /* done */ |
598 | e->experiment_timeout_task = NULL; | 608 | fprintf(stderr, "Last episode done!\n"); |
609 | if (NULL != e->experiment_timeout_task) | ||
610 | { | ||
611 | GNUNET_SCHEDULER_cancel(e->experiment_timeout_task); | ||
612 | e->experiment_timeout_task = NULL; | ||
613 | } | ||
614 | e->e_done_cb(e, GNUNET_TIME_absolute_get_duration(e->start_time), GNUNET_OK); | ||
615 | return; | ||
599 | } | 616 | } |
600 | e->e_done_cb (e, GNUNET_TIME_absolute_get_duration(e->start_time), GNUNET_OK); | ||
601 | return; | ||
602 | } | ||
603 | 617 | ||
604 | fprintf (stderr, "Running episode %u with timeout %s\n", | 618 | fprintf(stderr, "Running episode %u with timeout %s\n", |
605 | e->cur->id, | 619 | e->cur->id, |
606 | GNUNET_STRINGS_relative_time_to_string(e->cur->duration, GNUNET_YES)); | 620 | GNUNET_STRINGS_relative_time_to_string(e->cur->duration, GNUNET_YES)); |
607 | enforce_episode(e->cur); | 621 | enforce_episode(e->cur); |
608 | 622 | ||
609 | e->episode_timeout_task = GNUNET_SCHEDULER_add_delayed (e->cur->duration, | 623 | e->episode_timeout_task = GNUNET_SCHEDULER_add_delayed(e->cur->duration, |
610 | &timeout_episode, e); | 624 | &timeout_episode, e); |
611 | } | 625 | } |
612 | 626 | ||
613 | 627 | ||
614 | void | 628 | void |
615 | GNUNET_ATS_TEST_experimentation_run (struct Experiment *e, | 629 | GNUNET_ATS_TEST_experimentation_run(struct Experiment *e, |
616 | GNUNET_ATS_TESTING_EpisodeDoneCallback ep_done_cb, | 630 | GNUNET_ATS_TESTING_EpisodeDoneCallback ep_done_cb, |
617 | GNUNET_ATS_TESTING_ExperimentDoneCallback e_done_cb) | 631 | GNUNET_ATS_TESTING_ExperimentDoneCallback e_done_cb) |
618 | { | 632 | { |
619 | fprintf (stderr, "Running experiment `%s' with timeout %s\n", e->name, | 633 | fprintf(stderr, "Running experiment `%s' with timeout %s\n", e->name, |
620 | GNUNET_STRINGS_relative_time_to_string(e->max_duration, GNUNET_YES)); | 634 | GNUNET_STRINGS_relative_time_to_string(e->max_duration, GNUNET_YES)); |
621 | e->e_done_cb = e_done_cb; | 635 | e->e_done_cb = e_done_cb; |
622 | e->ep_done_cb = ep_done_cb; | 636 | e->ep_done_cb = ep_done_cb; |
623 | e->start_time = GNUNET_TIME_absolute_get(); | 637 | e->start_time = GNUNET_TIME_absolute_get(); |
624 | 638 | ||
625 | /* Start total time out */ | 639 | /* Start total time out */ |
626 | e->experiment_timeout_task = GNUNET_SCHEDULER_add_delayed (e->max_duration, | 640 | e->experiment_timeout_task = GNUNET_SCHEDULER_add_delayed(e->max_duration, |
627 | &timeout_experiment, e); | 641 | &timeout_experiment, e); |
628 | 642 | ||
629 | /* Start */ | 643 | /* Start */ |
630 | e->cur = e->start; | 644 | e->cur = e->start; |
631 | fprintf (stderr, "Running episode %u with timeout %s\n", | 645 | fprintf(stderr, "Running episode %u with timeout %s\n", |
632 | e->cur->id, | 646 | e->cur->id, |
633 | GNUNET_STRINGS_relative_time_to_string(e->cur->duration, GNUNET_YES)); | 647 | GNUNET_STRINGS_relative_time_to_string(e->cur->duration, GNUNET_YES)); |
634 | enforce_episode(e->cur); | 648 | enforce_episode(e->cur); |
635 | e->episode_timeout_task = GNUNET_SCHEDULER_add_delayed (e->cur->duration, | 649 | e->episode_timeout_task = GNUNET_SCHEDULER_add_delayed(e->cur->duration, |
636 | &timeout_episode, e); | 650 | &timeout_episode, e); |
637 | |||
638 | |||
639 | } | 651 | } |
640 | 652 | ||
641 | 653 | ||
642 | struct Experiment * | 654 | struct Experiment * |
643 | GNUNET_ATS_TEST_experimentation_load (const char *filename) | 655 | GNUNET_ATS_TEST_experimentation_load(const char *filename) |
644 | { | 656 | { |
645 | struct Experiment *e; | 657 | struct Experiment *e; |
646 | struct GNUNET_CONFIGURATION_Handle *cfg; | 658 | struct GNUNET_CONFIGURATION_Handle *cfg; |
659 | |||
647 | e = NULL; | 660 | e = NULL; |
648 | 661 | ||
649 | cfg = GNUNET_CONFIGURATION_create(); | 662 | cfg = GNUNET_CONFIGURATION_create(); |
650 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_load (cfg, filename)) | 663 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_load(cfg, filename)) |
651 | { | 664 | { |
652 | fprintf (stderr, "Failed to load `%s'\n", filename); | 665 | fprintf(stderr, "Failed to load `%s'\n", filename); |
653 | GNUNET_CONFIGURATION_destroy (cfg); | 666 | GNUNET_CONFIGURATION_destroy(cfg); |
654 | return NULL; | 667 | return NULL; |
655 | } | 668 | } |
656 | 669 | ||
657 | e = create_experiment (); | 670 | e = create_experiment(); |
658 | 671 | ||
659 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string(cfg, "experiment", | 672 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string(cfg, "experiment", |
660 | "name", &e->name)) | 673 | "name", &e->name)) |
661 | { | 674 | { |
662 | fprintf (stderr, "Invalid %s", "name"); | 675 | fprintf(stderr, "Invalid %s", "name"); |
663 | free_experiment (e); | 676 | free_experiment(e); |
664 | return NULL; | 677 | return NULL; |
665 | } | 678 | } |
666 | else | 679 | else |
667 | fprintf (stderr, "Experiment name: `%s'\n", e->name); | 680 | fprintf(stderr, "Experiment name: `%s'\n", e->name); |
668 | 681 | ||
669 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_filename (cfg, "experiment", | 682 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_filename(cfg, "experiment", |
670 | "cfg_file", &e->cfg_file)) | 683 | "cfg_file", &e->cfg_file)) |
671 | { | 684 | { |
672 | fprintf (stderr, "Invalid %s", "cfg_file"); | 685 | fprintf(stderr, "Invalid %s", "cfg_file"); |
673 | free_experiment (e); | 686 | free_experiment(e); |
674 | return NULL; | 687 | return NULL; |
675 | } | 688 | } |
676 | else | 689 | else |
677 | fprintf (stderr, "Experiment name: `%s'\n", e->cfg_file); | 690 | fprintf(stderr, "Experiment name: `%s'\n", e->cfg_file); |
678 | 691 | ||
679 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number(cfg, "experiment", | 692 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number(cfg, "experiment", |
680 | "masters", &e->num_masters)) | 693 | "masters", &e->num_masters)) |
681 | { | 694 | { |
682 | fprintf (stderr, "Invalid %s", "masters"); | 695 | fprintf(stderr, "Invalid %s", "masters"); |
683 | free_experiment (e); | 696 | free_experiment(e); |
684 | return NULL; | 697 | return NULL; |
685 | } | 698 | } |
686 | else | 699 | else |
687 | fprintf (stderr, "Experiment masters: `%llu'\n", | 700 | fprintf(stderr, "Experiment masters: `%llu'\n", |
688 | e->num_masters); | 701 | e->num_masters); |
689 | 702 | ||
690 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number(cfg, "experiment", | 703 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number(cfg, "experiment", |
691 | "slaves", &e->num_slaves)) | 704 | "slaves", &e->num_slaves)) |
692 | { | 705 | { |
693 | fprintf (stderr, "Invalid %s", "slaves"); | 706 | fprintf(stderr, "Invalid %s", "slaves"); |
694 | free_experiment (e); | 707 | free_experiment(e); |
695 | return NULL; | 708 | return NULL; |
696 | } | 709 | } |
697 | else | 710 | else |
698 | fprintf (stderr, "Experiment slaves: `%llu'\n", | 711 | fprintf(stderr, "Experiment slaves: `%llu'\n", |
699 | e->num_slaves); | 712 | e->num_slaves); |
700 | 713 | ||
701 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_time(cfg, "experiment", | 714 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_time(cfg, "experiment", |
702 | "log_freq", &e->log_freq)) | 715 | "log_freq", &e->log_freq)) |
703 | { | 716 | { |
704 | fprintf (stderr, "Invalid %s", "log_freq"); | 717 | fprintf(stderr, "Invalid %s", "log_freq"); |
705 | free_experiment (e); | 718 | free_experiment(e); |
706 | return NULL; | 719 | return NULL; |
707 | } | 720 | } |
708 | else | 721 | else |
709 | fprintf (stderr, "Experiment logging frequency: `%s'\n", | 722 | fprintf(stderr, "Experiment logging frequency: `%s'\n", |
710 | GNUNET_STRINGS_relative_time_to_string (e->log_freq, GNUNET_YES)); | 723 | GNUNET_STRINGS_relative_time_to_string(e->log_freq, GNUNET_YES)); |
711 | 724 | ||
712 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_time(cfg, "experiment", | 725 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_time(cfg, "experiment", |
713 | "max_duration", &e->max_duration)) | 726 | "max_duration", &e->max_duration)) |
714 | { | 727 | { |
715 | fprintf (stderr, "Invalid %s", "max_duration"); | 728 | fprintf(stderr, "Invalid %s", "max_duration"); |
716 | free_experiment (e); | 729 | free_experiment(e); |
717 | return NULL; | 730 | return NULL; |
718 | } | 731 | } |
719 | else | 732 | else |
720 | fprintf (stderr, "Experiment duration: `%s'\n", | 733 | fprintf(stderr, "Experiment duration: `%s'\n", |
721 | GNUNET_STRINGS_relative_time_to_string (e->max_duration, GNUNET_YES)); | 734 | GNUNET_STRINGS_relative_time_to_string(e->max_duration, GNUNET_YES)); |
722 | 735 | ||
723 | load_episodes (e, cfg); | 736 | load_episodes(e, cfg); |
724 | fprintf (stderr, "Loaded %u episodes with total duration %s\n", | 737 | fprintf(stderr, "Loaded %u episodes with total duration %s\n", |
725 | e->num_episodes, | 738 | e->num_episodes, |
726 | GNUNET_STRINGS_relative_time_to_string (e->total_duration, GNUNET_YES)); | 739 | GNUNET_STRINGS_relative_time_to_string(e->total_duration, GNUNET_YES)); |
727 | 740 | ||
728 | GNUNET_CONFIGURATION_destroy (cfg); | 741 | GNUNET_CONFIGURATION_destroy(cfg); |
729 | return e; | 742 | return e; |
730 | } | 743 | } |
731 | 744 | ||
732 | void | 745 | void |
733 | GNUNET_ATS_TEST_experimentation_stop (struct Experiment *e) | 746 | GNUNET_ATS_TEST_experimentation_stop(struct Experiment *e) |
734 | { | 747 | { |
735 | if (NULL != e->experiment_timeout_task) | 748 | if (NULL != e->experiment_timeout_task) |
736 | { | 749 | { |
737 | GNUNET_SCHEDULER_cancel (e->experiment_timeout_task); | 750 | GNUNET_SCHEDULER_cancel(e->experiment_timeout_task); |
738 | e->experiment_timeout_task = NULL; | 751 | e->experiment_timeout_task = NULL; |
739 | } | 752 | } |
740 | if (NULL != e->episode_timeout_task) | 753 | if (NULL != e->episode_timeout_task) |
741 | { | 754 | { |
742 | GNUNET_SCHEDULER_cancel (e->episode_timeout_task); | 755 | GNUNET_SCHEDULER_cancel(e->episode_timeout_task); |
743 | e->episode_timeout_task = NULL; | 756 | e->episode_timeout_task = NULL; |
744 | } | 757 | } |
745 | free_experiment (e); | 758 | free_experiment(e); |
746 | } | 759 | } |
747 | 760 | ||
748 | /* end of file ats-testing-experiment.c*/ | 761 | /* 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 index 8624904a5..a362955d2 100644 --- a/src/ats-tests/ats-testing-log.c +++ b/src/ats-tests/ats-testing-log.c | |||
@@ -1,19 +1,19 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2010-2013 GNUnet e.V. | 3 | Copyright (C) 2010-2013 GNUnet e.V. |
4 | 4 | ||
5 | GNUnet is free software: you can redistribute it and/or modify it | 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 | 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, | 7 | by the Free Software Foundation, either version 3 of the License, |
8 | or (at your option) any later version. | 8 | or (at your option) any later version. |
9 | 9 | ||
10 | GNUnet is distributed in the hope that it will be useful, but | 10 | GNUnet is distributed in the hope that it will be useful, but |
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Affero General Public License for more details. | 13 | Affero General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Affero General Public License | 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/>. | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | 17 | ||
18 | SPDX-License-Identifier: AGPL3.0-or-later | 18 | SPDX-License-Identifier: AGPL3.0-or-later |
19 | */ | 19 | */ |
@@ -28,25 +28,25 @@ | |||
28 | #include "ats-testing.h" | 28 | #include "ats-testing.h" |
29 | 29 | ||
30 | #define THROUGHPUT_TEMPLATE "#!/usr/bin/gnuplot \n" \ | 30 | #define THROUGHPUT_TEMPLATE "#!/usr/bin/gnuplot \n" \ |
31 | "set datafile separator ';' \n" \ | 31 | "set datafile separator ';' \n" \ |
32 | "set title \"Throughput between Master and Slaves\" \n" \ | 32 | "set title \"Throughput between Master and Slaves\" \n" \ |
33 | "set xlabel \"Time in ms\" \n" \ | 33 | "set xlabel \"Time in ms\" \n" \ |
34 | "set ylabel \"Bytes/s\" \n" \ | 34 | "set ylabel \"Bytes/s\" \n" \ |
35 | "set grid \n" | 35 | "set grid \n" |
36 | 36 | ||
37 | #define RTT_TEMPLATE "#!/usr/bin/gnuplot \n" \ | 37 | #define RTT_TEMPLATE "#!/usr/bin/gnuplot \n" \ |
38 | "set datafile separator ';' \n" \ | 38 | "set datafile separator ';' \n" \ |
39 | "set title \"Application level roundtrip time between Master and Slaves\" \n" \ | 39 | "set title \"Application level roundtrip time between Master and Slaves\" \n" \ |
40 | "set xlabel \"Time in ms\" \n" \ | 40 | "set xlabel \"Time in ms\" \n" \ |
41 | "set ylabel \"ms\" \n" \ | 41 | "set ylabel \"ms\" \n" \ |
42 | "set grid \n" | 42 | "set grid \n" |
43 | 43 | ||
44 | #define BW_TEMPLATE "#!/usr/bin/gnuplot \n" \ | 44 | #define BW_TEMPLATE "#!/usr/bin/gnuplot \n" \ |
45 | "set datafile separator ';' \n" \ | 45 | "set datafile separator ';' \n" \ |
46 | "set title \"Bandwidth inbound and outbound between Master and Slaves\" \n" \ | 46 | "set title \"Bandwidth inbound and outbound between Master and Slaves\" \n" \ |
47 | "set xlabel \"Time in ms\" \n" \ | 47 | "set xlabel \"Time in ms\" \n" \ |
48 | "set ylabel \"Bytes / s \" \n" \ | 48 | "set ylabel \"Bytes / s \" \n" \ |
49 | "set grid \n" | 49 | "set grid \n" |
50 | 50 | ||
51 | #define LOG_ITEMS_TIME 2 | 51 | #define LOG_ITEMS_TIME 2 |
52 | #define LOG_ITEMS_PER_PEER 17 | 52 | #define LOG_ITEMS_PER_PEER 17 |
@@ -72,8 +72,7 @@ | |||
72 | /** | 72 | /** |
73 | * A single logging time step for a partner | 73 | * A single logging time step for a partner |
74 | */ | 74 | */ |
75 | struct PartnerLoggingTimestep | 75 | struct PartnerLoggingTimestep { |
76 | { | ||
77 | /** | 76 | /** |
78 | * Peer | 77 | * Peer |
79 | */ | 78 | */ |
@@ -143,8 +142,7 @@ struct PartnerLoggingTimestep | |||
143 | /** | 142 | /** |
144 | * A single logging time step for a peer | 143 | * A single logging time step for a peer |
145 | */ | 144 | */ |
146 | struct PeerLoggingTimestep | 145 | struct PeerLoggingTimestep { |
147 | { | ||
148 | /** | 146 | /** |
149 | * Next in DLL | 147 | * Next in DLL |
150 | */ | 148 | */ |
@@ -199,8 +197,7 @@ struct PeerLoggingTimestep | |||
199 | /** | 197 | /** |
200 | * Entry for a benchmark peer | 198 | * Entry for a benchmark peer |
201 | */ | 199 | */ |
202 | struct LoggingPeer | 200 | struct LoggingPeer { |
203 | { | ||
204 | /** | 201 | /** |
205 | * Peer | 202 | * Peer |
206 | */ | 203 | */ |
@@ -222,8 +219,7 @@ struct LoggingPeer | |||
222 | struct PeerLoggingTimestep *tail; | 219 | struct PeerLoggingTimestep *tail; |
223 | }; | 220 | }; |
224 | 221 | ||
225 | struct LoggingHandle | 222 | struct LoggingHandle { |
226 | { | ||
227 | /** | 223 | /** |
228 | * Logging task | 224 | * Logging task |
229 | */ | 225 | */ |
@@ -248,179 +244,179 @@ struct LoggingHandle | |||
248 | 244 | ||
249 | 245 | ||
250 | static void | 246 | static void |
251 | write_throughput_gnuplot_script (char * fn, struct LoggingPeer *lp, char **fs, int slaves) | 247 | write_throughput_gnuplot_script(char * fn, struct LoggingPeer *lp, char **fs, int slaves) |
252 | { | 248 | { |
253 | struct GNUNET_DISK_FileHandle *f; | 249 | struct GNUNET_DISK_FileHandle *f; |
254 | char * gfn; | 250 | char * gfn; |
255 | char *data; | 251 | char *data; |
256 | int c_s; | 252 | int c_s; |
257 | 253 | ||
258 | GNUNET_asprintf (&gfn, "gnuplot_throughput_%s",fn); | 254 | GNUNET_asprintf(&gfn, "gnuplot_throughput_%s", fn); |
259 | fprintf (stderr, "Writing throughput plot for master %u and %u slaves to `%s'\n", | 255 | fprintf(stderr, "Writing throughput plot for master %u and %u slaves to `%s'\n", |
260 | lp->peer->no, slaves, gfn); | 256 | lp->peer->no, slaves, gfn); |
261 | 257 | ||
262 | f = GNUNET_DISK_file_open (gfn, | 258 | f = GNUNET_DISK_file_open(gfn, |
263 | GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE, | 259 | GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE, |
264 | GNUNET_DISK_PERM_USER_EXEC | GNUNET_DISK_PERM_USER_READ | | 260 | GNUNET_DISK_PERM_USER_EXEC | GNUNET_DISK_PERM_USER_READ | |
265 | GNUNET_DISK_PERM_USER_WRITE); | 261 | GNUNET_DISK_PERM_USER_WRITE); |
266 | if (NULL == f) | 262 | if (NULL == f) |
267 | { | 263 | { |
268 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot open gnuplot file `%s'\n", gfn); | 264 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Cannot open gnuplot file `%s'\n", gfn); |
269 | GNUNET_free (gfn); | 265 | GNUNET_free(gfn); |
270 | return; | 266 | return; |
271 | } | 267 | } |
272 | 268 | ||
273 | /* Write header */ | 269 | /* Write header */ |
274 | if (GNUNET_SYSERR == GNUNET_DISK_file_write(f, THROUGHPUT_TEMPLATE, | 270 | if (GNUNET_SYSERR == GNUNET_DISK_file_write(f, THROUGHPUT_TEMPLATE, |
275 | strlen(THROUGHPUT_TEMPLATE))) | 271 | strlen(THROUGHPUT_TEMPLATE))) |
276 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 272 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, |
277 | "Cannot write data to plot file `%s'\n", gfn); | 273 | "Cannot write data to plot file `%s'\n", gfn); |
278 | 274 | ||
279 | /* Write master data */ | 275 | /* Write master data */ |
280 | GNUNET_asprintf (&data, | 276 | GNUNET_asprintf(&data, |
281 | "plot '%s' using 2:%u with lines title 'Master %u send total', \\\n" \ | 277 | "plot '%s' using 2:%u with lines title 'Master %u send total', \\\n" \ |
282 | "'%s' using 2:%u with lines title 'Master %u receive total', \\\n", | 278 | "'%s' using 2:%u with lines title 'Master %u receive total', \\\n", |
283 | fn, LOG_ITEMS_TIME + LOG_ITEM_THROUGHPUT_SENT, lp->peer->no, | 279 | fn, LOG_ITEMS_TIME + LOG_ITEM_THROUGHPUT_SENT, lp->peer->no, |
284 | fn, LOG_ITEMS_TIME + LOG_ITEM_THROUGHPUT_RECV, lp->peer->no); | 280 | fn, LOG_ITEMS_TIME + LOG_ITEM_THROUGHPUT_RECV, lp->peer->no); |
285 | if (GNUNET_SYSERR == GNUNET_DISK_file_write(f, data, strlen(data))) | 281 | if (GNUNET_SYSERR == GNUNET_DISK_file_write(f, data, strlen(data))) |
286 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot write data to plot file `%s'\n", gfn); | 282 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Cannot write data to plot file `%s'\n", gfn); |
287 | GNUNET_free (data); | 283 | GNUNET_free(data); |
288 | 284 | ||
289 | for (c_s = 0; c_s < slaves; c_s++) | 285 | for (c_s = 0; c_s < slaves; c_s++) |
290 | { | 286 | { |
291 | GNUNET_asprintf (&data, "'%s' using 2:%u with lines title 'Master %u - Slave %u send', \\\n" \ | 287 | GNUNET_asprintf(&data, "'%s' using 2:%u with lines title 'Master %u - Slave %u send', \\\n" \ |
292 | "'%s' using 2:%u with lines title 'Master %u - Slave %u receive'%s\n", | 288 | "'%s' using 2:%u with lines title 'Master %u - Slave %u receive'%s\n", |
293 | fs[c_s], | 289 | fs[c_s], |
294 | LOG_ITEMS_TIME + LOG_ITEM_THROUGHPUT_SENT, | 290 | LOG_ITEMS_TIME + LOG_ITEM_THROUGHPUT_SENT, |
295 | lp->peer->no, | 291 | lp->peer->no, |
296 | lp->peer->partners[c_s].dest->no, | 292 | lp->peer->partners[c_s].dest->no, |
297 | fs[c_s], | 293 | fs[c_s], |
298 | LOG_ITEMS_TIME + LOG_ITEM_THROUGHPUT_RECV, | 294 | LOG_ITEMS_TIME + LOG_ITEM_THROUGHPUT_RECV, |
299 | lp->peer->no, | 295 | lp->peer->no, |
300 | lp->peer->partners[c_s].dest->no, | 296 | lp->peer->partners[c_s].dest->no, |
301 | (c_s < lp->peer->num_partners -1) ? ", \\" : "\n pause -1"); | 297 | (c_s < lp->peer->num_partners - 1) ? ", \\" : "\n pause -1"); |
302 | if (GNUNET_SYSERR == GNUNET_DISK_file_write(f, data, strlen(data))) | 298 | if (GNUNET_SYSERR == GNUNET_DISK_file_write(f, data, strlen(data))) |
303 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot write data to plot file `%s'\n", gfn); | 299 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Cannot write data to plot file `%s'\n", gfn); |
304 | GNUNET_free (data); | 300 | GNUNET_free(data); |
305 | } | 301 | } |
306 | 302 | ||
307 | if (GNUNET_SYSERR == GNUNET_DISK_file_close(f)) | 303 | if (GNUNET_SYSERR == GNUNET_DISK_file_close(f)) |
308 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 304 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, |
309 | "Cannot close gnuplot file `%s'\n", gfn); | 305 | "Cannot close gnuplot file `%s'\n", gfn); |
310 | else | 306 | else |
311 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 307 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, |
312 | "Data successfully written to plot file `%s'\n", gfn); | 308 | "Data successfully written to plot file `%s'\n", gfn); |
313 | GNUNET_free (gfn); | 309 | GNUNET_free(gfn); |
314 | } | 310 | } |
315 | 311 | ||
316 | 312 | ||
317 | static void | 313 | static void |
318 | write_rtt_gnuplot_script (char * fn, struct LoggingPeer *lp, char **fs, int slaves) | 314 | write_rtt_gnuplot_script(char * fn, struct LoggingPeer *lp, char **fs, int slaves) |
319 | { | 315 | { |
320 | struct GNUNET_DISK_FileHandle *f; | 316 | struct GNUNET_DISK_FileHandle *f; |
321 | char * gfn; | 317 | char * gfn; |
322 | char *data; | 318 | char *data; |
323 | int c_s; | 319 | int c_s; |
324 | 320 | ||
325 | GNUNET_asprintf (&gfn, "gnuplot_rtt_%s",fn); | 321 | GNUNET_asprintf(&gfn, "gnuplot_rtt_%s", fn); |
326 | fprintf (stderr, "Writing rtt plot for master %u to `%s'\n", | 322 | fprintf(stderr, "Writing rtt plot for master %u to `%s'\n", |
327 | lp->peer->no, gfn); | 323 | lp->peer->no, gfn); |
328 | 324 | ||
329 | f = GNUNET_DISK_file_open (gfn, | 325 | f = GNUNET_DISK_file_open(gfn, |
330 | GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE, | 326 | GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE, |
331 | GNUNET_DISK_PERM_USER_EXEC | GNUNET_DISK_PERM_USER_READ | | 327 | GNUNET_DISK_PERM_USER_EXEC | GNUNET_DISK_PERM_USER_READ | |
332 | GNUNET_DISK_PERM_USER_WRITE); | 328 | GNUNET_DISK_PERM_USER_WRITE); |
333 | if (NULL == f) | 329 | if (NULL == f) |
334 | { | 330 | { |
335 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot open gnuplot file `%s'\n", gfn); | 331 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Cannot open gnuplot file `%s'\n", gfn); |
336 | GNUNET_free (gfn); | 332 | GNUNET_free(gfn); |
337 | return; | 333 | return; |
338 | } | 334 | } |
339 | 335 | ||
340 | /* Write header */ | 336 | /* Write header */ |
341 | if (GNUNET_SYSERR == GNUNET_DISK_file_write(f, RTT_TEMPLATE, strlen(RTT_TEMPLATE))) | 337 | if (GNUNET_SYSERR == GNUNET_DISK_file_write(f, RTT_TEMPLATE, strlen(RTT_TEMPLATE))) |
342 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot write data to plot file `%s'\n", gfn); | 338 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Cannot write data to plot file `%s'\n", gfn); |
343 | 339 | ||
344 | for (c_s = 0; c_s < slaves; c_s++) | 340 | for (c_s = 0; c_s < slaves; c_s++) |
345 | { | 341 | { |
346 | GNUNET_asprintf (&data, "%s'%s' using 2:%u with lines title 'Master %u - Slave %u '%s\n", | 342 | GNUNET_asprintf(&data, "%s'%s' using 2:%u with lines title 'Master %u - Slave %u '%s\n", |
347 | (0 == c_s) ? "plot " :"", | 343 | (0 == c_s) ? "plot " : "", |
348 | fs[c_s], | 344 | fs[c_s], |
349 | LOG_ITEMS_TIME + LOG_ITEM_APP_RTT, | 345 | LOG_ITEMS_TIME + LOG_ITEM_APP_RTT, |
350 | lp->peer->no, | 346 | lp->peer->no, |
351 | lp->peer->partners[c_s].dest->no, | 347 | lp->peer->partners[c_s].dest->no, |
352 | (c_s < lp->peer->num_partners -1) ? ", \\" : "\n pause -1"); | 348 | (c_s < lp->peer->num_partners - 1) ? ", \\" : "\n pause -1"); |
353 | if (GNUNET_SYSERR == GNUNET_DISK_file_write(f, data, strlen(data))) | 349 | if (GNUNET_SYSERR == GNUNET_DISK_file_write(f, data, strlen(data))) |
354 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot write data to plot file `%s'\n", gfn); | 350 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Cannot write data to plot file `%s'\n", gfn); |
355 | GNUNET_free (data); | 351 | GNUNET_free(data); |
356 | } | 352 | } |
357 | 353 | ||
358 | if (GNUNET_SYSERR == GNUNET_DISK_file_close(f)) | 354 | if (GNUNET_SYSERR == GNUNET_DISK_file_close(f)) |
359 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot close gnuplot file `%s'\n", gfn); | 355 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Cannot close gnuplot file `%s'\n", gfn); |
360 | else | 356 | else |
361 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Data successfully written to plot file `%s'\n", gfn); | 357 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Data successfully written to plot file `%s'\n", gfn); |
362 | GNUNET_free (gfn); | 358 | GNUNET_free(gfn); |
363 | } | 359 | } |
364 | 360 | ||
365 | static void | 361 | static void |
366 | write_bw_gnuplot_script (char * fn, struct LoggingPeer *lp, char **fs, int slaves) | 362 | write_bw_gnuplot_script(char * fn, struct LoggingPeer *lp, char **fs, int slaves) |
367 | { | 363 | { |
368 | struct GNUNET_DISK_FileHandle *f; | 364 | struct GNUNET_DISK_FileHandle *f; |
369 | char * gfn; | 365 | char * gfn; |
370 | char *data; | 366 | char *data; |
371 | int c_s; | 367 | int c_s; |
372 | 368 | ||
373 | GNUNET_asprintf (&gfn, "gnuplot_bw_%s",fn); | 369 | GNUNET_asprintf(&gfn, "gnuplot_bw_%s", fn); |
374 | fprintf (stderr, "Writing bandwidth plot for master %u to `%s'\n", | 370 | fprintf(stderr, "Writing bandwidth plot for master %u to `%s'\n", |
375 | lp->peer->no, gfn); | 371 | lp->peer->no, gfn); |
376 | 372 | ||
377 | f = GNUNET_DISK_file_open (gfn, | 373 | f = GNUNET_DISK_file_open(gfn, |
378 | GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE, | 374 | GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE, |
379 | GNUNET_DISK_PERM_USER_EXEC | GNUNET_DISK_PERM_USER_READ | | 375 | GNUNET_DISK_PERM_USER_EXEC | GNUNET_DISK_PERM_USER_READ | |
380 | GNUNET_DISK_PERM_USER_WRITE); | 376 | GNUNET_DISK_PERM_USER_WRITE); |
381 | if (NULL == f) | 377 | if (NULL == f) |
382 | { | 378 | { |
383 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot open gnuplot file `%s'\n", gfn); | 379 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Cannot open gnuplot file `%s'\n", gfn); |
384 | GNUNET_free (gfn); | 380 | GNUNET_free(gfn); |
385 | return; | 381 | return; |
386 | } | 382 | } |
387 | 383 | ||
388 | /* Write header */ | 384 | /* Write header */ |
389 | if (GNUNET_SYSERR == GNUNET_DISK_file_write(f, BW_TEMPLATE, strlen(BW_TEMPLATE))) | 385 | if (GNUNET_SYSERR == GNUNET_DISK_file_write(f, BW_TEMPLATE, strlen(BW_TEMPLATE))) |
390 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 386 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, |
391 | "Cannot write data to plot file `%s'\n", gfn); | 387 | "Cannot write data to plot file `%s'\n", gfn); |
392 | 388 | ||
393 | for (c_s = 0; c_s < slaves; c_s++) | 389 | for (c_s = 0; c_s < slaves; c_s++) |
394 | { | 390 | { |
395 | GNUNET_asprintf (&data, "%s"\ | 391 | GNUNET_asprintf(&data, "%s" \ |
396 | "'%s' using 2:%u with lines title 'BW out master %u - Slave %u ', \\\n" \ | 392 | "'%s' using 2:%u with lines title 'BW out master %u - Slave %u ', \\\n" \ |
397 | "'%s' using 2:%u with lines title 'BW in master %u - Slave %u '"\ | 393 | "'%s' using 2:%u with lines title 'BW in master %u - Slave %u '" \ |
398 | "%s\n", | 394 | "%s\n", |
399 | (0 == c_s) ? "plot " :"", | 395 | (0 == c_s) ? "plot " : "", |
400 | fs[c_s], | 396 | fs[c_s], |
401 | LOG_ITEMS_TIME + LOG_ITEM_ATS_BW_OUT, | 397 | LOG_ITEMS_TIME + LOG_ITEM_ATS_BW_OUT, |
402 | lp->peer->no, c_s, | 398 | lp->peer->no, c_s, |
403 | fs[c_s], | 399 | fs[c_s], |
404 | LOG_ITEMS_TIME + LOG_ITEM_ATS_BW_IN, | 400 | LOG_ITEMS_TIME + LOG_ITEM_ATS_BW_IN, |
405 | lp->peer->no, c_s, | 401 | lp->peer->no, c_s, |
406 | (c_s < lp->peer->num_partners -1) ? ", \\" : "\n pause -1"); | 402 | (c_s < lp->peer->num_partners - 1) ? ", \\" : "\n pause -1"); |
407 | if (GNUNET_SYSERR == GNUNET_DISK_file_write(f, data, strlen(data))) | 403 | if (GNUNET_SYSERR == GNUNET_DISK_file_write(f, data, strlen(data))) |
408 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot write data to plot file `%s'\n", gfn); | 404 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Cannot write data to plot file `%s'\n", gfn); |
409 | GNUNET_free (data); | 405 | GNUNET_free(data); |
410 | } | 406 | } |
411 | 407 | ||
412 | if (GNUNET_SYSERR == GNUNET_DISK_file_close(f)) | 408 | if (GNUNET_SYSERR == GNUNET_DISK_file_close(f)) |
413 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot close gnuplot file `%s'\n", gfn); | 409 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Cannot close gnuplot file `%s'\n", gfn); |
414 | else | 410 | else |
415 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Data successfully written to plot file `%s'\n", gfn); | 411 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Data successfully written to plot file `%s'\n", gfn); |
416 | GNUNET_free (gfn); | 412 | GNUNET_free(gfn); |
417 | } | 413 | } |
418 | 414 | ||
419 | 415 | ||
420 | void | 416 | void |
421 | GNUNET_ATS_TEST_logging_write_to_file (struct LoggingHandle *l, | 417 | GNUNET_ATS_TEST_logging_write_to_file(struct LoggingHandle *l, |
422 | const char *experiment_name, | 418 | const char *experiment_name, |
423 | int plots) | 419 | int plots) |
424 | { | 420 | { |
425 | struct GNUNET_DISK_FileHandle *f[l->num_slaves]; | 421 | struct GNUNET_DISK_FileHandle *f[l->num_slaves]; |
426 | struct GNUNET_DISK_FileHandle *f_m; | 422 | struct GNUNET_DISK_FileHandle *f_m; |
@@ -439,179 +435,178 @@ GNUNET_ATS_TEST_logging_write_to_file (struct LoggingHandle *l, | |||
439 | 435 | ||
440 | tmp_exp_name = experiment_name; | 436 | tmp_exp_name = experiment_name; |
441 | for (c_m = 0; c_m < l->num_masters; c_m++) | 437 | for (c_m = 0; c_m < l->num_masters; c_m++) |
442 | { | ||
443 | GNUNET_asprintf (&filename_master, "%s_%llu_master%u_%s", | ||
444 | experiment_name, timestamp.abs_value_us, c_m, l->name); | ||
445 | fprintf (stderr, "Writing data for master %u to file `%s'\n", | ||
446 | c_m,filename_master); | ||
447 | |||
448 | f_m = GNUNET_DISK_file_open (filename_master, | ||
449 | GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE, | ||
450 | GNUNET_DISK_PERM_USER_READ | GNUNET_DISK_PERM_USER_WRITE); | ||
451 | if (NULL == f_m) | ||
452 | { | ||
453 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot open log file `%s'\n", filename_master); | ||
454 | GNUNET_free (filename_master); | ||
455 | return; | ||
456 | } | ||
457 | |||
458 | GNUNET_asprintf (&data, "# master %u; experiment : %s\n" | ||
459 | "timestamp; timestamp delta; #messages sent; #bytes sent; #throughput sent; #messages received; #bytes received; #throughput received; \n" , | ||
460 | c_m, experiment_name); | ||
461 | if (GNUNET_SYSERR == GNUNET_DISK_file_write(f_m, data, strlen(data))) | ||
462 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
463 | "Cannot write data to log file `%s'\n",filename_master); | ||
464 | GNUNET_free (data); | ||
465 | |||
466 | for (c_s = 0; c_s < l->lp[c_m].peer->num_partners; c_s++) | ||
467 | { | ||
468 | GNUNET_asprintf (&filename_slaves[c_s], "%s_%llu_master%u_slave_%u_%s", | ||
469 | tmp_exp_name, timestamp.abs_value_us, c_m, c_s, l->name); | ||
470 | |||
471 | fprintf (stderr, "Writing data for master %u slave %u to file `%s'\n", | ||
472 | c_m, c_s, filename_slaves[c_s]); | ||
473 | |||
474 | f[c_s] = GNUNET_DISK_file_open (filename_slaves[c_s], | ||
475 | GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE, | ||
476 | GNUNET_DISK_PERM_USER_READ | GNUNET_DISK_PERM_USER_WRITE); | ||
477 | if (NULL == f[c_s]) | ||
478 | { | ||
479 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot open log file `%s'\n", filename_slaves[c_s]); | ||
480 | GNUNET_free (filename_slaves[c_s]); | ||
481 | GNUNET_break (GNUNET_OK == GNUNET_DISK_file_close(f_m)); | ||
482 | GNUNET_free (filename_master); | ||
483 | return; | ||
484 | } | ||
485 | |||
486 | /* Header */ | ||
487 | GNUNET_asprintf (&data, "# master %u; slave %u ; experiment : %s\n" | ||
488 | "timestamp; timestamp delta; #messages sent; #bytes sent; #throughput sent; #messages received; #bytes received; #throughput received; " \ | ||
489 | "rtt; bw in; bw out; ats_cost_lan; ats_cost_wlan; ats_delay; ats_distance; ats_network_type; ats_utilization_up ;ats_utilization_down;" \ | ||
490 | "pref bandwidth; pref delay\n", | ||
491 | c_m, c_s, experiment_name); | ||
492 | if (GNUNET_SYSERR == GNUNET_DISK_file_write(f[c_s], data, strlen(data))) | ||
493 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
494 | "Cannot write data to log file `%s'\n",filename_slaves[c_s]); | ||
495 | GNUNET_free (data); | ||
496 | } | ||
497 | |||
498 | for (cur_lt = l->lp[c_m].head; NULL != cur_lt; cur_lt = cur_lt->next) | ||
499 | { | 438 | { |
500 | if (l->verbose) | 439 | GNUNET_asprintf(&filename_master, "%s_%llu_master%u_%s", |
501 | fprintf (stderr, | 440 | experiment_name, timestamp.abs_value_us, c_m, l->name); |
502 | "Master [%u]: timestamp %llu %llu ; %u %u %u ; %u %u %u\n", | 441 | fprintf(stderr, "Writing data for master %u to file `%s'\n", |
503 | l->lp[c_m].peer->no, | 442 | c_m, filename_master); |
504 | (long long unsigned int) cur_lt->timestamp.abs_value_us, | 443 | |
505 | (long long unsigned int) GNUNET_TIME_absolute_get_difference(l->lp[c_m].start, | 444 | f_m = GNUNET_DISK_file_open(filename_master, |
506 | cur_lt->timestamp).rel_value_us / 1000, | 445 | GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE, |
507 | cur_lt->total_messages_sent, | 446 | GNUNET_DISK_PERM_USER_READ | GNUNET_DISK_PERM_USER_WRITE); |
508 | cur_lt->total_bytes_sent, | 447 | if (NULL == f_m) |
509 | cur_lt->total_throughput_send, | 448 | { |
510 | cur_lt->total_messages_received, | 449 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Cannot open log file `%s'\n", filename_master); |
511 | cur_lt->total_bytes_received, | 450 | GNUNET_free(filename_master); |
512 | cur_lt->total_throughput_recv); | 451 | return; |
513 | 452 | } | |
514 | /* Assembling master string */ | ||
515 | GNUNET_asprintf (&data, "%llu;%llu;%u;%u;%u;%u;%u;%u;\n", | ||
516 | (long long unsigned int) cur_lt->timestamp.abs_value_us, | ||
517 | (long long unsigned int) GNUNET_TIME_absolute_get_difference(l->lp[c_m].start, | ||
518 | cur_lt->timestamp).rel_value_us / 1000, | ||
519 | cur_lt->total_messages_sent, | ||
520 | cur_lt->total_bytes_sent, | ||
521 | cur_lt->total_throughput_send, | ||
522 | cur_lt->total_messages_received, | ||
523 | cur_lt->total_bytes_received, | ||
524 | cur_lt->total_throughput_recv); | ||
525 | 453 | ||
454 | GNUNET_asprintf(&data, "# master %u; experiment : %s\n" | ||
455 | "timestamp; timestamp delta; #messages sent; #bytes sent; #throughput sent; #messages received; #bytes received; #throughput received; \n", | ||
456 | c_m, experiment_name); | ||
526 | if (GNUNET_SYSERR == GNUNET_DISK_file_write(f_m, data, strlen(data))) | 457 | if (GNUNET_SYSERR == GNUNET_DISK_file_write(f_m, data, strlen(data))) |
527 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 458 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, |
528 | "Cannot write data to master file %u\n", c_m); | 459 | "Cannot write data to log file `%s'\n", filename_master); |
529 | GNUNET_free (data); | 460 | GNUNET_free(data); |
530 | |||
531 | 461 | ||
532 | for (c_s = 0; c_s < l->lp[c_m].peer->num_partners; c_s++) | 462 | for (c_s = 0; c_s < l->lp[c_m].peer->num_partners; c_s++) |
533 | { | 463 | { |
534 | plt = &cur_lt->slaves_log[c_s]; | 464 | GNUNET_asprintf(&filename_slaves[c_s], "%s_%llu_master%u_slave_%u_%s", |
535 | /* Log partners */ | 465 | tmp_exp_name, timestamp.abs_value_us, c_m, c_s, l->name); |
536 | 466 | ||
537 | /* Assembling slave string */ | 467 | fprintf(stderr, "Writing data for master %u slave %u to file `%s'\n", |
538 | GNUNET_asprintf(&data, | 468 | c_m, c_s, filename_slaves[c_s]); |
539 | "%llu;%llu;%u;%u;%u;%u;%u;%u;%.3f;%u;%u;%u;%u;%u;%u;%u;%.3f;%.3f\n", | 469 | |
540 | (long long unsigned int) cur_lt->timestamp.abs_value_us, | 470 | f[c_s] = GNUNET_DISK_file_open(filename_slaves[c_s], |
541 | (long long unsigned int) GNUNET_TIME_absolute_get_difference(l->lp[c_m].start, | 471 | GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE, |
542 | cur_lt->timestamp).rel_value_us / 1000, | 472 | GNUNET_DISK_PERM_USER_READ | GNUNET_DISK_PERM_USER_WRITE); |
543 | plt->total_messages_sent, | 473 | if (NULL == f[c_s]) |
544 | plt->total_bytes_sent, | 474 | { |
545 | plt->throughput_sent, | 475 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Cannot open log file `%s'\n", filename_slaves[c_s]); |
546 | plt->total_messages_received, | 476 | GNUNET_free(filename_slaves[c_s]); |
547 | plt->total_bytes_received, | 477 | GNUNET_break(GNUNET_OK == GNUNET_DISK_file_close(f_m)); |
548 | plt->throughput_recv, | 478 | GNUNET_free(filename_master); |
549 | (double) plt->app_rtt / 1000, | 479 | return; |
550 | plt->bandwidth_in, | 480 | } |
551 | plt->bandwidth_out, | 481 | |
552 | plt->ats_delay, | 482 | /* Header */ |
553 | plt->ats_distance, | 483 | GNUNET_asprintf(&data, "# master %u; slave %u ; experiment : %s\n" |
554 | plt->ats_network_type, | 484 | "timestamp; timestamp delta; #messages sent; #bytes sent; #throughput sent; #messages received; #bytes received; #throughput received; " \ |
555 | plt->ats_utilization_out, | 485 | "rtt; bw in; bw out; ats_cost_lan; ats_cost_wlan; ats_delay; ats_distance; ats_network_type; ats_utilization_up ;ats_utilization_down;" \ |
556 | plt->ats_utilization_in, | 486 | "pref bandwidth; pref delay\n", |
557 | plt->pref_bandwidth, | 487 | c_m, c_s, experiment_name); |
558 | plt->pref_delay); | 488 | if (GNUNET_SYSERR == GNUNET_DISK_file_write(f[c_s], data, strlen(data))) |
559 | 489 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, | |
560 | if (l->verbose) | 490 | "Cannot write data to log file `%s'\n", filename_slaves[c_s]); |
561 | fprintf (stderr, | 491 | GNUNET_free(data); |
562 | "\t Slave [%u]: %u %u %u ; %u %u %u rtt %u delay %llu bw_in %u bw_out %u \n", | 492 | } |
563 | plt->slave->no, | ||
564 | plt->total_messages_sent, | ||
565 | plt->total_bytes_sent, | ||
566 | plt->throughput_sent, | ||
567 | plt->total_messages_received, | ||
568 | plt->total_bytes_received, | ||
569 | plt->throughput_recv, | ||
570 | plt->app_rtt, | ||
571 | (long long unsigned int) plt->ats_delay.rel_value_us, | ||
572 | plt->bandwidth_in, | ||
573 | plt->bandwidth_out); | ||
574 | |||
575 | if (GNUNET_SYSERR == GNUNET_DISK_file_write(f[c_s], data, strlen(data))) | ||
576 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
577 | "Cannot write data to log file `%s'\n", filename_slaves[c_s]); | ||
578 | GNUNET_free (data); | ||
579 | |||
580 | } | ||
581 | } | ||
582 | 493 | ||
583 | for (c_s = 0; c_s < l->lp[c_m].peer->num_partners; c_s++) | 494 | for (cur_lt = l->lp[c_m].head; NULL != cur_lt; cur_lt = cur_lt->next) |
584 | { | 495 | { |
585 | if (GNUNET_SYSERR == GNUNET_DISK_file_close(f[c_s])) | 496 | if (l->verbose) |
586 | { | 497 | fprintf(stderr, |
587 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 498 | "Master [%u]: timestamp %llu %llu ; %u %u %u ; %u %u %u\n", |
588 | "Cannot close log file for master[%u] slave[%u]\n", c_m, c_s); | 499 | l->lp[c_m].peer->no, |
589 | continue; | 500 | (long long unsigned int)cur_lt->timestamp.abs_value_us, |
590 | } | 501 | (long long unsigned int)GNUNET_TIME_absolute_get_difference(l->lp[c_m].start, |
591 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 502 | cur_lt->timestamp).rel_value_us / 1000, |
592 | "Data file successfully written to log file for `%s'\n", | 503 | cur_lt->total_messages_sent, |
593 | filename_slaves[c_s]); | 504 | cur_lt->total_bytes_sent, |
594 | } | 505 | cur_lt->total_throughput_send, |
506 | cur_lt->total_messages_received, | ||
507 | cur_lt->total_bytes_received, | ||
508 | cur_lt->total_throughput_recv); | ||
509 | |||
510 | /* Assembling master string */ | ||
511 | GNUNET_asprintf(&data, "%llu;%llu;%u;%u;%u;%u;%u;%u;\n", | ||
512 | (long long unsigned int)cur_lt->timestamp.abs_value_us, | ||
513 | (long long unsigned int)GNUNET_TIME_absolute_get_difference(l->lp[c_m].start, | ||
514 | cur_lt->timestamp).rel_value_us / 1000, | ||
515 | cur_lt->total_messages_sent, | ||
516 | cur_lt->total_bytes_sent, | ||
517 | cur_lt->total_throughput_send, | ||
518 | cur_lt->total_messages_received, | ||
519 | cur_lt->total_bytes_received, | ||
520 | cur_lt->total_throughput_recv); | ||
521 | |||
522 | if (GNUNET_SYSERR == GNUNET_DISK_file_write(f_m, data, strlen(data))) | ||
523 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, | ||
524 | "Cannot write data to master file %u\n", c_m); | ||
525 | GNUNET_free(data); | ||
526 | |||
527 | |||
528 | for (c_s = 0; c_s < l->lp[c_m].peer->num_partners; c_s++) | ||
529 | { | ||
530 | plt = &cur_lt->slaves_log[c_s]; | ||
531 | /* Log partners */ | ||
532 | |||
533 | /* Assembling slave string */ | ||
534 | GNUNET_asprintf(&data, | ||
535 | "%llu;%llu;%u;%u;%u;%u;%u;%u;%.3f;%u;%u;%u;%u;%u;%u;%u;%.3f;%.3f\n", | ||
536 | (long long unsigned int)cur_lt->timestamp.abs_value_us, | ||
537 | (long long unsigned int)GNUNET_TIME_absolute_get_difference(l->lp[c_m].start, | ||
538 | cur_lt->timestamp).rel_value_us / 1000, | ||
539 | plt->total_messages_sent, | ||
540 | plt->total_bytes_sent, | ||
541 | plt->throughput_sent, | ||
542 | plt->total_messages_received, | ||
543 | plt->total_bytes_received, | ||
544 | plt->throughput_recv, | ||
545 | (double)plt->app_rtt / 1000, | ||
546 | plt->bandwidth_in, | ||
547 | plt->bandwidth_out, | ||
548 | plt->ats_delay, | ||
549 | plt->ats_distance, | ||
550 | plt->ats_network_type, | ||
551 | plt->ats_utilization_out, | ||
552 | plt->ats_utilization_in, | ||
553 | plt->pref_bandwidth, | ||
554 | plt->pref_delay); | ||
555 | |||
556 | if (l->verbose) | ||
557 | fprintf(stderr, | ||
558 | "\t Slave [%u]: %u %u %u ; %u %u %u rtt %u delay %llu bw_in %u bw_out %u \n", | ||
559 | plt->slave->no, | ||
560 | plt->total_messages_sent, | ||
561 | plt->total_bytes_sent, | ||
562 | plt->throughput_sent, | ||
563 | plt->total_messages_received, | ||
564 | plt->total_bytes_received, | ||
565 | plt->throughput_recv, | ||
566 | plt->app_rtt, | ||
567 | (long long unsigned int)plt->ats_delay.rel_value_us, | ||
568 | plt->bandwidth_in, | ||
569 | plt->bandwidth_out); | ||
570 | |||
571 | if (GNUNET_SYSERR == GNUNET_DISK_file_write(f[c_s], data, strlen(data))) | ||
572 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, | ||
573 | "Cannot write data to log file `%s'\n", filename_slaves[c_s]); | ||
574 | GNUNET_free(data); | ||
575 | } | ||
576 | } | ||
595 | 577 | ||
596 | if (GNUNET_SYSERR == GNUNET_DISK_file_close(f_m)) | 578 | for (c_s = 0; c_s < l->lp[c_m].peer->num_partners; c_s++) |
597 | { | 579 | { |
598 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, | 580 | if (GNUNET_SYSERR == GNUNET_DISK_file_close(f[c_s])) |
599 | "close", | 581 | { |
600 | filename_master); | 582 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, |
601 | GNUNET_free (filename_master); | 583 | "Cannot close log file for master[%u] slave[%u]\n", c_m, c_s); |
602 | return; | 584 | continue; |
603 | } | 585 | } |
604 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 586 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, |
605 | "Data file successfully written to log file for master `%s'\n", filename_master); | 587 | "Data file successfully written to log file for `%s'\n", |
588 | filename_slaves[c_s]); | ||
589 | } | ||
606 | 590 | ||
607 | if (GNUNET_YES == plots) | 591 | if (GNUNET_SYSERR == GNUNET_DISK_file_close(f_m)) |
608 | { | 592 | { |
609 | write_throughput_gnuplot_script (filename_master, &l->lp[c_m], filename_slaves, l->num_slaves); | 593 | GNUNET_log_strerror_file(GNUNET_ERROR_TYPE_ERROR, |
610 | write_rtt_gnuplot_script (filename_master, &l->lp[c_m], filename_slaves, l->num_slaves); | 594 | "close", |
611 | write_bw_gnuplot_script (filename_master, &l->lp[c_m], filename_slaves, l->num_slaves); | 595 | filename_master); |
596 | GNUNET_free(filename_master); | ||
597 | return; | ||
598 | } | ||
599 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, | ||
600 | "Data file successfully written to log file for master `%s'\n", filename_master); | ||
601 | |||
602 | if (GNUNET_YES == plots) | ||
603 | { | ||
604 | write_throughput_gnuplot_script(filename_master, &l->lp[c_m], filename_slaves, l->num_slaves); | ||
605 | write_rtt_gnuplot_script(filename_master, &l->lp[c_m], filename_slaves, l->num_slaves); | ||
606 | write_bw_gnuplot_script(filename_master, &l->lp[c_m], filename_slaves, l->num_slaves); | ||
607 | } | ||
612 | } | 608 | } |
613 | } | 609 | GNUNET_free(filename_master); |
614 | GNUNET_free (filename_master); | ||
615 | } | 610 | } |
616 | 611 | ||
617 | /** | 612 | /** |
@@ -620,7 +615,7 @@ GNUNET_ATS_TEST_logging_write_to_file (struct LoggingHandle *l, | |||
620 | * @param l logging handle to use | 615 | * @param l logging handle to use |
621 | */ | 616 | */ |
622 | void | 617 | void |
623 | GNUNET_ATS_TEST_logging_now (struct LoggingHandle *l) | 618 | GNUNET_ATS_TEST_logging_now(struct LoggingHandle *l) |
624 | { | 619 | { |
625 | struct LoggingPeer *bp; | 620 | struct LoggingPeer *bp; |
626 | struct PeerLoggingTimestep *mlt; | 621 | struct PeerLoggingTimestep *mlt; |
@@ -638,180 +633,180 @@ GNUNET_ATS_TEST_logging_now (struct LoggingHandle *l) | |||
638 | return; | 633 | return; |
639 | 634 | ||
640 | for (c_m = 0; c_m < l->num_masters; c_m++) | 635 | for (c_m = 0; c_m < l->num_masters; c_m++) |
641 | { | ||
642 | bp = &l->lp[c_m]; | ||
643 | mlt = GNUNET_new (struct PeerLoggingTimestep); | ||
644 | GNUNET_CONTAINER_DLL_insert_tail(l->lp[c_m].head, l->lp[c_m].tail, mlt); | ||
645 | prev_log_mlt = mlt->prev; | ||
646 | |||
647 | /* Collect data */ | ||
648 | /* Current master state */ | ||
649 | mlt->timestamp = GNUNET_TIME_absolute_get(); | ||
650 | mlt->total_bytes_sent = bp->peer->total_bytes_sent; | ||
651 | mlt->total_messages_sent = bp->peer->total_messages_sent; | ||
652 | mlt->total_bytes_received = bp->peer->total_bytes_received; | ||
653 | mlt->total_messages_received = bp->peer->total_messages_received; | ||
654 | |||
655 | /* Throughput */ | ||
656 | if (NULL == prev_log_mlt) | ||
657 | { | ||
658 | /* Get difference to start */ | ||
659 | delta = GNUNET_TIME_absolute_get_difference (l->lp[c_m].start, mlt->timestamp); | ||
660 | } | ||
661 | else | ||
662 | { | ||
663 | /* Get difference to last timestep */ | ||
664 | delta = GNUNET_TIME_absolute_get_difference (mlt->prev->timestamp, mlt->timestamp); | ||
665 | } | ||
666 | |||
667 | /* Multiplication factor for throughput calculation */ | ||
668 | mult = (double) GNUNET_TIME_UNIT_SECONDS.rel_value_us / (delta.rel_value_us); | ||
669 | |||
670 | /* Total throughput */ | ||
671 | if (NULL != prev_log_mlt) | ||
672 | { | ||
673 | if (mlt->total_bytes_sent - mlt->prev->total_bytes_sent > 0) | ||
674 | { | ||
675 | mlt->total_throughput_send = mult * (mlt->total_bytes_sent - mlt->prev->total_bytes_sent); | ||
676 | } | ||
677 | else | ||
678 | { | ||
679 | mlt->total_throughput_send = 0; | ||
680 | // mlt->total_throughput_send = prev_log_mlt->total_throughput_send; /* no msgs send */ | ||
681 | } | ||
682 | |||
683 | if (mlt->total_bytes_received - mlt->prev->total_bytes_received > 0) | ||
684 | { | ||
685 | mlt->total_throughput_recv = mult * (mlt->total_bytes_received - mlt->prev->total_bytes_received); | ||
686 | } | ||
687 | else | ||
688 | { | ||
689 | mlt->total_throughput_recv = 0; | ||
690 | //mlt->total_throughput_recv = prev_log_mlt->total_throughput_recv; /* no msgs received */ | ||
691 | } | ||
692 | } | ||
693 | else | ||
694 | { | ||
695 | mlt->total_throughput_send = mult * mlt->total_bytes_sent; | ||
696 | mlt->total_throughput_recv = mult * mlt->total_bytes_received; | ||
697 | } | ||
698 | |||
699 | if (GNUNET_YES == l->verbose) | ||
700 | { | 636 | { |
701 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 637 | bp = &l->lp[c_m]; |
702 | "Master[%u] delta: %llu us, bytes (sent/received): %u / %u; throughput send/recv: %u / %u\n", | 638 | mlt = GNUNET_new(struct PeerLoggingTimestep); |
703 | c_m, | 639 | GNUNET_CONTAINER_DLL_insert_tail(l->lp[c_m].head, l->lp[c_m].tail, mlt); |
704 | (unsigned long long) delta.rel_value_us, | 640 | prev_log_mlt = mlt->prev; |
705 | mlt->total_bytes_sent, | 641 | |
706 | mlt->total_bytes_received, | 642 | /* Collect data */ |
707 | mlt->total_throughput_send, | 643 | /* Current master state */ |
708 | mlt->total_throughput_recv); | 644 | mlt->timestamp = GNUNET_TIME_absolute_get(); |
709 | } | 645 | mlt->total_bytes_sent = bp->peer->total_bytes_sent; |
710 | 646 | mlt->total_messages_sent = bp->peer->total_messages_sent; | |
711 | mlt->slaves_log = GNUNET_malloc (bp->peer->num_partners * | 647 | mlt->total_bytes_received = bp->peer->total_bytes_received; |
712 | sizeof (struct PartnerLoggingTimestep)); | 648 | mlt->total_messages_received = bp->peer->total_messages_received; |
713 | 649 | ||
714 | for (c_s = 0; c_s < bp->peer->num_partners; c_s++) | 650 | /* Throughput */ |
715 | { | ||
716 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
717 | "Collect logging data master[%u] slave [%u]\n", c_m, c_s); | ||
718 | |||
719 | p = &bp->peer->partners[c_s]; | ||
720 | slt = &mlt->slaves_log[c_s]; | ||
721 | |||
722 | slt->slave = p->dest; | ||
723 | /* Bytes sent from master to this slave */ | ||
724 | slt->total_bytes_sent = p->bytes_sent; | ||
725 | /* Messages sent from master to this slave */ | ||
726 | slt->total_messages_sent = p->messages_sent; | ||
727 | /* Bytes master received from this slave */ | ||
728 | slt->total_bytes_received = p->bytes_received; | ||
729 | /* Messages master received from this slave */ | ||
730 | slt->total_messages_received = p->messages_received; | ||
731 | slt->total_app_rtt = p->total_app_rtt; | ||
732 | /* ats performance information */ | ||
733 | slt->ats_delay = p->props.delay; | ||
734 | slt->ats_distance = p->props.distance; | ||
735 | slt->ats_network_type = p->props.scope; | ||
736 | slt->ats_utilization_in = p->props.utilization_out; | ||
737 | slt->ats_utilization_out = p->props.utilization_out; | ||
738 | slt->bandwidth_in = p->bandwidth_in; | ||
739 | slt->bandwidth_out = p->bandwidth_out; | ||
740 | slt->pref_bandwidth = p->pref_bandwidth; | ||
741 | slt->pref_delay = p->pref_delay; | ||
742 | |||
743 | /* Total application level rtt */ | ||
744 | if (NULL == prev_log_mlt) | 651 | if (NULL == prev_log_mlt) |
745 | { | 652 | { |
746 | if (0 != slt->total_messages_sent) | 653 | /* Get difference to start */ |
747 | app_rtt = slt->total_app_rtt / slt->total_messages_sent; | 654 | delta = GNUNET_TIME_absolute_get_difference(l->lp[c_m].start, mlt->timestamp); |
748 | else | 655 | } |
749 | app_rtt = 0; | ||
750 | } | ||
751 | else | 656 | else |
752 | { | ||
753 | prev_log_slt = &prev_log_mlt->slaves_log[c_s]; | ||
754 | if ((slt->total_messages_sent - prev_log_slt->total_messages_sent) > 0) | ||
755 | app_rtt = (slt->total_app_rtt - prev_log_slt->total_app_rtt) / | ||
756 | (slt->total_messages_sent - prev_log_slt->total_messages_sent); | ||
757 | else | ||
758 | { | 657 | { |
759 | app_rtt = prev_log_slt->app_rtt; /* No messages were */ | 658 | /* Get difference to last timestep */ |
659 | delta = GNUNET_TIME_absolute_get_difference(mlt->prev->timestamp, mlt->timestamp); | ||
760 | } | 660 | } |
761 | } | ||
762 | slt->app_rtt = app_rtt; | ||
763 | 661 | ||
764 | /* Partner throughput */ | 662 | /* Multiplication factor for throughput calculation */ |
663 | mult = (double)GNUNET_TIME_UNIT_SECONDS.rel_value_us / (delta.rel_value_us); | ||
664 | |||
665 | /* Total throughput */ | ||
765 | if (NULL != prev_log_mlt) | 666 | if (NULL != prev_log_mlt) |
766 | { | 667 | { |
767 | prev_log_slt = &prev_log_mlt->slaves_log[c_s]; | 668 | if (mlt->total_bytes_sent - mlt->prev->total_bytes_sent > 0) |
768 | if (slt->total_bytes_sent > prev_log_slt->total_bytes_sent) | 669 | { |
769 | slt->throughput_sent = mult * (slt->total_bytes_sent - prev_log_slt->total_bytes_sent); | 670 | mlt->total_throughput_send = mult * (mlt->total_bytes_sent - mlt->prev->total_bytes_sent); |
770 | else | 671 | } |
771 | slt->throughput_sent = 0; | 672 | else |
772 | 673 | { | |
773 | if (slt->total_bytes_received > prev_log_slt->total_bytes_received) | 674 | mlt->total_throughput_send = 0; |
774 | slt->throughput_recv = mult * | 675 | // mlt->total_throughput_send = prev_log_mlt->total_throughput_send; /* no msgs send */ |
775 | (slt->total_bytes_received - prev_log_slt->total_bytes_received); | 676 | } |
776 | else | 677 | |
777 | slt->throughput_recv = 0; | 678 | if (mlt->total_bytes_received - mlt->prev->total_bytes_received > 0) |
778 | } | 679 | { |
680 | mlt->total_throughput_recv = mult * (mlt->total_bytes_received - mlt->prev->total_bytes_received); | ||
681 | } | ||
682 | else | ||
683 | { | ||
684 | mlt->total_throughput_recv = 0; | ||
685 | //mlt->total_throughput_recv = prev_log_mlt->total_throughput_recv; /* no msgs received */ | ||
686 | } | ||
687 | } | ||
779 | else | 688 | else |
780 | { | 689 | { |
781 | slt->throughput_sent = mult * slt->total_bytes_sent; | 690 | mlt->total_throughput_send = mult * mlt->total_bytes_sent; |
782 | slt->throughput_recv = mult * slt->total_bytes_received; | 691 | mlt->total_throughput_recv = mult * mlt->total_bytes_received; |
783 | } | 692 | } |
784 | 693 | ||
785 | if (GNUNET_YES == l->verbose) | 694 | if (GNUNET_YES == l->verbose) |
786 | { | 695 | { |
787 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 696 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, |
788 | "Master [%u] -> Slave [%u]: delta: %llu us, bytes (sent/received): %u / %u; throughput send/recv: %u / %u\n", | 697 | "Master[%u] delta: %llu us, bytes (sent/received): %u / %u; throughput send/recv: %u / %u\n", |
789 | c_m, c_s, | 698 | c_m, |
790 | (unsigned long long) delta.rel_value_us, | 699 | (unsigned long long)delta.rel_value_us, |
791 | mlt->total_bytes_sent, | 700 | mlt->total_bytes_sent, |
792 | mlt->total_bytes_received, | 701 | mlt->total_bytes_received, |
793 | slt->throughput_sent, | 702 | mlt->total_throughput_send, |
794 | slt->throughput_recv); | 703 | mlt->total_throughput_recv); |
795 | } | 704 | } |
796 | else | 705 | |
797 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 706 | mlt->slaves_log = GNUNET_malloc(bp->peer->num_partners * |
798 | "Master [%u]: slave [%u]\n", | 707 | sizeof(struct PartnerLoggingTimestep)); |
799 | bp->peer->no, p->dest->no); | 708 | |
709 | for (c_s = 0; c_s < bp->peer->num_partners; c_s++) | ||
710 | { | ||
711 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, | ||
712 | "Collect logging data master[%u] slave [%u]\n", c_m, c_s); | ||
713 | |||
714 | p = &bp->peer->partners[c_s]; | ||
715 | slt = &mlt->slaves_log[c_s]; | ||
716 | |||
717 | slt->slave = p->dest; | ||
718 | /* Bytes sent from master to this slave */ | ||
719 | slt->total_bytes_sent = p->bytes_sent; | ||
720 | /* Messages sent from master to this slave */ | ||
721 | slt->total_messages_sent = p->messages_sent; | ||
722 | /* Bytes master received from this slave */ | ||
723 | slt->total_bytes_received = p->bytes_received; | ||
724 | /* Messages master received from this slave */ | ||
725 | slt->total_messages_received = p->messages_received; | ||
726 | slt->total_app_rtt = p->total_app_rtt; | ||
727 | /* ats performance information */ | ||
728 | slt->ats_delay = p->props.delay; | ||
729 | slt->ats_distance = p->props.distance; | ||
730 | slt->ats_network_type = p->props.scope; | ||
731 | slt->ats_utilization_in = p->props.utilization_out; | ||
732 | slt->ats_utilization_out = p->props.utilization_out; | ||
733 | slt->bandwidth_in = p->bandwidth_in; | ||
734 | slt->bandwidth_out = p->bandwidth_out; | ||
735 | slt->pref_bandwidth = p->pref_bandwidth; | ||
736 | slt->pref_delay = p->pref_delay; | ||
737 | |||
738 | /* Total application level rtt */ | ||
739 | if (NULL == prev_log_mlt) | ||
740 | { | ||
741 | if (0 != slt->total_messages_sent) | ||
742 | app_rtt = slt->total_app_rtt / slt->total_messages_sent; | ||
743 | else | ||
744 | app_rtt = 0; | ||
745 | } | ||
746 | else | ||
747 | { | ||
748 | prev_log_slt = &prev_log_mlt->slaves_log[c_s]; | ||
749 | if ((slt->total_messages_sent - prev_log_slt->total_messages_sent) > 0) | ||
750 | app_rtt = (slt->total_app_rtt - prev_log_slt->total_app_rtt) / | ||
751 | (slt->total_messages_sent - prev_log_slt->total_messages_sent); | ||
752 | else | ||
753 | { | ||
754 | app_rtt = prev_log_slt->app_rtt; /* No messages were */ | ||
755 | } | ||
756 | } | ||
757 | slt->app_rtt = app_rtt; | ||
758 | |||
759 | /* Partner throughput */ | ||
760 | if (NULL != prev_log_mlt) | ||
761 | { | ||
762 | prev_log_slt = &prev_log_mlt->slaves_log[c_s]; | ||
763 | if (slt->total_bytes_sent > prev_log_slt->total_bytes_sent) | ||
764 | slt->throughput_sent = mult * (slt->total_bytes_sent - prev_log_slt->total_bytes_sent); | ||
765 | else | ||
766 | slt->throughput_sent = 0; | ||
767 | |||
768 | if (slt->total_bytes_received > prev_log_slt->total_bytes_received) | ||
769 | slt->throughput_recv = mult * | ||
770 | (slt->total_bytes_received - prev_log_slt->total_bytes_received); | ||
771 | else | ||
772 | slt->throughput_recv = 0; | ||
773 | } | ||
774 | else | ||
775 | { | ||
776 | slt->throughput_sent = mult * slt->total_bytes_sent; | ||
777 | slt->throughput_recv = mult * slt->total_bytes_received; | ||
778 | } | ||
779 | |||
780 | if (GNUNET_YES == l->verbose) | ||
781 | { | ||
782 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, | ||
783 | "Master [%u] -> Slave [%u]: delta: %llu us, bytes (sent/received): %u / %u; throughput send/recv: %u / %u\n", | ||
784 | c_m, c_s, | ||
785 | (unsigned long long)delta.rel_value_us, | ||
786 | mlt->total_bytes_sent, | ||
787 | mlt->total_bytes_received, | ||
788 | slt->throughput_sent, | ||
789 | slt->throughput_recv); | ||
790 | } | ||
791 | else | ||
792 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | ||
793 | "Master [%u]: slave [%u]\n", | ||
794 | bp->peer->no, p->dest->no); | ||
795 | } | ||
800 | } | 796 | } |
801 | } | ||
802 | } | 797 | } |
803 | 798 | ||
804 | 799 | ||
805 | static void | 800 | static void |
806 | collect_log_task (void *cls) | 801 | collect_log_task(void *cls) |
807 | { | 802 | { |
808 | struct LoggingHandle *l = cls; | 803 | struct LoggingHandle *l = cls; |
809 | 804 | ||
810 | l->log_task = NULL; | 805 | l->log_task = NULL; |
811 | GNUNET_ATS_TEST_logging_now (l); | 806 | GNUNET_ATS_TEST_logging_now(l); |
812 | l->log_task = GNUNET_SCHEDULER_add_delayed (l->frequency, | 807 | l->log_task = GNUNET_SCHEDULER_add_delayed(l->frequency, |
813 | &collect_log_task, | 808 | &collect_log_task, |
814 | l); | 809 | l); |
815 | } | 810 | } |
816 | 811 | ||
817 | 812 | ||
@@ -821,20 +816,20 @@ collect_log_task (void *cls) | |||
821 | * @param l the logging handle | 816 | * @param l the logging handle |
822 | */ | 817 | */ |
823 | void | 818 | void |
824 | GNUNET_ATS_TEST_logging_stop (struct LoggingHandle *l) | 819 | GNUNET_ATS_TEST_logging_stop(struct LoggingHandle *l) |
825 | { | 820 | { |
826 | if (GNUNET_YES!= l->running) | 821 | if (GNUNET_YES != l->running) |
827 | return; | 822 | return; |
828 | 823 | ||
829 | if (NULL != l->log_task) | 824 | if (NULL != l->log_task) |
830 | { | 825 | { |
831 | GNUNET_SCHEDULER_cancel (l->log_task); | 826 | GNUNET_SCHEDULER_cancel(l->log_task); |
832 | l->log_task = NULL; | 827 | l->log_task = NULL; |
833 | } | 828 | } |
834 | l->running = GNUNET_NO; | 829 | l->running = GNUNET_NO; |
835 | 830 | ||
836 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, | 831 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, |
837 | _("Stop logging\n")); | 832 | _("Stop logging\n")); |
838 | } | 833 | } |
839 | 834 | ||
840 | /** | 835 | /** |
@@ -843,26 +838,26 @@ GNUNET_ATS_TEST_logging_stop (struct LoggingHandle *l) | |||
843 | * @param l the logging handle | 838 | * @param l the logging handle |
844 | */ | 839 | */ |
845 | void | 840 | void |
846 | GNUNET_ATS_TEST_logging_clean_up (struct LoggingHandle *l) | 841 | GNUNET_ATS_TEST_logging_clean_up(struct LoggingHandle *l) |
847 | { | 842 | { |
848 | int c_m; | 843 | int c_m; |
849 | struct PeerLoggingTimestep *cur; | 844 | struct PeerLoggingTimestep *cur; |
850 | 845 | ||
851 | if (GNUNET_YES == l->running) | 846 | if (GNUNET_YES == l->running) |
852 | GNUNET_ATS_TEST_logging_stop (l); | 847 | GNUNET_ATS_TEST_logging_stop(l); |
853 | 848 | ||
854 | for (c_m = 0; c_m < l->num_masters; c_m++) | 849 | for (c_m = 0; c_m < l->num_masters; c_m++) |
855 | { | ||
856 | while (NULL != (cur = l->lp[c_m].head)) | ||
857 | { | 850 | { |
858 | GNUNET_CONTAINER_DLL_remove (l->lp[c_m].head, l->lp[c_m].tail, cur); | 851 | while (NULL != (cur = l->lp[c_m].head)) |
859 | GNUNET_free (cur->slaves_log); | 852 | { |
860 | GNUNET_free (cur); | 853 | GNUNET_CONTAINER_DLL_remove(l->lp[c_m].head, l->lp[c_m].tail, cur); |
854 | GNUNET_free(cur->slaves_log); | ||
855 | GNUNET_free(cur); | ||
856 | } | ||
861 | } | 857 | } |
862 | } | ||
863 | 858 | ||
864 | GNUNET_free (l->lp); | 859 | GNUNET_free(l->lp); |
865 | GNUNET_free (l); | 860 | GNUNET_free(l); |
866 | } | 861 | } |
867 | 862 | ||
868 | 863 | ||
@@ -889,24 +884,24 @@ GNUNET_ATS_TEST_logging_start(struct GNUNET_TIME_Relative log_frequency, | |||
889 | int c_m; | 884 | int c_m; |
890 | 885 | ||
891 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, | 886 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, |
892 | _("Start logging `%s'\n"), testname); | 887 | _("Start logging `%s'\n"), testname); |
893 | 888 | ||
894 | l = GNUNET_new (struct LoggingHandle); | 889 | l = GNUNET_new(struct LoggingHandle); |
895 | l->num_masters = num_masters; | 890 | l->num_masters = num_masters; |
896 | l->num_slaves = num_slaves; | 891 | l->num_slaves = num_slaves; |
897 | l->name = testname; | 892 | l->name = testname; |
898 | l->frequency = log_frequency; | 893 | l->frequency = log_frequency; |
899 | l->verbose = verbose; | 894 | l->verbose = verbose; |
900 | l->lp = GNUNET_malloc (num_masters * sizeof (struct LoggingPeer)); | 895 | l->lp = GNUNET_malloc(num_masters * sizeof(struct LoggingPeer)); |
901 | 896 | ||
902 | for (c_m = 0; c_m < num_masters; c_m ++) | 897 | for (c_m = 0; c_m < num_masters; c_m++) |
903 | { | 898 | { |
904 | l->lp[c_m].peer = &masters[c_m]; | 899 | l->lp[c_m].peer = &masters[c_m]; |
905 | l->lp[c_m].start = GNUNET_TIME_absolute_get(); | 900 | l->lp[c_m].start = GNUNET_TIME_absolute_get(); |
906 | } | 901 | } |
907 | 902 | ||
908 | /* Schedule logging task */ | 903 | /* Schedule logging task */ |
909 | l->log_task = GNUNET_SCHEDULER_add_now (&collect_log_task, l); | 904 | l->log_task = GNUNET_SCHEDULER_add_now(&collect_log_task, l); |
910 | l->running = GNUNET_YES; | 905 | l->running = GNUNET_YES; |
911 | 906 | ||
912 | return l; | 907 | return l; |
diff --git a/src/ats-tests/ats-testing-preferences.c b/src/ats-tests/ats-testing-preferences.c index ba2f133b9..a14e66736 100644 --- a/src/ats-tests/ats-testing-preferences.c +++ b/src/ats-tests/ats-testing-preferences.c | |||
@@ -1,19 +1,19 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2010-2013 GNUnet e.V. | 3 | Copyright (C) 2010-2013 GNUnet e.V. |
4 | 4 | ||
5 | GNUnet is free software: you can redistribute it and/or modify it | 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 | 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, | 7 | by the Free Software Foundation, either version 3 of the License, |
8 | or (at your option) any later version. | 8 | or (at your option) any later version. |
9 | 9 | ||
10 | GNUnet is distributed in the hope that it will be useful, but | 10 | GNUnet is distributed in the hope that it will be useful, but |
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Affero General Public License for more details. | 13 | Affero General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Affero General Public License | 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/>. | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | 17 | ||
18 | SPDX-License-Identifier: AGPL3.0-or-later | 18 | SPDX-License-Identifier: AGPL3.0-or-later |
19 | */ | 19 | */ |
@@ -33,76 +33,82 @@ static struct PreferenceGenerator *pg_tail; | |||
33 | extern struct GNUNET_ATS_TEST_Topology *top; | 33 | extern struct GNUNET_ATS_TEST_Topology *top; |
34 | 34 | ||
35 | static double | 35 | static double |
36 | get_preference (struct PreferenceGenerator *pg) | 36 | get_preference(struct PreferenceGenerator *pg) |
37 | { | 37 | { |
38 | struct GNUNET_TIME_Relative time_delta; | 38 | struct GNUNET_TIME_Relative time_delta; |
39 | double delta_value; | 39 | double delta_value; |
40 | double pref_value; | 40 | double pref_value; |
41 | 41 | ||
42 | /* Calculate the current preference value */ | 42 | /* Calculate the current preference value */ |
43 | switch (pg->type) { | 43 | switch (pg->type) |
44 | { | ||
44 | case GNUNET_ATS_TEST_TG_CONSTANT: | 45 | case GNUNET_ATS_TEST_TG_CONSTANT: |
45 | pref_value = pg->base_value; | 46 | pref_value = pg->base_value; |
46 | break; | 47 | break; |
48 | |||
47 | case GNUNET_ATS_TEST_TG_LINEAR: | 49 | case GNUNET_ATS_TEST_TG_LINEAR: |
48 | time_delta = GNUNET_TIME_absolute_get_duration(pg->time_start); | 50 | time_delta = GNUNET_TIME_absolute_get_duration(pg->time_start); |
49 | /* Calculate point of time in the current period */ | 51 | /* Calculate point of time in the current period */ |
50 | time_delta.rel_value_us = time_delta.rel_value_us % | 52 | time_delta.rel_value_us = time_delta.rel_value_us % |
51 | pg->duration_period.rel_value_us; | 53 | pg->duration_period.rel_value_us; |
52 | delta_value = ((double) time_delta.rel_value_us / | 54 | delta_value = ((double)time_delta.rel_value_us / |
53 | pg->duration_period.rel_value_us) * (pg->max_value - pg->base_value); | 55 | pg->duration_period.rel_value_us) * (pg->max_value - pg->base_value); |
54 | if ((pg->max_value < pg->base_value) && | 56 | if ((pg->max_value < pg->base_value) && |
55 | ((pg->max_value - pg->base_value) > pg->base_value)) | 57 | ((pg->max_value - pg->base_value) > pg->base_value)) |
56 | { | 58 | { |
57 | /* This will cause an underflow */ | 59 | /* This will cause an underflow */ |
58 | GNUNET_break (0); | 60 | GNUNET_break(0); |
59 | } | 61 | } |
60 | pref_value = pg->base_value + delta_value; | 62 | pref_value = pg->base_value + delta_value; |
61 | break; | 63 | break; |
64 | |||
62 | case GNUNET_ATS_TEST_TG_RANDOM: | 65 | case GNUNET_ATS_TEST_TG_RANDOM: |
63 | delta_value = (double) GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, | 66 | delta_value = (double)GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_WEAK, |
64 | 10000 * (pg->max_value - pg->base_value)) / 10000; | 67 | 10000 * (pg->max_value - pg->base_value)) / 10000; |
65 | pref_value = pg->base_value + delta_value; | 68 | pref_value = pg->base_value + delta_value; |
66 | break; | 69 | break; |
70 | |||
67 | case GNUNET_ATS_TEST_TG_SINUS: | 71 | case GNUNET_ATS_TEST_TG_SINUS: |
68 | time_delta = GNUNET_TIME_absolute_get_duration(pg->time_start); | 72 | time_delta = GNUNET_TIME_absolute_get_duration(pg->time_start); |
69 | /* Calculate point of time in the current period */ | 73 | /* Calculate point of time in the current period */ |
70 | time_delta.rel_value_us = time_delta.rel_value_us % | 74 | time_delta.rel_value_us = time_delta.rel_value_us % |
71 | pg->duration_period.rel_value_us; | 75 | pg->duration_period.rel_value_us; |
72 | if ((pg->max_value - pg->base_value) > pg->base_value) | 76 | if ((pg->max_value - pg->base_value) > pg->base_value) |
73 | { | 77 | { |
74 | /* This will cause an underflow for second half of sinus period, | 78 | /* This will cause an underflow for second half of sinus period, |
75 | * will be detected in general when experiments are loaded */ | 79 | * will be detected in general when experiments are loaded */ |
76 | GNUNET_break (0); | 80 | GNUNET_break(0); |
77 | } | 81 | } |
78 | delta_value = (pg->max_value - pg->base_value) * | 82 | delta_value = (pg->max_value - pg->base_value) * |
79 | sin ( (2 * M_PI) / ((double) pg->duration_period.rel_value_us) * | 83 | sin((2 * M_PI) / ((double)pg->duration_period.rel_value_us) * |
80 | time_delta.rel_value_us); | 84 | time_delta.rel_value_us); |
81 | pref_value = pg->base_value + delta_value; | 85 | pref_value = pg->base_value + delta_value; |
82 | break; | 86 | break; |
87 | |||
83 | default: | 88 | default: |
84 | pref_value = 0.0; | 89 | pref_value = 0.0; |
85 | break; | 90 | break; |
86 | } | 91 | } |
87 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Current preference value is %f\n", | 92 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Current preference value is %f\n", |
88 | pref_value); | 93 | pref_value); |
89 | return pref_value; | 94 | return pref_value; |
90 | } | 95 | } |
91 | 96 | ||
92 | 97 | ||
93 | static void | 98 | static void |
94 | set_pref_task (void *cls) | 99 | set_pref_task(void *cls) |
95 | { | 100 | { |
96 | struct BenchmarkPartner *p = cls; | 101 | struct BenchmarkPartner *p = cls; |
97 | double pref_value; | 102 | double pref_value; |
103 | |||
98 | p->pg->set_task = NULL; | 104 | p->pg->set_task = NULL; |
99 | 105 | ||
100 | pref_value = get_preference (p->pg); | 106 | pref_value = get_preference(p->pg); |
101 | 107 | ||
102 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, | 108 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, |
103 | "Setting preference for master [%u] and slave [%u] for %s to %f\n", | 109 | "Setting preference for master [%u] and slave [%u] for %s to %f\n", |
104 | p->me->no, p->dest->no, | 110 | p->me->no, p->dest->no, |
105 | GNUNET_ATS_print_preference_type (p->pg->kind), pref_value); | 111 | GNUNET_ATS_print_preference_type(p->pg->kind), pref_value); |
106 | 112 | ||
107 | GNUNET_ATS_performance_change_preference(p->me->ats_perf_handle, | 113 | GNUNET_ATS_performance_change_preference(p->me->ats_perf_handle, |
108 | &p->dest->id, | 114 | &p->dest->id, |
@@ -110,20 +116,22 @@ set_pref_task (void *cls) | |||
110 | pref_value, | 116 | pref_value, |
111 | GNUNET_ATS_PREFERENCE_END); | 117 | GNUNET_ATS_PREFERENCE_END); |
112 | 118 | ||
113 | switch (p->pg->kind) { | 119 | switch (p->pg->kind) |
120 | { | ||
114 | case GNUNET_ATS_PREFERENCE_BANDWIDTH: | 121 | case GNUNET_ATS_PREFERENCE_BANDWIDTH: |
115 | p->pref_bandwidth = pref_value; | 122 | p->pref_bandwidth = pref_value; |
116 | break; | 123 | break; |
124 | |||
117 | case GNUNET_ATS_PREFERENCE_LATENCY: | 125 | case GNUNET_ATS_PREFERENCE_LATENCY: |
118 | p->pref_delay = pref_value; | 126 | p->pref_delay = pref_value; |
119 | break; | 127 | break; |
128 | |||
120 | default: | 129 | default: |
121 | break; | 130 | break; |
122 | } | 131 | } |
123 | |||
124 | p->pg->set_task = GNUNET_SCHEDULER_add_delayed (p->pg->frequency, | ||
125 | set_pref_task, p); | ||
126 | 132 | ||
133 | p->pg->set_task = GNUNET_SCHEDULER_add_delayed(p->pg->frequency, | ||
134 | set_pref_task, p); | ||
127 | } | 135 | } |
128 | 136 | ||
129 | 137 | ||
@@ -142,25 +150,25 @@ set_pref_task (void *cls) | |||
142 | * @return the preference generator | 150 | * @return the preference generator |
143 | */ | 151 | */ |
144 | struct PreferenceGenerator * | 152 | struct PreferenceGenerator * |
145 | GNUNET_ATS_TEST_generate_preferences_start (struct BenchmarkPeer *src, | 153 | GNUNET_ATS_TEST_generate_preferences_start(struct BenchmarkPeer *src, |
146 | struct BenchmarkPartner *dest, | 154 | struct BenchmarkPartner *dest, |
147 | enum GeneratorType type, | 155 | enum GeneratorType type, |
148 | unsigned int base_value, | 156 | unsigned int base_value, |
149 | unsigned int value_rate, | 157 | unsigned int value_rate, |
150 | struct GNUNET_TIME_Relative period, | 158 | struct GNUNET_TIME_Relative period, |
151 | struct GNUNET_TIME_Relative frequency, | 159 | struct GNUNET_TIME_Relative frequency, |
152 | enum GNUNET_ATS_PreferenceKind kind) | 160 | enum GNUNET_ATS_PreferenceKind kind) |
153 | { | 161 | { |
154 | struct PreferenceGenerator *pg; | 162 | struct PreferenceGenerator *pg; |
155 | 163 | ||
156 | if (NULL != dest->pg) | 164 | if (NULL != dest->pg) |
157 | { | 165 | { |
158 | GNUNET_break (0); | 166 | GNUNET_break(0); |
159 | return NULL; | 167 | return NULL; |
160 | } | 168 | } |
161 | 169 | ||
162 | pg = GNUNET_new (struct PreferenceGenerator); | 170 | pg = GNUNET_new(struct PreferenceGenerator); |
163 | GNUNET_CONTAINER_DLL_insert (pg_head, pg_tail, pg); | 171 | GNUNET_CONTAINER_DLL_insert(pg_head, pg_tail, pg); |
164 | pg->type = type; | 172 | pg->type = type; |
165 | pg->src = src; | 173 | pg->src = src; |
166 | pg->dest = dest; | 174 | pg->dest = dest; |
@@ -171,58 +179,63 @@ GNUNET_ATS_TEST_generate_preferences_start (struct BenchmarkPeer *src, | |||
171 | pg->frequency = frequency; | 179 | pg->frequency = frequency; |
172 | pg->time_start = GNUNET_TIME_absolute_get(); | 180 | pg->time_start = GNUNET_TIME_absolute_get(); |
173 | 181 | ||
174 | switch (type) { | 182 | switch (type) |
183 | { | ||
175 | case GNUNET_ATS_TEST_TG_CONSTANT: | 184 | case GNUNET_ATS_TEST_TG_CONSTANT: |
176 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 185 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, |
177 | "Setting up constant preference generator master[%u] `%s' and slave [%u] `%s' max %u Bips\n", | 186 | "Setting up constant preference generator master[%u] `%s' and slave [%u] `%s' max %u Bips\n", |
178 | dest->me->no, GNUNET_i2s (&dest->me->id), | 187 | dest->me->no, GNUNET_i2s(&dest->me->id), |
179 | dest->dest->no, GNUNET_i2s (&dest->dest->id), | 188 | dest->dest->no, GNUNET_i2s(&dest->dest->id), |
180 | base_value); | 189 | base_value); |
181 | break; | 190 | break; |
191 | |||
182 | case GNUNET_ATS_TEST_TG_LINEAR: | 192 | case GNUNET_ATS_TEST_TG_LINEAR: |
183 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 193 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, |
184 | "Setting up linear preference generator master[%u] `%s' and slave [%u] `%s' min %u Bips max %u Bips\n", | 194 | "Setting up linear preference generator master[%u] `%s' and slave [%u] `%s' min %u Bips max %u Bips\n", |
185 | dest->me->no, GNUNET_i2s (&dest->me->id), | 195 | dest->me->no, GNUNET_i2s(&dest->me->id), |
186 | dest->dest->no, GNUNET_i2s (&dest->dest->id), | 196 | dest->dest->no, GNUNET_i2s(&dest->dest->id), |
187 | base_value, value_rate); | 197 | base_value, value_rate); |
188 | break; | 198 | break; |
199 | |||
189 | case GNUNET_ATS_TEST_TG_SINUS: | 200 | case GNUNET_ATS_TEST_TG_SINUS: |
190 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 201 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, |
191 | "Setting up sinus preference generator master[%u] `%s' and slave [%u] `%s' baserate %u Bips, amplitude %u Bps\n", | 202 | "Setting up sinus preference generator master[%u] `%s' and slave [%u] `%s' baserate %u Bips, amplitude %u Bps\n", |
192 | dest->me->no, GNUNET_i2s (&dest->me->id), | 203 | dest->me->no, GNUNET_i2s(&dest->me->id), |
193 | dest->dest->no, GNUNET_i2s (&dest->dest->id), | 204 | dest->dest->no, GNUNET_i2s(&dest->dest->id), |
194 | base_value, value_rate); | 205 | base_value, value_rate); |
195 | break; | 206 | break; |
207 | |||
196 | case GNUNET_ATS_TEST_TG_RANDOM: | 208 | case GNUNET_ATS_TEST_TG_RANDOM: |
197 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 209 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, |
198 | "Setting up random preference generator master[%u] `%s' and slave [%u] `%s' min %u Bips max %u Bps\n", | 210 | "Setting up random preference generator master[%u] `%s' and slave [%u] `%s' min %u Bips max %u Bps\n", |
199 | dest->me->no, GNUNET_i2s (&dest->me->id), | 211 | dest->me->no, GNUNET_i2s(&dest->me->id), |
200 | dest->dest->no, GNUNET_i2s (&dest->dest->id), | 212 | dest->dest->no, GNUNET_i2s(&dest->dest->id), |
201 | base_value, value_rate); | 213 | base_value, value_rate); |
202 | break; | 214 | break; |
215 | |||
203 | default: | 216 | default: |
204 | break; | 217 | break; |
205 | } | 218 | } |
206 | 219 | ||
207 | dest->pg = pg; | 220 | dest->pg = pg; |
208 | pg->set_task = GNUNET_SCHEDULER_add_now (&set_pref_task, dest); | 221 | pg->set_task = GNUNET_SCHEDULER_add_now(&set_pref_task, dest); |
209 | return pg; | 222 | return pg; |
210 | } | 223 | } |
211 | 224 | ||
212 | 225 | ||
213 | void | 226 | void |
214 | GNUNET_ATS_TEST_generate_preferences_stop (struct PreferenceGenerator *pg) | 227 | GNUNET_ATS_TEST_generate_preferences_stop(struct PreferenceGenerator *pg) |
215 | { | 228 | { |
216 | GNUNET_CONTAINER_DLL_remove (pg_head, pg_tail, pg); | 229 | GNUNET_CONTAINER_DLL_remove(pg_head, pg_tail, pg); |
217 | pg->dest->pg = NULL; | 230 | pg->dest->pg = NULL; |
218 | 231 | ||
219 | if (NULL != pg->set_task) | 232 | if (NULL != pg->set_task) |
220 | { | 233 | { |
221 | GNUNET_SCHEDULER_cancel (pg->set_task); | 234 | GNUNET_SCHEDULER_cancel(pg->set_task); |
222 | pg->set_task = NULL; | 235 | pg->set_task = NULL; |
223 | } | 236 | } |
224 | 237 | ||
225 | GNUNET_free (pg); | 238 | GNUNET_free(pg); |
226 | } | 239 | } |
227 | 240 | ||
228 | 241 | ||
@@ -230,16 +243,17 @@ GNUNET_ATS_TEST_generate_preferences_stop (struct PreferenceGenerator *pg) | |||
230 | * Stop all preferences generators | 243 | * Stop all preferences generators |
231 | */ | 244 | */ |
232 | void | 245 | void |
233 | GNUNET_ATS_TEST_generate_preferences_stop_all () | 246 | GNUNET_ATS_TEST_generate_preferences_stop_all() |
234 | { | 247 | { |
235 | struct PreferenceGenerator *cur; | 248 | struct PreferenceGenerator *cur; |
236 | struct PreferenceGenerator *next; | 249 | struct PreferenceGenerator *next; |
250 | |||
237 | next = pg_head; | 251 | next = pg_head; |
238 | for (cur = next; NULL != cur; cur = next) | 252 | for (cur = next; NULL != cur; cur = next) |
239 | { | 253 | { |
240 | next = cur->next; | 254 | next = cur->next; |
241 | GNUNET_ATS_TEST_generate_preferences_stop(cur); | 255 | GNUNET_ATS_TEST_generate_preferences_stop(cur); |
242 | } | 256 | } |
243 | } | 257 | } |
244 | 258 | ||
245 | /* end of file ats-testing-preferences.c */ | 259 | /* 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 index 3756596c9..01462980c 100644 --- a/src/ats-tests/ats-testing-traffic.c +++ b/src/ats-tests/ats-testing-traffic.c | |||
@@ -1,19 +1,19 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2010-2013, 2016 GNUnet e.V. | 3 | Copyright (C) 2010-2013, 2016 GNUnet e.V. |
4 | 4 | ||
5 | GNUnet is free software: you can redistribute it and/or modify it | 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 | 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, | 7 | by the Free Software Foundation, either version 3 of the License, |
8 | or (at your option) any later version. | 8 | or (at your option) any later version. |
9 | 9 | ||
10 | GNUnet is distributed in the hope that it will be useful, but | 10 | GNUnet is distributed in the hope that it will be useful, but |
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Affero General Public License for more details. | 13 | Affero General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Affero General Public License | 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/>. | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | 17 | ||
18 | SPDX-License-Identifier: AGPL3.0-or-later | 18 | SPDX-License-Identifier: AGPL3.0-or-later |
19 | */ | 19 | */ |
@@ -33,7 +33,7 @@ static struct TrafficGenerator *tg_tail; | |||
33 | extern struct GNUNET_ATS_TEST_Topology *top; | 33 | extern struct GNUNET_ATS_TEST_Topology *top; |
34 | 34 | ||
35 | static struct GNUNET_TIME_Relative | 35 | static struct GNUNET_TIME_Relative |
36 | get_delay (struct TrafficGenerator *tg) | 36 | get_delay(struct TrafficGenerator *tg) |
37 | { | 37 | { |
38 | struct GNUNET_TIME_Relative delay; | 38 | struct GNUNET_TIME_Relative delay; |
39 | struct GNUNET_TIME_Relative time_delta; | 39 | struct GNUNET_TIME_Relative time_delta; |
@@ -43,65 +43,70 @@ get_delay (struct TrafficGenerator *tg) | |||
43 | delay.rel_value_us = 0; | 43 | delay.rel_value_us = 0; |
44 | 44 | ||
45 | /* Calculate the current transmission rate based on the type of traffic */ | 45 | /* Calculate the current transmission rate based on the type of traffic */ |
46 | switch (tg->type) { | 46 | switch (tg->type) |
47 | { | ||
47 | case GNUNET_ATS_TEST_TG_CONSTANT: | 48 | case GNUNET_ATS_TEST_TG_CONSTANT: |
48 | if (UINT32_MAX == tg->base_rate) | 49 | if (UINT32_MAX == tg->base_rate) |
49 | return GNUNET_TIME_UNIT_ZERO; | 50 | return GNUNET_TIME_UNIT_ZERO; |
50 | cur_rate = tg->base_rate; | 51 | cur_rate = tg->base_rate; |
51 | break; | 52 | break; |
53 | |||
52 | case GNUNET_ATS_TEST_TG_LINEAR: | 54 | case GNUNET_ATS_TEST_TG_LINEAR: |
53 | time_delta = GNUNET_TIME_absolute_get_duration(tg->time_start); | 55 | time_delta = GNUNET_TIME_absolute_get_duration(tg->time_start); |
54 | /* Calculate point of time in the current period */ | 56 | /* Calculate point of time in the current period */ |
55 | time_delta.rel_value_us = time_delta.rel_value_us % tg->duration_period.rel_value_us; | 57 | time_delta.rel_value_us = time_delta.rel_value_us % tg->duration_period.rel_value_us; |
56 | delta_rate = ((double) time_delta.rel_value_us / tg->duration_period.rel_value_us) * | 58 | delta_rate = ((double)time_delta.rel_value_us / tg->duration_period.rel_value_us) * |
57 | (tg->max_rate - tg->base_rate); | 59 | (tg->max_rate - tg->base_rate); |
58 | if ((tg->max_rate < tg->base_rate) && ((tg->max_rate - tg->base_rate) > tg->base_rate)) | 60 | if ((tg->max_rate < tg->base_rate) && ((tg->max_rate - tg->base_rate) > tg->base_rate)) |
59 | { | 61 | { |
60 | /* This will cause an underflow */ | 62 | /* This will cause an underflow */ |
61 | GNUNET_break (0); | 63 | GNUNET_break(0); |
62 | } | 64 | } |
63 | cur_rate = tg->base_rate + delta_rate; | 65 | cur_rate = tg->base_rate + delta_rate; |
64 | break; | 66 | break; |
67 | |||
65 | case GNUNET_ATS_TEST_TG_RANDOM: | 68 | case GNUNET_ATS_TEST_TG_RANDOM: |
66 | cur_rate = tg->base_rate + GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, | 69 | cur_rate = tg->base_rate + GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_WEAK, |
67 | tg->max_rate - tg->base_rate); | 70 | tg->max_rate - tg->base_rate); |
68 | break; | 71 | break; |
72 | |||
69 | case GNUNET_ATS_TEST_TG_SINUS: | 73 | case GNUNET_ATS_TEST_TG_SINUS: |
70 | time_delta = GNUNET_TIME_absolute_get_duration(tg->time_start); | 74 | time_delta = GNUNET_TIME_absolute_get_duration(tg->time_start); |
71 | /* Calculate point of time in the current period */ | 75 | /* Calculate point of time in the current period */ |
72 | time_delta.rel_value_us = time_delta.rel_value_us % tg->duration_period.rel_value_us; | 76 | time_delta.rel_value_us = time_delta.rel_value_us % tg->duration_period.rel_value_us; |
73 | if ((tg->max_rate - tg->base_rate) > tg->base_rate) | 77 | if ((tg->max_rate - tg->base_rate) > tg->base_rate) |
74 | { | 78 | { |
75 | /* This will cause an underflow for second half of sinus period, | 79 | /* This will cause an underflow for second half of sinus period, |
76 | * will be detected in general when experiments are loaded */ | 80 | * will be detected in general when experiments are loaded */ |
77 | GNUNET_break (0); | 81 | GNUNET_break(0); |
78 | } | 82 | } |
79 | delta_rate = (tg->max_rate - tg->base_rate) * | 83 | delta_rate = (tg->max_rate - tg->base_rate) * |
80 | sin ( (2 * M_PI) / ((double) tg->duration_period.rel_value_us) * time_delta.rel_value_us); | 84 | sin((2 * M_PI) / ((double)tg->duration_period.rel_value_us) * time_delta.rel_value_us); |
81 | cur_rate = tg->base_rate + delta_rate; | 85 | cur_rate = tg->base_rate + delta_rate; |
82 | break; | 86 | break; |
87 | |||
83 | default: | 88 | default: |
84 | return delay; | 89 | return delay; |
85 | break; | 90 | break; |
86 | } | 91 | } |
87 | 92 | ||
88 | if (cur_rate < 0) | 93 | if (cur_rate < 0) |
89 | { | 94 | { |
90 | cur_rate = 1; | 95 | cur_rate = 1; |
91 | } | 96 | } |
92 | /* Calculate the delay for the next message based on the current delay */ | 97 | /* Calculate the delay for the next message based on the current delay */ |
93 | delay.rel_value_us = GNUNET_TIME_UNIT_SECONDS.rel_value_us * TEST_MESSAGE_SIZE / cur_rate; | 98 | delay.rel_value_us = GNUNET_TIME_UNIT_SECONDS.rel_value_us * TEST_MESSAGE_SIZE / cur_rate; |
94 | 99 | ||
95 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 100 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
96 | "Current rate is %lld, calculated delay is %llu\n", | 101 | "Current rate is %lld, calculated delay is %llu\n", |
97 | cur_rate, | 102 | cur_rate, |
98 | (unsigned long long) delay.rel_value_us); | 103 | (unsigned long long)delay.rel_value_us); |
99 | return delay; | 104 | return delay; |
100 | } | 105 | } |
101 | 106 | ||
102 | 107 | ||
103 | static void | 108 | static void |
104 | update_ping_data (void *cls) | 109 | update_ping_data(void *cls) |
105 | { | 110 | { |
106 | struct BenchmarkPartner *p = cls; | 111 | struct BenchmarkPartner *p = cls; |
107 | struct GNUNET_TIME_Relative delay; | 112 | struct GNUNET_TIME_Relative delay; |
@@ -112,23 +117,23 @@ update_ping_data (void *cls) | |||
112 | p->me->total_bytes_sent += TEST_MESSAGE_SIZE; | 117 | p->me->total_bytes_sent += TEST_MESSAGE_SIZE; |
113 | 118 | ||
114 | if (NULL == p->tg) | 119 | if (NULL == p->tg) |
115 | { | 120 | { |
116 | GNUNET_break (0); | 121 | GNUNET_break(0); |
117 | return; | 122 | return; |
118 | } | 123 | } |
119 | delay = get_delay (p->tg); | 124 | delay = get_delay(p->tg); |
120 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 125 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
121 | "Delay for next transmission %s\n", | 126 | "Delay for next transmission %s\n", |
122 | GNUNET_STRINGS_relative_time_to_string (delay, | 127 | GNUNET_STRINGS_relative_time_to_string(delay, |
123 | GNUNET_YES)); | 128 | GNUNET_YES)); |
124 | p->tg->next_ping_transmission | 129 | p->tg->next_ping_transmission |
125 | = GNUNET_TIME_absolute_add (GNUNET_TIME_absolute_get(), | 130 | = GNUNET_TIME_absolute_add(GNUNET_TIME_absolute_get(), |
126 | delay); | 131 | delay); |
127 | } | 132 | } |
128 | 133 | ||
129 | 134 | ||
130 | static void | 135 | static void |
131 | comm_schedule_send (void *cls) | 136 | comm_schedule_send(void *cls) |
132 | { | 137 | { |
133 | struct BenchmarkPartner *p = cls; | 138 | struct BenchmarkPartner *p = cls; |
134 | struct TestMessage *msg; | 139 | struct TestMessage *msg; |
@@ -136,25 +141,25 @@ comm_schedule_send (void *cls) | |||
136 | 141 | ||
137 | p->tg->send_task = NULL; | 142 | p->tg->send_task = NULL; |
138 | p->last_message_sent = GNUNET_TIME_absolute_get(); | 143 | p->last_message_sent = GNUNET_TIME_absolute_get(); |
139 | env = GNUNET_MQ_msg (msg, | 144 | env = GNUNET_MQ_msg(msg, |
140 | TEST_MESSAGE_TYPE_PING); | 145 | TEST_MESSAGE_TYPE_PING); |
141 | memset (msg->padding, | 146 | memset(msg->padding, |
142 | 'a', | 147 | 'a', |
143 | sizeof (msg->padding)); | 148 | sizeof(msg->padding)); |
144 | GNUNET_MQ_notify_sent (env, | 149 | GNUNET_MQ_notify_sent(env, |
145 | &update_ping_data, | 150 | &update_ping_data, |
146 | p); | 151 | p); |
147 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 152 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
148 | "Master [%u]: Sending PING to [%u]\n", | 153 | "Master [%u]: Sending PING to [%u]\n", |
149 | p->me->no, | 154 | p->me->no, |
150 | p->dest->no); | 155 | p->dest->no); |
151 | GNUNET_MQ_send (p->mq, | 156 | GNUNET_MQ_send(p->mq, |
152 | env); | 157 | env); |
153 | } | 158 | } |
154 | 159 | ||
155 | 160 | ||
156 | static void | 161 | static void |
157 | update_pong_data (void *cls) | 162 | update_pong_data(void *cls) |
158 | { | 163 | { |
159 | struct BenchmarkPartner *p = cls; | 164 | struct BenchmarkPartner *p = cls; |
160 | 165 | ||
@@ -166,49 +171,50 @@ update_pong_data (void *cls) | |||
166 | 171 | ||
167 | 172 | ||
168 | void | 173 | void |
169 | GNUNET_ATS_TEST_traffic_handle_ping (struct BenchmarkPartner *p) | 174 | GNUNET_ATS_TEST_traffic_handle_ping(struct BenchmarkPartner *p) |
170 | { | 175 | { |
171 | struct TestMessage *msg; | 176 | struct TestMessage *msg; |
172 | struct GNUNET_MQ_Envelope *env; | 177 | struct GNUNET_MQ_Envelope *env; |
173 | 178 | ||
174 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 179 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
175 | "Slave [%u]: Received PING from [%u], sending PONG\n", | 180 | "Slave [%u]: Received PING from [%u], sending PONG\n", |
176 | p->me->no, | 181 | p->me->no, |
177 | p->dest->no); | 182 | p->dest->no); |
178 | p->messages_received++; | 183 | p->messages_received++; |
179 | p->bytes_received += TEST_MESSAGE_SIZE; | 184 | p->bytes_received += TEST_MESSAGE_SIZE; |
180 | p->me->total_messages_received++; | 185 | p->me->total_messages_received++; |
181 | p->me->total_bytes_received += TEST_MESSAGE_SIZE; | 186 | p->me->total_bytes_received += TEST_MESSAGE_SIZE; |
182 | 187 | ||
183 | 188 | ||
184 | env = GNUNET_MQ_msg (msg, | 189 | env = GNUNET_MQ_msg(msg, |
185 | TEST_MESSAGE_TYPE_PING); | 190 | TEST_MESSAGE_TYPE_PING); |
186 | memset (msg->padding, | 191 | memset(msg->padding, |
187 | 'a', | 192 | 'a', |
188 | sizeof (msg->padding)); | 193 | sizeof(msg->padding)); |
189 | GNUNET_MQ_notify_sent (env, | 194 | GNUNET_MQ_notify_sent(env, |
190 | &update_pong_data, | 195 | &update_pong_data, |
191 | p); | 196 | p); |
192 | GNUNET_MQ_send (p->mq, | 197 | GNUNET_MQ_send(p->mq, |
193 | env); | 198 | env); |
194 | } | 199 | } |
195 | 200 | ||
196 | 201 | ||
197 | void | 202 | void |
198 | GNUNET_ATS_TEST_traffic_handle_pong (struct BenchmarkPartner *p) | 203 | GNUNET_ATS_TEST_traffic_handle_pong(struct BenchmarkPartner *p) |
199 | { | 204 | { |
200 | struct GNUNET_TIME_Relative left; | 205 | struct GNUNET_TIME_Relative left; |
201 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 206 | |
202 | "Master [%u]: Received PONG from [%u], next message\n", | 207 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
203 | p->me->no, | 208 | "Master [%u]: Received PONG from [%u], next message\n", |
204 | p->dest->no); | 209 | p->me->no, |
210 | p->dest->no); | ||
205 | 211 | ||
206 | p->messages_received++; | 212 | p->messages_received++; |
207 | p->bytes_received += TEST_MESSAGE_SIZE; | 213 | p->bytes_received += TEST_MESSAGE_SIZE; |
208 | p->me->total_messages_received++; | 214 | p->me->total_messages_received++; |
209 | p->me->total_bytes_received += TEST_MESSAGE_SIZE; | 215 | p->me->total_bytes_received += TEST_MESSAGE_SIZE; |
210 | p->total_app_rtt += GNUNET_TIME_absolute_get_difference(p->last_message_sent, | 216 | p->total_app_rtt += GNUNET_TIME_absolute_get_difference(p->last_message_sent, |
211 | GNUNET_TIME_absolute_get()).rel_value_us; | 217 | GNUNET_TIME_absolute_get()).rel_value_us; |
212 | 218 | ||
213 | /* Schedule next send event */ | 219 | /* Schedule next send event */ |
214 | if (NULL == p->tg) | 220 | if (NULL == p->tg) |
@@ -216,23 +222,23 @@ GNUNET_ATS_TEST_traffic_handle_pong (struct BenchmarkPartner *p) | |||
216 | 222 | ||
217 | left = GNUNET_TIME_absolute_get_remaining(p->tg->next_ping_transmission); | 223 | left = GNUNET_TIME_absolute_get_remaining(p->tg->next_ping_transmission); |
218 | if (UINT32_MAX == p->tg->base_rate) | 224 | if (UINT32_MAX == p->tg->base_rate) |
219 | { | 225 | { |
220 | p->tg->send_task = GNUNET_SCHEDULER_add_now (&comm_schedule_send, p); | 226 | p->tg->send_task = GNUNET_SCHEDULER_add_now(&comm_schedule_send, p); |
221 | } | 227 | } |
222 | else if (0 == left.rel_value_us) | 228 | else if (0 == left.rel_value_us) |
223 | { | 229 | { |
224 | p->tg->send_task = GNUNET_SCHEDULER_add_now (&comm_schedule_send, p); | 230 | p->tg->send_task = GNUNET_SCHEDULER_add_now(&comm_schedule_send, p); |
225 | } | 231 | } |
226 | else | 232 | else |
227 | { | 233 | { |
228 | /* Enforce minimum transmission rate 1 msg / sec */ | 234 | /* Enforce minimum transmission rate 1 msg / sec */ |
229 | if (GNUNET_TIME_UNIT_SECONDS.rel_value_us == (left = GNUNET_TIME_relative_min (left, GNUNET_TIME_UNIT_SECONDS)).rel_value_us) | 235 | if (GNUNET_TIME_UNIT_SECONDS.rel_value_us == (left = GNUNET_TIME_relative_min(left, GNUNET_TIME_UNIT_SECONDS)).rel_value_us) |
230 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, | 236 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, |
231 | "Enforcing minimum send rate between master [%u] and slave [%u]\n", | 237 | "Enforcing minimum send rate between master [%u] and slave [%u]\n", |
232 | p->me->no, p->dest->no); | 238 | p->me->no, p->dest->no); |
233 | p->tg->send_task = GNUNET_SCHEDULER_add_delayed (left, | 239 | p->tg->send_task = GNUNET_SCHEDULER_add_delayed(left, |
234 | &comm_schedule_send, p); | 240 | &comm_schedule_send, p); |
235 | } | 241 | } |
236 | } | 242 | } |
237 | 243 | ||
238 | 244 | ||
@@ -250,26 +256,26 @@ GNUNET_ATS_TEST_traffic_handle_pong (struct BenchmarkPartner *p) | |||
250 | * @return the traffic generator | 256 | * @return the traffic generator |
251 | */ | 257 | */ |
252 | struct TrafficGenerator * | 258 | struct TrafficGenerator * |
253 | GNUNET_ATS_TEST_generate_traffic_start (struct BenchmarkPeer *src, | 259 | GNUNET_ATS_TEST_generate_traffic_start(struct BenchmarkPeer *src, |
254 | struct BenchmarkPartner *dest, | 260 | struct BenchmarkPartner *dest, |
255 | enum GeneratorType type, | 261 | enum GeneratorType type, |
256 | unsigned int base_rate, | 262 | unsigned int base_rate, |
257 | unsigned int max_rate, | 263 | unsigned int max_rate, |
258 | struct GNUNET_TIME_Relative period, | 264 | struct GNUNET_TIME_Relative period, |
259 | struct GNUNET_TIME_Relative duration) | 265 | struct GNUNET_TIME_Relative duration) |
260 | { | 266 | { |
261 | struct TrafficGenerator *tg; | 267 | struct TrafficGenerator *tg; |
262 | 268 | ||
263 | if (NULL != dest->tg) | 269 | if (NULL != dest->tg) |
264 | { | 270 | { |
265 | GNUNET_break (0); | 271 | GNUNET_break(0); |
266 | return NULL; | 272 | return NULL; |
267 | } | 273 | } |
268 | 274 | ||
269 | tg = GNUNET_new (struct TrafficGenerator); | 275 | tg = GNUNET_new(struct TrafficGenerator); |
270 | GNUNET_CONTAINER_DLL_insert (tg_head, | 276 | GNUNET_CONTAINER_DLL_insert(tg_head, |
271 | tg_tail, | 277 | tg_tail, |
272 | tg); | 278 | tg); |
273 | tg->type = type; | 279 | tg->type = type; |
274 | tg->src = src; | 280 | tg->src = src; |
275 | tg->dest = dest; | 281 | tg->dest = dest; |
@@ -279,71 +285,76 @@ GNUNET_ATS_TEST_generate_traffic_start (struct BenchmarkPeer *src, | |||
279 | tg->time_start = GNUNET_TIME_absolute_get(); | 285 | tg->time_start = GNUNET_TIME_absolute_get(); |
280 | tg->next_ping_transmission = GNUNET_TIME_UNIT_FOREVER_ABS; | 286 | tg->next_ping_transmission = GNUNET_TIME_UNIT_FOREVER_ABS; |
281 | 287 | ||
282 | switch (type) { | 288 | switch (type) |
283 | case GNUNET_ATS_TEST_TG_CONSTANT: | 289 | { |
284 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 290 | case GNUNET_ATS_TEST_TG_CONSTANT: |
285 | "Setting up constant traffic generator master[%u] `%s' and slave [%u] `%s' max %u Bips\n", | 291 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, |
286 | dest->me->no, | 292 | "Setting up constant traffic generator master[%u] `%s' and slave [%u] `%s' max %u Bips\n", |
287 | GNUNET_i2s (&dest->me->id), | 293 | dest->me->no, |
288 | dest->dest->no, | 294 | GNUNET_i2s(&dest->me->id), |
289 | GNUNET_i2s (&dest->dest->id), | 295 | dest->dest->no, |
290 | base_rate); | 296 | GNUNET_i2s(&dest->dest->id), |
291 | break; | 297 | base_rate); |
292 | case GNUNET_ATS_TEST_TG_LINEAR: | 298 | break; |
293 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 299 | |
294 | "Setting up linear traffic generator master[%u] `%s' and slave [%u] `%s' min %u Bips max %u Bips\n", | 300 | case GNUNET_ATS_TEST_TG_LINEAR: |
295 | dest->me->no, | 301 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, |
296 | GNUNET_i2s (&dest->me->id), | 302 | "Setting up linear traffic generator master[%u] `%s' and slave [%u] `%s' min %u Bips max %u Bips\n", |
297 | dest->dest->no, | 303 | dest->me->no, |
298 | GNUNET_i2s (&dest->dest->id), | 304 | GNUNET_i2s(&dest->me->id), |
299 | base_rate, | 305 | dest->dest->no, |
300 | max_rate); | 306 | GNUNET_i2s(&dest->dest->id), |
301 | break; | 307 | base_rate, |
302 | case GNUNET_ATS_TEST_TG_SINUS: | 308 | max_rate); |
303 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 309 | break; |
304 | "Setting up sinus traffic generator master[%u] `%s' and slave [%u] `%s' baserate %u Bips, amplitude %u Bps\n", | 310 | |
305 | dest->me->no, | 311 | case GNUNET_ATS_TEST_TG_SINUS: |
306 | GNUNET_i2s (&dest->me->id), | 312 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, |
307 | dest->dest->no, | 313 | "Setting up sinus traffic generator master[%u] `%s' and slave [%u] `%s' baserate %u Bips, amplitude %u Bps\n", |
308 | GNUNET_i2s (&dest->dest->id), | 314 | dest->me->no, |
309 | base_rate, | 315 | GNUNET_i2s(&dest->me->id), |
310 | max_rate); | 316 | dest->dest->no, |
311 | break; | 317 | GNUNET_i2s(&dest->dest->id), |
312 | case GNUNET_ATS_TEST_TG_RANDOM: | 318 | base_rate, |
313 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 319 | max_rate); |
314 | "Setting up random traffic generator master[%u] `%s' and slave [%u] `%s' min %u Bips max %u Bps\n", | ||
315 | dest->me->no, | ||
316 | GNUNET_i2s (&dest->me->id), | ||
317 | dest->dest->no, | ||
318 | GNUNET_i2s (&dest->dest->id), | ||
319 | base_rate, | ||
320 | max_rate); | ||
321 | break; | 320 | break; |
321 | |||
322 | case GNUNET_ATS_TEST_TG_RANDOM: | ||
323 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, | ||
324 | "Setting up random traffic generator master[%u] `%s' and slave [%u] `%s' min %u Bips max %u Bps\n", | ||
325 | dest->me->no, | ||
326 | GNUNET_i2s(&dest->me->id), | ||
327 | dest->dest->no, | ||
328 | GNUNET_i2s(&dest->dest->id), | ||
329 | base_rate, | ||
330 | max_rate); | ||
331 | break; | ||
332 | |||
322 | default: | 333 | default: |
323 | break; | 334 | break; |
324 | } | 335 | } |
325 | 336 | ||
326 | dest->tg = tg; | 337 | dest->tg = tg; |
327 | tg->send_task | 338 | tg->send_task |
328 | = GNUNET_SCHEDULER_add_now (&comm_schedule_send, | 339 | = GNUNET_SCHEDULER_add_now(&comm_schedule_send, |
329 | dest); | 340 | dest); |
330 | return tg; | 341 | return tg; |
331 | } | 342 | } |
332 | 343 | ||
333 | 344 | ||
334 | void | 345 | void |
335 | GNUNET_ATS_TEST_generate_traffic_stop (struct TrafficGenerator *tg) | 346 | GNUNET_ATS_TEST_generate_traffic_stop(struct TrafficGenerator *tg) |
336 | { | 347 | { |
337 | GNUNET_CONTAINER_DLL_remove (tg_head, | 348 | GNUNET_CONTAINER_DLL_remove(tg_head, |
338 | tg_tail, | 349 | tg_tail, |
339 | tg); | 350 | tg); |
340 | tg->dest->tg = NULL; | 351 | tg->dest->tg = NULL; |
341 | if (NULL != tg->send_task) | 352 | if (NULL != tg->send_task) |
342 | { | 353 | { |
343 | GNUNET_SCHEDULER_cancel (tg->send_task); | 354 | GNUNET_SCHEDULER_cancel(tg->send_task); |
344 | tg->send_task = NULL; | 355 | tg->send_task = NULL; |
345 | } | 356 | } |
346 | GNUNET_free (tg); | 357 | GNUNET_free(tg); |
347 | } | 358 | } |
348 | 359 | ||
349 | 360 | ||
@@ -351,17 +362,17 @@ GNUNET_ATS_TEST_generate_traffic_stop (struct TrafficGenerator *tg) | |||
351 | * Stop all traffic generators | 362 | * Stop all traffic generators |
352 | */ | 363 | */ |
353 | void | 364 | void |
354 | GNUNET_ATS_TEST_generate_traffic_stop_all () | 365 | GNUNET_ATS_TEST_generate_traffic_stop_all() |
355 | { | 366 | { |
356 | struct TrafficGenerator *cur; | 367 | struct TrafficGenerator *cur; |
357 | struct TrafficGenerator *next; | 368 | struct TrafficGenerator *next; |
358 | 369 | ||
359 | next = tg_head; | 370 | next = tg_head; |
360 | for (cur = next; NULL != cur; cur = next) | 371 | for (cur = next; NULL != cur; cur = next) |
361 | { | 372 | { |
362 | next = cur->next; | 373 | next = cur->next; |
363 | GNUNET_ATS_TEST_generate_traffic_stop(cur); | 374 | GNUNET_ATS_TEST_generate_traffic_stop(cur); |
364 | } | 375 | } |
365 | } | 376 | } |
366 | 377 | ||
367 | /* end of file ats-testing-traffic.c */ | 378 | /* end of file ats-testing-traffic.c */ |
diff --git a/src/ats-tests/ats-testing.c b/src/ats-tests/ats-testing.c index d8b9e5ef5..696deb4bd 100644 --- a/src/ats-tests/ats-testing.c +++ b/src/ats-tests/ats-testing.c | |||
@@ -1,19 +1,19 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2010-2013, 2016, 2017 GNUnet e.V. | 3 | Copyright (C) 2010-2013, 2016, 2017 GNUnet e.V. |
4 | 4 | ||
5 | GNUnet is free software: you can redistribute it and/or modify it | 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 | 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, | 7 | by the Free Software Foundation, either version 3 of the License, |
8 | or (at your option) any later version. | 8 | or (at your option) any later version. |
9 | 9 | ||
10 | GNUnet is distributed in the hope that it will be useful, but | 10 | GNUnet is distributed in the hope that it will be useful, but |
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Affero General Public License for more details. | 13 | Affero General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Affero General Public License | 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/>. | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | 17 | ||
18 | SPDX-License-Identifier: AGPL3.0-or-later | 18 | SPDX-License-Identifier: AGPL3.0-or-later |
19 | */ | 19 | */ |
@@ -30,8 +30,7 @@ | |||
30 | /** | 30 | /** |
31 | * Connect peers with testbed | 31 | * Connect peers with testbed |
32 | */ | 32 | */ |
33 | struct TestbedConnectOperation | 33 | struct TestbedConnectOperation { |
34 | { | ||
35 | /** | 34 | /** |
36 | * The benchmarking master initiating this connection | 35 | * The benchmarking master initiating this connection |
37 | */ | 36 | */ |
@@ -59,7 +58,7 @@ struct GNUNET_ATS_TEST_Topology *top; | |||
59 | * @param cls NULL | 58 | * @param cls NULL |
60 | */ | 59 | */ |
61 | static void | 60 | static void |
62 | do_shutdown (void *cls) | 61 | do_shutdown(void *cls) |
63 | { | 62 | { |
64 | int c_m; | 63 | int c_m; |
65 | int c_s; | 64 | int c_s; |
@@ -68,119 +67,119 @@ do_shutdown (void *cls) | |||
68 | 67 | ||
69 | top->state.benchmarking = GNUNET_NO; | 68 | top->state.benchmarking = GNUNET_NO; |
70 | 69 | ||
71 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 70 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, |
72 | "Benchmarking done\n"); | 71 | "Benchmarking done\n"); |
73 | 72 | ||
74 | GNUNET_ATS_TEST_generate_traffic_stop_all (); | 73 | GNUNET_ATS_TEST_generate_traffic_stop_all(); |
75 | 74 | ||
76 | for (c_m = 0; c_m < top->num_masters; c_m++) | 75 | 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 | { | 76 | { |
110 | GNUNET_TESTBED_operation_done (p->comm_op); | 77 | p = &top->mps[c_m]; |
111 | p->comm_op = NULL; | 78 | if (NULL != top->mps[c_m].peer_id_op) |
79 | { | ||
80 | GNUNET_TESTBED_operation_done(p->peer_id_op); | ||
81 | p->peer_id_op = NULL; | ||
82 | } | ||
83 | |||
84 | if (NULL != p->ats_task) | ||
85 | GNUNET_SCHEDULER_cancel(p->ats_task); | ||
86 | p->ats_task = NULL; | ||
87 | |||
88 | for (c_op = 0; c_op < p->num_partners; c_op++) | ||
89 | { | ||
90 | if ((NULL != p->core_connect_ops) && | ||
91 | (NULL != p->core_connect_ops[c_op].connect_op)) | ||
92 | { | ||
93 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, | ||
94 | "Failed to connect peer 0 and %u\n", | ||
95 | c_op); | ||
96 | GNUNET_TESTBED_operation_done(p->core_connect_ops[c_op].connect_op); | ||
97 | p->core_connect_ops[c_op].connect_op = NULL; | ||
98 | } | ||
99 | } | ||
100 | |||
101 | if (NULL != p->ats_perf_op) | ||
102 | { | ||
103 | GNUNET_TESTBED_operation_done(p->ats_perf_op); | ||
104 | p->ats_perf_op = NULL; | ||
105 | } | ||
106 | |||
107 | if (NULL != p->comm_op) | ||
108 | { | ||
109 | GNUNET_TESTBED_operation_done(p->comm_op); | ||
110 | p->comm_op = NULL; | ||
111 | } | ||
112 | GNUNET_free_non_null(p->core_connect_ops); | ||
113 | GNUNET_free(p->partners); | ||
114 | p->partners = NULL; | ||
112 | } | 115 | } |
113 | GNUNET_free_non_null (p->core_connect_ops); | ||
114 | GNUNET_free(p->partners); | ||
115 | p->partners = NULL; | ||
116 | } | ||
117 | 116 | ||
118 | for (c_s = 0; c_s < top->num_slaves; c_s++) | 117 | 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 | { | 118 | { |
133 | GNUNET_TESTBED_operation_done (p->comm_op); | 119 | p = &top->sps[c_s]; |
134 | p->comm_op = NULL; | 120 | if (NULL != p->peer_id_op) |
121 | { | ||
122 | GNUNET_TESTBED_operation_done(p->peer_id_op); | ||
123 | p->peer_id_op = NULL; | ||
124 | } | ||
125 | if (NULL != p->ats_perf_op) | ||
126 | { | ||
127 | GNUNET_TESTBED_operation_done(p->ats_perf_op); | ||
128 | p->ats_perf_op = NULL; | ||
129 | } | ||
130 | if (NULL != p->comm_op) | ||
131 | { | ||
132 | GNUNET_TESTBED_operation_done(p->comm_op); | ||
133 | p->comm_op = NULL; | ||
134 | } | ||
135 | GNUNET_free(p->partners); | ||
136 | p->partners = NULL; | ||
135 | } | 137 | } |
136 | GNUNET_free(p->partners); | 138 | GNUNET_SCHEDULER_shutdown(); |
137 | p->partners = NULL; | 139 | GNUNET_free(top); |
138 | } | ||
139 | GNUNET_SCHEDULER_shutdown (); | ||
140 | GNUNET_free (top); | ||
141 | top = NULL; | 140 | top = NULL; |
142 | } | 141 | } |
143 | 142 | ||
144 | 143 | ||
145 | static struct BenchmarkPartner * | 144 | static struct BenchmarkPartner * |
146 | find_partner (struct BenchmarkPeer *me, | 145 | find_partner(struct BenchmarkPeer *me, |
147 | const struct GNUNET_PeerIdentity *peer) | 146 | const struct GNUNET_PeerIdentity *peer) |
148 | { | 147 | { |
149 | int c_m; | 148 | int c_m; |
150 | 149 | ||
151 | for (c_m = 0; c_m < me->num_partners; c_m++) | 150 | 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 | { | 151 | { |
157 | return &me->partners[c_m]; | 152 | /* Find a partner with other as destination */ |
153 | if (0 == GNUNET_memcmp(peer, | ||
154 | &me->partners[c_m].dest->id)) | ||
155 | { | ||
156 | return &me->partners[c_m]; | ||
157 | } | ||
158 | } | 158 | } |
159 | } | ||
160 | 159 | ||
161 | return NULL; | 160 | return NULL; |
162 | } | 161 | } |
163 | 162 | ||
164 | 163 | ||
165 | static struct BenchmarkPeer * | 164 | static struct BenchmarkPeer * |
166 | find_peer (const struct GNUNET_PeerIdentity * peer) | 165 | find_peer(const struct GNUNET_PeerIdentity * peer) |
167 | { | 166 | { |
168 | int c_p; | 167 | int c_p; |
169 | 168 | ||
170 | for (c_p = 0; c_p < top->num_masters; c_p++) | 169 | for (c_p = 0; c_p < top->num_masters; c_p++) |
171 | { | 170 | { |
172 | if (0 == GNUNET_memcmp (&top->mps[c_p].id, | 171 | if (0 == GNUNET_memcmp(&top->mps[c_p].id, |
173 | peer)) | 172 | peer)) |
174 | return &top->mps[c_p]; | 173 | return &top->mps[c_p]; |
175 | } | 174 | } |
176 | 175 | ||
177 | for (c_p = 0; c_p < top->num_slaves; c_p++) | 176 | for (c_p = 0; c_p < top->num_slaves; c_p++) |
178 | { | 177 | { |
179 | if (0 == GNUNET_memcmp (&top->sps[c_p].id, | 178 | if (0 == GNUNET_memcmp(&top->sps[c_p].id, |
180 | peer)) | 179 | peer)) |
181 | return &top->sps[c_p]; | 180 | return &top->sps[c_p]; |
182 | } | 181 | } |
183 | return NULL ; | 182 | return NULL; |
184 | } | 183 | } |
185 | 184 | ||
186 | 185 | ||
@@ -193,9 +192,9 @@ find_peer (const struct GNUNET_PeerIdentity * peer) | |||
193 | * @return the `struct BenchmarkPartner` of @a peer | 192 | * @return the `struct BenchmarkPartner` of @a peer |
194 | */ | 193 | */ |
195 | static void * | 194 | static void * |
196 | comm_connect_cb (void *cls, | 195 | comm_connect_cb(void *cls, |
197 | const struct GNUNET_PeerIdentity *peer, | 196 | const struct GNUNET_PeerIdentity *peer, |
198 | struct GNUNET_MQ_Handle *mq) | 197 | struct GNUNET_MQ_Handle *mq) |
199 | { | 198 | { |
200 | struct BenchmarkPeer *me = cls; | 199 | struct BenchmarkPeer *me = cls; |
201 | struct BenchmarkPeer *remote; | 200 | struct BenchmarkPeer *remote; |
@@ -204,60 +203,60 @@ comm_connect_cb (void *cls, | |||
204 | int c; | 203 | int c; |
205 | int completed; | 204 | int completed; |
206 | 205 | ||
207 | remote = find_peer (peer); | 206 | remote = find_peer(peer); |
208 | if (NULL == remote) | 207 | if (NULL == remote) |
209 | { | 208 | { |
210 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 209 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, |
211 | "Unknown peer connected: `%s'\n", | 210 | "Unknown peer connected: `%s'\n", |
212 | GNUNET_i2s (peer)); | 211 | GNUNET_i2s(peer)); |
213 | GNUNET_break (0); | 212 | GNUNET_break(0); |
214 | return NULL; | 213 | return NULL; |
215 | } | 214 | } |
216 | 215 | ||
217 | id = GNUNET_strdup (GNUNET_i2s (&me->id)); | 216 | id = GNUNET_strdup(GNUNET_i2s(&me->id)); |
218 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 217 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
219 | "%s [%u] `%s' connected to %s [%u] %s\n", | 218 | "%s [%u] `%s' connected to %s [%u] %s\n", |
220 | (me->master == GNUNET_YES) ? "Master": "Slave", | 219 | (me->master == GNUNET_YES) ? "Master" : "Slave", |
221 | me->no, | 220 | me->no, |
222 | id, | 221 | id, |
223 | (remote->master == GNUNET_YES) ? "Master": "Slave", | 222 | (remote->master == GNUNET_YES) ? "Master" : "Slave", |
224 | remote->no, | 223 | remote->no, |
225 | GNUNET_i2s (peer)); | 224 | GNUNET_i2s(peer)); |
226 | 225 | ||
227 | me->core_connections++; | 226 | me->core_connections++; |
228 | if ((GNUNET_YES == me->master) && | 227 | if ((GNUNET_YES == me->master) && |
229 | (GNUNET_NO == remote->master) && | 228 | (GNUNET_NO == remote->master) && |
230 | (GNUNET_NO == top->state.connected_CORE)) | 229 | (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 | { | 230 | { |
248 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 231 | me->core_slave_connections++; |
249 | "All master peers connected all slave peers\n"); | 232 | |
250 | top->state.connected_CORE = GNUNET_YES; | 233 | if (me->core_slave_connections == top->num_slaves) |
251 | /* Notify about setup done */ | 234 | { |
252 | if (NULL != top->done_cb) | 235 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, |
253 | top->done_cb (top->done_cb_cls, | 236 | "Master [%u] connected all slaves\n", |
254 | top->mps, | 237 | me->no); |
255 | top->sps); | 238 | } |
239 | completed = GNUNET_YES; | ||
240 | for (c = 0; c < top->num_masters; c++) | ||
241 | { | ||
242 | if (top->mps[c].core_slave_connections != top->num_slaves) | ||
243 | completed = GNUNET_NO; | ||
244 | } | ||
245 | if (GNUNET_YES == completed) | ||
246 | { | ||
247 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, | ||
248 | "All master peers connected all slave peers\n"); | ||
249 | top->state.connected_CORE = GNUNET_YES; | ||
250 | /* Notify about setup done */ | ||
251 | if (NULL != top->done_cb) | ||
252 | top->done_cb(top->done_cb_cls, | ||
253 | top->mps, | ||
254 | top->sps); | ||
255 | } | ||
256 | } | 256 | } |
257 | } | 257 | GNUNET_free(id); |
258 | GNUNET_free (id); | 258 | p = find_partner(me, |
259 | p = find_partner (me, | 259 | peer); |
260 | peer); | ||
261 | if (NULL != p) | 260 | if (NULL != p) |
262 | p->mq = mq; | 261 | p->mq = mq; |
263 | return p; | 262 | return p; |
@@ -270,9 +269,9 @@ comm_connect_cb (void *cls, | |||
270 | * @param internal_cls the `struct BenchmarkPartner` of @a peer | 269 | * @param internal_cls the `struct BenchmarkPartner` of @a peer |
271 | */ | 270 | */ |
272 | static void | 271 | static void |
273 | comm_disconnect_cb (void *cls, | 272 | comm_disconnect_cb(void *cls, |
274 | const struct GNUNET_PeerIdentity *peer, | 273 | const struct GNUNET_PeerIdentity *peer, |
275 | void *internal_cls) | 274 | void *internal_cls) |
276 | { | 275 | { |
277 | struct BenchmarkPeer *me = cls; | 276 | struct BenchmarkPeer *me = cls; |
278 | struct BenchmarkPartner *p = internal_cls; | 277 | struct BenchmarkPartner *p = internal_cls; |
@@ -281,169 +280,170 @@ comm_disconnect_cb (void *cls, | |||
281 | if (NULL == p) | 280 | if (NULL == p) |
282 | return; | 281 | return; |
283 | 282 | ||
284 | id = GNUNET_strdup (GNUNET_i2s (&me->id)); | 283 | id = GNUNET_strdup(GNUNET_i2s(&me->id)); |
285 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 284 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
286 | "%s disconnected from %s\n", | 285 | "%s disconnected from %s\n", |
287 | id, | 286 | id, |
288 | GNUNET_i2s (peer)); | 287 | GNUNET_i2s(peer)); |
289 | GNUNET_assert (me->core_connections > 0); | 288 | GNUNET_assert(me->core_connections > 0); |
290 | me->core_connections--; | 289 | me->core_connections--; |
291 | 290 | ||
292 | if ( (GNUNET_YES == top->state.benchmarking) && | 291 | if ((GNUNET_YES == top->state.benchmarking) && |
293 | ( (GNUNET_YES == me->master) || | 292 | ((GNUNET_YES == me->master) || |
294 | (GNUNET_YES == p->dest->master) ) ) | 293 | (GNUNET_YES == p->dest->master))) |
295 | { | 294 | { |
296 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 295 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, |
297 | "%s disconnected from %s while benchmarking\n", | 296 | "%s disconnected from %s while benchmarking\n", |
298 | id, | 297 | id, |
299 | GNUNET_i2s (peer)); | 298 | GNUNET_i2s(peer)); |
300 | } | 299 | } |
301 | GNUNET_free(id); | 300 | GNUNET_free(id); |
302 | } | 301 | } |
303 | 302 | ||
304 | 303 | ||
305 | static void | 304 | static void |
306 | handle_pong (void *cls, | 305 | handle_pong(void *cls, |
307 | const struct TestMessage *message) | 306 | const struct TestMessage *message) |
308 | { | 307 | { |
309 | struct BenchmarkPartner *p = cls; | 308 | struct BenchmarkPartner *p = cls; |
310 | 309 | ||
311 | GNUNET_ATS_TEST_traffic_handle_pong (p); | 310 | GNUNET_ATS_TEST_traffic_handle_pong(p); |
312 | } | 311 | } |
313 | 312 | ||
314 | 313 | ||
315 | static void | 314 | static void |
316 | handle_ping (void *cls, | 315 | handle_ping(void *cls, |
317 | const struct TestMessage *message) | 316 | const struct TestMessage *message) |
318 | { | 317 | { |
319 | struct BenchmarkPartner *p = cls; | 318 | struct BenchmarkPartner *p = cls; |
320 | 319 | ||
321 | GNUNET_ATS_TEST_traffic_handle_ping (p); | 320 | GNUNET_ATS_TEST_traffic_handle_ping(p); |
322 | } | 321 | } |
323 | 322 | ||
324 | 323 | ||
325 | static void * | 324 | static void * |
326 | transport_connect_adapter (void *cls, | 325 | transport_connect_adapter(void *cls, |
327 | const struct GNUNET_CONFIGURATION_Handle *cfg) | 326 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
328 | { | 327 | { |
329 | struct BenchmarkPeer *me = cls; | 328 | struct BenchmarkPeer *me = cls; |
330 | struct GNUNET_MQ_MessageHandler handlers[] = { | 329 | struct GNUNET_MQ_MessageHandler handlers[] = { |
331 | GNUNET_MQ_hd_fixed_size (ping, | 330 | GNUNET_MQ_hd_fixed_size(ping, |
332 | TEST_MESSAGE_TYPE_PING, | 331 | TEST_MESSAGE_TYPE_PING, |
333 | struct TestMessage, | 332 | struct TestMessage, |
334 | me), | 333 | me), |
335 | GNUNET_MQ_hd_fixed_size (pong, | 334 | GNUNET_MQ_hd_fixed_size(pong, |
336 | TEST_MESSAGE_TYPE_PONG, | 335 | TEST_MESSAGE_TYPE_PONG, |
337 | struct TestMessage, | 336 | struct TestMessage, |
338 | me), | 337 | me), |
339 | GNUNET_MQ_handler_end () | 338 | GNUNET_MQ_handler_end() |
340 | }; | 339 | }; |
341 | 340 | ||
342 | me->th = GNUNET_TRANSPORT_core_connect (cfg, | 341 | me->th = GNUNET_TRANSPORT_core_connect(cfg, |
343 | &me->id, | 342 | &me->id, |
344 | handlers, | 343 | handlers, |
345 | me, | 344 | me, |
346 | &comm_connect_cb, | 345 | &comm_connect_cb, |
347 | &comm_disconnect_cb, | 346 | &comm_disconnect_cb, |
348 | NULL); | 347 | NULL); |
349 | if (NULL == me->th) | 348 | if (NULL == me->th) |
350 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 349 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, |
351 | "Failed to create transport connection \n"); | 350 | "Failed to create transport connection \n"); |
352 | return me->th; | 351 | return me->th; |
353 | } | 352 | } |
354 | 353 | ||
355 | 354 | ||
356 | static void | 355 | static void |
357 | transport_disconnect_adapter (void *cls, | 356 | transport_disconnect_adapter(void *cls, |
358 | void *op_result) | 357 | void *op_result) |
359 | { | 358 | { |
360 | struct BenchmarkPeer *me = cls; | 359 | struct BenchmarkPeer *me = cls; |
361 | 360 | ||
362 | GNUNET_TRANSPORT_core_disconnect (me->th); | 361 | GNUNET_TRANSPORT_core_disconnect(me->th); |
363 | me->th = NULL; | 362 | me->th = NULL; |
364 | } | 363 | } |
365 | 364 | ||
366 | 365 | ||
367 | static void * | 366 | static void * |
368 | core_connect_adapter (void *cls, | 367 | core_connect_adapter(void *cls, |
369 | const struct GNUNET_CONFIGURATION_Handle *cfg) | 368 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
370 | { | 369 | { |
371 | struct BenchmarkPeer *me = cls; | 370 | struct BenchmarkPeer *me = cls; |
372 | struct GNUNET_MQ_MessageHandler handlers[] = { | 371 | struct GNUNET_MQ_MessageHandler handlers[] = { |
373 | GNUNET_MQ_hd_fixed_size (ping, | 372 | GNUNET_MQ_hd_fixed_size(ping, |
374 | TEST_MESSAGE_TYPE_PING, | 373 | TEST_MESSAGE_TYPE_PING, |
375 | struct TestMessage, | 374 | struct TestMessage, |
376 | me), | 375 | me), |
377 | GNUNET_MQ_hd_fixed_size (pong, | 376 | GNUNET_MQ_hd_fixed_size(pong, |
378 | TEST_MESSAGE_TYPE_PONG, | 377 | TEST_MESSAGE_TYPE_PONG, |
379 | struct TestMessage, | 378 | struct TestMessage, |
380 | me), | 379 | me), |
381 | GNUNET_MQ_handler_end () | 380 | GNUNET_MQ_handler_end() |
382 | }; | 381 | }; |
383 | 382 | ||
384 | me->ch = GNUNET_CORE_connect (cfg, | 383 | me->ch = GNUNET_CORE_connect(cfg, |
385 | me, | 384 | me, |
386 | NULL, | 385 | NULL, |
387 | &comm_connect_cb, | 386 | &comm_connect_cb, |
388 | &comm_disconnect_cb, | 387 | &comm_disconnect_cb, |
389 | handlers); | 388 | handlers); |
390 | if (NULL == me->ch) | 389 | if (NULL == me->ch) |
391 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 390 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, |
392 | "Failed to create core connection \n"); | 391 | "Failed to create core connection \n"); |
393 | return me->ch; | 392 | return me->ch; |
394 | } | 393 | } |
395 | 394 | ||
396 | 395 | ||
397 | static void | 396 | static void |
398 | core_disconnect_adapter (void *cls, | 397 | core_disconnect_adapter(void *cls, |
399 | void *op_result) | 398 | void *op_result) |
400 | { | 399 | { |
401 | struct BenchmarkPeer *me = cls; | 400 | struct BenchmarkPeer *me = cls; |
402 | 401 | ||
403 | GNUNET_CORE_disconnect (me->ch); | 402 | GNUNET_CORE_disconnect(me->ch); |
404 | me->ch = NULL; | 403 | me->ch = NULL; |
405 | } | 404 | } |
406 | 405 | ||
407 | 406 | ||
408 | static void | 407 | static void |
409 | connect_completion_callback (void *cls, | 408 | connect_completion_callback(void *cls, |
410 | struct GNUNET_TESTBED_Operation *op, | 409 | struct GNUNET_TESTBED_Operation *op, |
411 | const char *emsg) | 410 | const char *emsg) |
412 | { | 411 | { |
413 | struct TestbedConnectOperation *cop = cls; | 412 | struct TestbedConnectOperation *cop = cls; |
414 | static int ops = 0; | 413 | static int ops = 0; |
415 | int c; | 414 | int c; |
415 | |||
416 | if (NULL == emsg) | 416 | if (NULL == emsg) |
417 | { | 417 | { |
418 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, | 418 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, |
419 | _("Connected master [%u] with slave [%u]\n"), | 419 | _("Connected master [%u] with slave [%u]\n"), |
420 | cop->master->no, | 420 | cop->master->no, |
421 | cop->slave->no); | 421 | cop->slave->no); |
422 | } | 422 | } |
423 | else | 423 | else |
424 | { | 424 | { |
425 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, | 425 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, |
426 | _("Failed to connect master peer [%u] with slave [%u]\n"), | 426 | _("Failed to connect master peer [%u] with slave [%u]\n"), |
427 | cop->master->no, cop->slave->no); | 427 | cop->master->no, cop->slave->no); |
428 | GNUNET_break(0); | 428 | GNUNET_break(0); |
429 | GNUNET_SCHEDULER_shutdown (); | 429 | GNUNET_SCHEDULER_shutdown(); |
430 | } | 430 | } |
431 | GNUNET_TESTBED_operation_done (op); | 431 | GNUNET_TESTBED_operation_done(op); |
432 | ops++; | 432 | ops++; |
433 | for (c = 0; c < top->num_slaves; c++) | 433 | for (c = 0; c < top->num_slaves; c++) |
434 | { | 434 | { |
435 | if (cop == &cop->master->core_connect_ops[c]) | 435 | if (cop == &cop->master->core_connect_ops[c]) |
436 | cop->master->core_connect_ops[c].connect_op = NULL; | 436 | cop->master->core_connect_ops[c].connect_op = NULL; |
437 | } | 437 | } |
438 | if (ops == top->num_masters * top->num_slaves) | 438 | if (ops == top->num_masters * top->num_slaves) |
439 | { | 439 | { |
440 | top->state.connected_PEERS = GNUNET_YES; | 440 | top->state.connected_PEERS = GNUNET_YES; |
441 | } | 441 | } |
442 | } | 442 | } |
443 | 443 | ||
444 | 444 | ||
445 | static void | 445 | static void |
446 | do_connect_peers (void *cls) | 446 | do_connect_peers(void *cls) |
447 | { | 447 | { |
448 | int c_m; | 448 | int c_m; |
449 | int c_s; | 449 | int c_s; |
@@ -453,142 +453,143 @@ do_connect_peers (void *cls) | |||
453 | (top->state.connected_COMM_service == GNUNET_NO)) | 453 | (top->state.connected_COMM_service == GNUNET_NO)) |
454 | return; | 454 | return; |
455 | 455 | ||
456 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 456 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, |
457 | "Connecting peers on CORE level\n"); | 457 | "Connecting peers on CORE level\n"); |
458 | for (c_m = 0; c_m < top->num_masters; c_m++) | 458 | for (c_m = 0; c_m < top->num_masters; c_m++) |
459 | { | ||
460 | p = &top->mps[c_m]; | ||
461 | p->core_connect_ops = GNUNET_malloc (top->num_slaves * | ||
462 | sizeof (struct TestbedConnectOperation)); | ||
463 | |||
464 | for (c_s = 0; c_s < top->num_slaves; c_s++) | ||
465 | { | 459 | { |
466 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 460 | p = &top->mps[c_m]; |
467 | "Connecting master [%u] with slave [%u]\n", | 461 | p->core_connect_ops = GNUNET_malloc(top->num_slaves * |
468 | p->no, | 462 | sizeof(struct TestbedConnectOperation)); |
469 | top->sps[c_s].no); | 463 | |
470 | p->core_connect_ops[c_s].master = p; | 464 | for (c_s = 0; c_s < top->num_slaves; c_s++) |
471 | p->core_connect_ops[c_s].slave = &top->sps[c_s]; | 465 | { |
472 | p->core_connect_ops[c_s].connect_op | 466 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, |
473 | = GNUNET_TESTBED_overlay_connect (NULL, | 467 | "Connecting master [%u] with slave [%u]\n", |
474 | &connect_completion_callback, | 468 | p->no, |
475 | &p->core_connect_ops[c_s], | 469 | top->sps[c_s].no); |
476 | top->sps[c_s].peer, | 470 | p->core_connect_ops[c_s].master = p; |
477 | p->peer); | 471 | p->core_connect_ops[c_s].slave = &top->sps[c_s]; |
478 | if (NULL == p->core_connect_ops[c_s].connect_op) | 472 | p->core_connect_ops[c_s].connect_op |
479 | { | 473 | = GNUNET_TESTBED_overlay_connect(NULL, |
480 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 474 | &connect_completion_callback, |
481 | "Could not connect master [%u] and slave [%u]\n", | 475 | &p->core_connect_ops[c_s], |
482 | p->no, | 476 | top->sps[c_s].peer, |
483 | top->sps[c_s].no); | 477 | p->peer); |
484 | GNUNET_break(0); | 478 | if (NULL == p->core_connect_ops[c_s].connect_op) |
485 | GNUNET_SCHEDULER_shutdown (); | 479 | { |
486 | return; | 480 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, |
487 | } | 481 | "Could not connect master [%u] and slave [%u]\n", |
482 | p->no, | ||
483 | top->sps[c_s].no); | ||
484 | GNUNET_break(0); | ||
485 | GNUNET_SCHEDULER_shutdown(); | ||
486 | return; | ||
487 | } | ||
488 | } | ||
488 | } | 489 | } |
489 | } | ||
490 | } | 490 | } |
491 | 491 | ||
492 | 492 | ||
493 | static void | 493 | static void |
494 | comm_connect_completion_cb (void *cls, | 494 | comm_connect_completion_cb(void *cls, |
495 | struct GNUNET_TESTBED_Operation *op, | 495 | struct GNUNET_TESTBED_Operation *op, |
496 | void *ca_result, | 496 | void *ca_result, |
497 | const char *emsg) | 497 | const char *emsg) |
498 | { | 498 | { |
499 | static int comm_done = 0; | 499 | static int comm_done = 0; |
500 | 500 | ||
501 | if ((NULL != emsg) || (NULL == ca_result)) | 501 | if ((NULL != emsg) || (NULL == ca_result)) |
502 | { | 502 | { |
503 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, | 503 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, |
504 | "Initialization failed, shutdown\n"); | 504 | "Initialization failed, shutdown\n"); |
505 | GNUNET_break(0); | 505 | GNUNET_break(0); |
506 | GNUNET_SCHEDULER_shutdown (); | 506 | GNUNET_SCHEDULER_shutdown(); |
507 | return; | 507 | return; |
508 | } | 508 | } |
509 | comm_done++; | 509 | comm_done++; |
510 | 510 | ||
511 | if (comm_done == top->num_slaves + top->num_masters) | 511 | if (comm_done == top->num_slaves + top->num_masters) |
512 | { | 512 | { |
513 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 513 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, |
514 | "Connected to all %s services\n", | 514 | "Connected to all %s services\n", |
515 | (GNUNET_YES == top->test_core) ? "CORE" : "TRANSPORT"); | 515 | (GNUNET_YES == top->test_core) ? "CORE" : "TRANSPORT"); |
516 | top->state.connected_COMM_service = GNUNET_YES; | 516 | top->state.connected_COMM_service = GNUNET_YES; |
517 | GNUNET_SCHEDULER_add_now (&do_connect_peers, | 517 | GNUNET_SCHEDULER_add_now(&do_connect_peers, |
518 | NULL); | 518 | NULL); |
519 | } | 519 | } |
520 | } | 520 | } |
521 | 521 | ||
522 | 522 | ||
523 | static void | 523 | static void |
524 | do_comm_connect (void *cls) | 524 | do_comm_connect(void *cls) |
525 | { | 525 | { |
526 | int c_s; | 526 | int c_s; |
527 | int c_m; | 527 | int c_m; |
528 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 528 | |
529 | "Connecting to all %s services\n", | 529 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, |
530 | (GNUNET_YES == top->test_core) ? "CORE" : "TRANSPORT"); | 530 | "Connecting to all %s services\n", |
531 | (GNUNET_YES == top->test_core) ? "CORE" : "TRANSPORT"); | ||
531 | for (c_m = 0; c_m < top->num_masters; c_m++) | 532 | for (c_m = 0; c_m < top->num_masters; c_m++) |
532 | { | ||
533 | if (GNUNET_YES == top->test_core) | ||
534 | top->mps[c_m].comm_op | ||
535 | = GNUNET_TESTBED_service_connect (NULL, | ||
536 | top->mps[c_m].peer, | ||
537 | "core", | ||
538 | &comm_connect_completion_cb, | ||
539 | NULL, | ||
540 | &core_connect_adapter, | ||
541 | &core_disconnect_adapter, | ||
542 | &top->mps[c_m]); | ||
543 | else | ||
544 | { | 533 | { |
545 | top->mps[c_m].comm_op | 534 | if (GNUNET_YES == top->test_core) |
546 | = GNUNET_TESTBED_service_connect (NULL, | 535 | top->mps[c_m].comm_op |
547 | top->mps[c_m].peer, | 536 | = GNUNET_TESTBED_service_connect(NULL, |
548 | "transport", | 537 | top->mps[c_m].peer, |
549 | &comm_connect_completion_cb, | 538 | "core", |
550 | NULL, | 539 | &comm_connect_completion_cb, |
551 | &transport_connect_adapter, | 540 | NULL, |
552 | &transport_disconnect_adapter, | 541 | &core_connect_adapter, |
553 | &top->mps[c_m]); | 542 | &core_disconnect_adapter, |
543 | &top->mps[c_m]); | ||
544 | else | ||
545 | { | ||
546 | top->mps[c_m].comm_op | ||
547 | = GNUNET_TESTBED_service_connect(NULL, | ||
548 | top->mps[c_m].peer, | ||
549 | "transport", | ||
550 | &comm_connect_completion_cb, | ||
551 | NULL, | ||
552 | &transport_connect_adapter, | ||
553 | &transport_disconnect_adapter, | ||
554 | &top->mps[c_m]); | ||
555 | } | ||
554 | } | 556 | } |
555 | } | ||
556 | 557 | ||
557 | for (c_s = 0; c_s < top->num_slaves; c_s++) | 558 | for (c_s = 0; c_s < top->num_slaves; c_s++) |
558 | { | ||
559 | if (GNUNET_YES == top->test_core) | ||
560 | top->sps[c_s].comm_op | ||
561 | = GNUNET_TESTBED_service_connect (NULL, | ||
562 | top->sps[c_s].peer, | ||
563 | "core", | ||
564 | &comm_connect_completion_cb, | ||
565 | NULL, | ||
566 | &core_connect_adapter, | ||
567 | &core_disconnect_adapter, | ||
568 | &top->sps[c_s]); | ||
569 | else | ||
570 | { | 559 | { |
571 | top->sps[c_s].comm_op | 560 | if (GNUNET_YES == top->test_core) |
572 | = GNUNET_TESTBED_service_connect (NULL, | 561 | top->sps[c_s].comm_op |
573 | top->sps[c_s].peer, | 562 | = GNUNET_TESTBED_service_connect(NULL, |
574 | "transport", | 563 | top->sps[c_s].peer, |
575 | &comm_connect_completion_cb, | 564 | "core", |
576 | NULL, | 565 | &comm_connect_completion_cb, |
577 | &transport_connect_adapter, | 566 | NULL, |
578 | &transport_disconnect_adapter, | 567 | &core_connect_adapter, |
579 | &top->sps[c_s]); | 568 | &core_disconnect_adapter, |
569 | &top->sps[c_s]); | ||
570 | else | ||
571 | { | ||
572 | top->sps[c_s].comm_op | ||
573 | = GNUNET_TESTBED_service_connect(NULL, | ||
574 | top->sps[c_s].peer, | ||
575 | "transport", | ||
576 | &comm_connect_completion_cb, | ||
577 | NULL, | ||
578 | &transport_connect_adapter, | ||
579 | &transport_disconnect_adapter, | ||
580 | &top->sps[c_s]); | ||
581 | } | ||
580 | } | 582 | } |
581 | } | ||
582 | } | 583 | } |
583 | 584 | ||
584 | 585 | ||
585 | static void | 586 | static void |
586 | ats_performance_info_cb (void *cls, | 587 | ats_performance_info_cb(void *cls, |
587 | const struct GNUNET_HELLO_Address *address, | 588 | const struct GNUNET_HELLO_Address *address, |
588 | int address_active, | 589 | int address_active, |
589 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, | 590 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, |
590 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, | 591 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, |
591 | const struct GNUNET_ATS_Properties *ats_prop) | 592 | const struct GNUNET_ATS_Properties *ats_prop) |
592 | { | 593 | { |
593 | struct BenchmarkPeer *me = cls; | 594 | struct BenchmarkPeer *me = cls; |
594 | struct BenchmarkPartner *p; | 595 | struct BenchmarkPartner *p; |
@@ -596,36 +597,36 @@ ats_performance_info_cb (void *cls, | |||
596 | char *peer_id; | 597 | char *peer_id; |
597 | 598 | ||
598 | if (NULL == address) | 599 | if (NULL == address) |
599 | { | 600 | { |
600 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 601 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, |
601 | "Peer %u: ATS Service disconnected!\n", | 602 | "Peer %u: ATS Service disconnected!\n", |
602 | me->no); | 603 | me->no); |
603 | return; | 604 | return; |
604 | } | 605 | } |
605 | 606 | ||
606 | p = find_partner (me, | 607 | p = find_partner(me, |
607 | &address->peer); | 608 | &address->peer); |
608 | if (NULL == p) | 609 | if (NULL == p) |
609 | { | 610 | { |
610 | /* This is not one of my partners | 611 | /* This is not one of my partners |
611 | * Will happen since the peers will connect to each other due to gossiping | 612 | * Will happen since the peers will connect to each other due to gossiping |
612 | */ | 613 | */ |
613 | return; | 614 | return; |
614 | } | 615 | } |
615 | peer_id = GNUNET_strdup (GNUNET_i2s (&me->id)); | 616 | peer_id = GNUNET_strdup(GNUNET_i2s(&me->id)); |
616 | 617 | ||
617 | log = GNUNET_NO; | 618 | log = GNUNET_NO; |
618 | if ((p->bandwidth_in != ntohl (bandwidth_in.value__)) || | 619 | if ((p->bandwidth_in != ntohl(bandwidth_in.value__)) || |
619 | (p->bandwidth_out != ntohl (bandwidth_out.value__))) | 620 | (p->bandwidth_out != ntohl(bandwidth_out.value__))) |
620 | log = GNUNET_YES; | 621 | log = GNUNET_YES; |
621 | p->bandwidth_in = ntohl (bandwidth_in.value__); | 622 | p->bandwidth_in = ntohl(bandwidth_in.value__); |
622 | p->bandwidth_out = ntohl (bandwidth_out.value__); | 623 | p->bandwidth_out = ntohl(bandwidth_out.value__); |
623 | 624 | ||
624 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 625 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
625 | "%s [%u] received ATS information: %s\n", | 626 | "%s [%u] received ATS information: %s\n", |
626 | (GNUNET_YES == p->me->master) ? "Master" : "Slave", | 627 | (GNUNET_YES == p->me->master) ? "Master" : "Slave", |
627 | p->me->no, | 628 | p->me->no, |
628 | GNUNET_i2s (&p->dest->id)); | 629 | GNUNET_i2s(&p->dest->id)); |
629 | 630 | ||
630 | p->props.utilization_out = ats_prop->utilization_out; | 631 | p->props.utilization_out = ats_prop->utilization_out; |
631 | p->props.utilization_in = ats_prop->utilization_in; | 632 | p->props.utilization_in = ats_prop->utilization_in; |
@@ -634,113 +635,113 @@ ats_performance_info_cb (void *cls, | |||
634 | p->props.distance = ats_prop->distance; | 635 | p->props.distance = ats_prop->distance; |
635 | 636 | ||
636 | if (GNUNET_YES == log) | 637 | if (GNUNET_YES == log) |
637 | top->ats_perf_cb (cls, address, | 638 | top->ats_perf_cb(cls, address, |
638 | address_active, | 639 | address_active, |
639 | bandwidth_out, | 640 | bandwidth_out, |
640 | bandwidth_in, | 641 | bandwidth_in, |
641 | ats_prop); | 642 | ats_prop); |
642 | GNUNET_free(peer_id); | 643 | GNUNET_free(peer_id); |
643 | } | 644 | } |
644 | 645 | ||
645 | 646 | ||
646 | static void * | 647 | static void * |
647 | ats_perf_connect_adapter (void *cls, | 648 | ats_perf_connect_adapter(void *cls, |
648 | const struct GNUNET_CONFIGURATION_Handle *cfg) | 649 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
649 | { | 650 | { |
650 | struct BenchmarkPeer *me = cls; | 651 | struct BenchmarkPeer *me = cls; |
651 | 652 | ||
652 | me->ats_perf_handle | 653 | me->ats_perf_handle |
653 | = GNUNET_ATS_performance_init (cfg, | 654 | = GNUNET_ATS_performance_init(cfg, |
654 | &ats_performance_info_cb, | 655 | &ats_performance_info_cb, |
655 | me); | 656 | me); |
656 | if (NULL == me->ats_perf_handle) | 657 | if (NULL == me->ats_perf_handle) |
657 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 658 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, |
658 | "Failed to create ATS performance handle \n"); | 659 | "Failed to create ATS performance handle \n"); |
659 | return me->ats_perf_handle; | 660 | return me->ats_perf_handle; |
660 | } | 661 | } |
661 | 662 | ||
662 | 663 | ||
663 | static void | 664 | static void |
664 | ats_perf_disconnect_adapter (void *cls, | 665 | ats_perf_disconnect_adapter(void *cls, |
665 | void *op_result) | 666 | void *op_result) |
666 | { | 667 | { |
667 | struct BenchmarkPeer *me = cls; | 668 | struct BenchmarkPeer *me = cls; |
668 | 669 | ||
669 | GNUNET_ATS_performance_done (me->ats_perf_handle); | 670 | GNUNET_ATS_performance_done(me->ats_perf_handle); |
670 | me->ats_perf_handle = NULL; | 671 | me->ats_perf_handle = NULL; |
671 | } | 672 | } |
672 | 673 | ||
673 | 674 | ||
674 | static void | 675 | static void |
675 | ats_connect_completion_cb (void *cls, | 676 | ats_connect_completion_cb(void *cls, |
676 | struct GNUNET_TESTBED_Operation *op, | 677 | struct GNUNET_TESTBED_Operation *op, |
677 | void *ca_result, | 678 | void *ca_result, |
678 | const char *emsg) | 679 | const char *emsg) |
679 | { | 680 | { |
680 | static int op_done = 0; | 681 | static int op_done = 0; |
681 | 682 | ||
682 | if ((NULL != emsg) || (NULL == ca_result)) | 683 | if ((NULL != emsg) || (NULL == ca_result)) |
683 | { | 684 | { |
684 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, | 685 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, |
685 | "Initialization failed, shutdown\n"); | 686 | "Initialization failed, shutdown\n"); |
686 | GNUNET_break(0); | 687 | GNUNET_break(0); |
687 | GNUNET_SCHEDULER_shutdown (); | 688 | GNUNET_SCHEDULER_shutdown(); |
688 | return; | 689 | return; |
689 | } | 690 | } |
690 | op_done++; | 691 | op_done++; |
691 | if (op_done == (top->num_masters + top->num_slaves)) | 692 | if (op_done == (top->num_masters + top->num_slaves)) |
692 | { | 693 | { |
693 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 694 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, |
694 | "Connected to all ATS services\n"); | 695 | "Connected to all ATS services\n"); |
695 | top->state.connected_ATS_service = GNUNET_YES; | 696 | top->state.connected_ATS_service = GNUNET_YES; |
696 | GNUNET_SCHEDULER_add_now (&do_comm_connect, | 697 | GNUNET_SCHEDULER_add_now(&do_comm_connect, |
697 | NULL); | 698 | NULL); |
698 | } | 699 | } |
699 | } | 700 | } |
700 | 701 | ||
701 | 702 | ||
702 | static void | 703 | static void |
703 | do_connect_ats (void *cls) | 704 | do_connect_ats(void *cls) |
704 | { | 705 | { |
705 | int c_m; | 706 | int c_m; |
706 | int c_s; | 707 | int c_s; |
707 | 708 | ||
708 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 709 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, |
709 | "Connecting to all ATS services\n"); | 710 | "Connecting to all ATS services\n"); |
710 | for (c_m = 0; c_m < top->num_masters; c_m++) | 711 | for (c_m = 0; c_m < top->num_masters; c_m++) |
711 | { | 712 | { |
712 | top->mps[c_m].ats_perf_op | 713 | top->mps[c_m].ats_perf_op |
713 | = GNUNET_TESTBED_service_connect (NULL, | 714 | = GNUNET_TESTBED_service_connect(NULL, |
714 | top->mps[c_m].peer, | 715 | top->mps[c_m].peer, |
715 | "ats", | 716 | "ats", |
716 | &ats_connect_completion_cb, | 717 | &ats_connect_completion_cb, |
717 | NULL, | 718 | NULL, |
718 | &ats_perf_connect_adapter, | 719 | &ats_perf_connect_adapter, |
719 | &ats_perf_disconnect_adapter, | 720 | &ats_perf_disconnect_adapter, |
720 | &top->mps[c_m]); | 721 | &top->mps[c_m]); |
721 | } | 722 | } |
722 | 723 | ||
723 | for (c_s = 0; c_s < top->num_slaves; c_s++) | 724 | for (c_s = 0; c_s < top->num_slaves; c_s++) |
724 | { | 725 | { |
725 | top->sps[c_s].ats_perf_op | 726 | top->sps[c_s].ats_perf_op |
726 | = GNUNET_TESTBED_service_connect (NULL, | 727 | = GNUNET_TESTBED_service_connect(NULL, |
727 | top->sps[c_s].peer, | 728 | top->sps[c_s].peer, |
728 | "ats", | 729 | "ats", |
729 | &ats_connect_completion_cb, | 730 | &ats_connect_completion_cb, |
730 | NULL, | 731 | NULL, |
731 | &ats_perf_connect_adapter, | 732 | &ats_perf_connect_adapter, |
732 | &ats_perf_disconnect_adapter, | 733 | &ats_perf_disconnect_adapter, |
733 | &top->sps[c_s]); | 734 | &top->sps[c_s]); |
734 | } | 735 | } |
735 | } | 736 | } |
736 | 737 | ||
737 | 738 | ||
738 | 739 | ||
739 | static void | 740 | static void |
740 | peerinformation_cb (void *cb_cls, | 741 | peerinformation_cb(void *cb_cls, |
741 | struct GNUNET_TESTBED_Operation *op, | 742 | struct GNUNET_TESTBED_Operation *op, |
742 | const struct GNUNET_TESTBED_PeerInformation *pinfo, | 743 | const struct GNUNET_TESTBED_PeerInformation *pinfo, |
743 | const char *emsg) | 744 | const char *emsg) |
744 | { | 745 | { |
745 | struct BenchmarkPeer *p = cb_cls; | 746 | struct BenchmarkPeer *p = cb_cls; |
746 | static int done = 0; | 747 | static int done = 0; |
@@ -748,23 +749,23 @@ peerinformation_cb (void *cb_cls, | |||
748 | GNUNET_assert(pinfo->pit == GNUNET_TESTBED_PIT_IDENTITY); | 749 | GNUNET_assert(pinfo->pit == GNUNET_TESTBED_PIT_IDENTITY); |
749 | 750 | ||
750 | p->id = *pinfo->result.id; | 751 | p->id = *pinfo->result.id; |
751 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 752 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, |
752 | "%s [%u] has peer id `%s'\n", | 753 | "%s [%u] has peer id `%s'\n", |
753 | (p->master == GNUNET_YES) ? "Master" : "Slave", | 754 | (p->master == GNUNET_YES) ? "Master" : "Slave", |
754 | p->no, | 755 | p->no, |
755 | GNUNET_i2s (&p->id)); | 756 | GNUNET_i2s(&p->id)); |
756 | 757 | ||
757 | GNUNET_TESTBED_operation_done (op); | 758 | GNUNET_TESTBED_operation_done(op); |
758 | p->peer_id_op = NULL; | 759 | p->peer_id_op = NULL; |
759 | done++; | 760 | done++; |
760 | 761 | ||
761 | if (done == top->num_slaves + top->num_masters) | 762 | if (done == top->num_slaves + top->num_masters) |
762 | { | 763 | { |
763 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 764 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, |
764 | "Retrieved all peer ID, connect to ATS\n"); | 765 | "Retrieved all peer ID, connect to ATS\n"); |
765 | GNUNET_SCHEDULER_add_now (&do_connect_ats, | 766 | GNUNET_SCHEDULER_add_now(&do_connect_ats, |
766 | NULL); | 767 | NULL); |
767 | } | 768 | } |
768 | } | 769 | } |
769 | 770 | ||
770 | 771 | ||
@@ -781,85 +782,85 @@ peerinformation_cb (void *cb_cls, | |||
781 | * failed | 782 | * failed |
782 | */ | 783 | */ |
783 | static void | 784 | static void |
784 | main_run (void *cls, | 785 | main_run(void *cls, |
785 | struct GNUNET_TESTBED_RunHandle *h, | 786 | struct GNUNET_TESTBED_RunHandle *h, |
786 | unsigned int num_peers, | 787 | unsigned int num_peers, |
787 | struct GNUNET_TESTBED_Peer **peers_, | 788 | struct GNUNET_TESTBED_Peer **peers_, |
788 | unsigned int links_succeeded, | 789 | unsigned int links_succeeded, |
789 | unsigned int links_failed) | 790 | unsigned int links_failed) |
790 | { | 791 | { |
791 | int c_m; | 792 | int c_m; |
792 | int c_s; | 793 | int c_s; |
793 | 794 | ||
794 | GNUNET_assert (NULL == cls); | 795 | GNUNET_assert(NULL == cls); |
795 | GNUNET_assert (top->num_masters + top->num_slaves == num_peers); | 796 | GNUNET_assert(top->num_masters + top->num_slaves == num_peers); |
796 | GNUNET_assert (NULL != peers_); | 797 | GNUNET_assert(NULL != peers_); |
797 | 798 | ||
798 | GNUNET_SCHEDULER_add_shutdown (&do_shutdown, | 799 | GNUNET_SCHEDULER_add_shutdown(&do_shutdown, |
799 | top); | 800 | top); |
800 | 801 | ||
801 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 802 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, |
802 | "Setting up %u masters and %u slaves\n", | 803 | "Setting up %u masters and %u slaves\n", |
803 | top->num_masters, | 804 | top->num_masters, |
804 | top->num_slaves); | 805 | top->num_slaves); |
805 | 806 | ||
806 | /* Setup master peers */ | 807 | /* Setup master peers */ |
807 | for (c_m = 0; c_m < top->num_masters; c_m++) | 808 | for (c_m = 0; c_m < top->num_masters; c_m++) |
808 | { | ||
809 | GNUNET_assert(NULL != peers_[c_m]); | ||
810 | top->mps[c_m].peer = peers_[c_m]; | ||
811 | top->mps[c_m].no = c_m; | ||
812 | top->mps[c_m].master = GNUNET_YES; | ||
813 | top->mps[c_m].pref_partner = &top->sps[c_m]; | ||
814 | top->mps[c_m].pref_value = TEST_ATS_PREFERENCE_DEFAULT; | ||
815 | top->mps[c_m].partners = | ||
816 | GNUNET_malloc (top->num_slaves * sizeof (struct BenchmarkPartner)); | ||
817 | top->mps[c_m].num_partners = top->num_slaves; | ||
818 | /* Initialize partners */ | ||
819 | for (c_s = 0; c_s < top->num_slaves; c_s++) | ||
820 | { | 809 | { |
821 | top->mps[c_m].partners[c_s].me = &top->mps[c_m]; | 810 | GNUNET_assert(NULL != peers_[c_m]); |
822 | top->mps[c_m].partners[c_s].dest = &top->sps[c_s]; | 811 | top->mps[c_m].peer = peers_[c_m]; |
812 | top->mps[c_m].no = c_m; | ||
813 | top->mps[c_m].master = GNUNET_YES; | ||
814 | top->mps[c_m].pref_partner = &top->sps[c_m]; | ||
815 | top->mps[c_m].pref_value = TEST_ATS_PREFERENCE_DEFAULT; | ||
816 | top->mps[c_m].partners = | ||
817 | GNUNET_malloc(top->num_slaves * sizeof(struct BenchmarkPartner)); | ||
818 | top->mps[c_m].num_partners = top->num_slaves; | ||
819 | /* Initialize partners */ | ||
820 | for (c_s = 0; c_s < top->num_slaves; c_s++) | ||
821 | { | ||
822 | top->mps[c_m].partners[c_s].me = &top->mps[c_m]; | ||
823 | top->mps[c_m].partners[c_s].dest = &top->sps[c_s]; | ||
824 | } | ||
825 | /* Get configuration */ | ||
826 | top->mps[c_m].peer_id_op | ||
827 | = GNUNET_TESTBED_peer_get_information(top->mps[c_m].peer, | ||
828 | GNUNET_TESTBED_PIT_IDENTITY, | ||
829 | &peerinformation_cb, | ||
830 | &top->mps[c_m]); | ||
823 | } | 831 | } |
824 | /* Get configuration */ | ||
825 | top->mps[c_m].peer_id_op | ||
826 | = GNUNET_TESTBED_peer_get_information (top->mps[c_m].peer, | ||
827 | GNUNET_TESTBED_PIT_IDENTITY, | ||
828 | &peerinformation_cb, | ||
829 | &top->mps[c_m]); | ||
830 | } | ||
831 | 832 | ||
832 | /* Setup slave peers */ | 833 | /* Setup slave peers */ |
833 | for (c_s = 0; c_s < top->num_slaves; c_s++) | 834 | for (c_s = 0; c_s < top->num_slaves; c_s++) |
834 | { | ||
835 | GNUNET_assert(NULL != peers_[c_s + top->num_masters]); | ||
836 | top->sps[c_s].peer = peers_[c_s + top->num_masters]; | ||
837 | top->sps[c_s].no = c_s + top->num_masters; | ||
838 | top->sps[c_s].master = GNUNET_NO; | ||
839 | top->sps[c_s].partners = | ||
840 | GNUNET_new_array (top->num_masters, | ||
841 | struct BenchmarkPartner); | ||
842 | top->sps[c_s].num_partners = top->num_masters; | ||
843 | /* Initialize partners */ | ||
844 | for (c_m = 0; c_m < top->num_masters; c_m++) | ||
845 | { | 835 | { |
846 | top->sps[c_s].partners[c_m].me = &top->sps[c_s]; | 836 | GNUNET_assert(NULL != peers_[c_s + top->num_masters]); |
847 | top->sps[c_s].partners[c_m].dest = &top->mps[c_m]; | 837 | top->sps[c_s].peer = peers_[c_s + top->num_masters]; |
848 | 838 | top->sps[c_s].no = c_s + top->num_masters; | |
849 | /* Initialize properties */ | 839 | top->sps[c_s].master = GNUNET_NO; |
850 | top->sps[c_s].partners[c_m].props.delay = GNUNET_TIME_UNIT_ZERO; | 840 | top->sps[c_s].partners = |
851 | top->sps[c_s].partners[c_m].props.distance = 0; | 841 | GNUNET_new_array(top->num_masters, |
852 | top->sps[c_s].partners[c_m].props.scope = GNUNET_NT_UNSPECIFIED; | 842 | struct BenchmarkPartner); |
853 | top->sps[c_s].partners[c_m].props.utilization_in = 0; | 843 | top->sps[c_s].num_partners = top->num_masters; |
854 | top->sps[c_s].partners[c_m].props.utilization_out = 0; | 844 | /* Initialize partners */ |
845 | for (c_m = 0; c_m < top->num_masters; c_m++) | ||
846 | { | ||
847 | top->sps[c_s].partners[c_m].me = &top->sps[c_s]; | ||
848 | top->sps[c_s].partners[c_m].dest = &top->mps[c_m]; | ||
849 | |||
850 | /* Initialize properties */ | ||
851 | top->sps[c_s].partners[c_m].props.delay = GNUNET_TIME_UNIT_ZERO; | ||
852 | top->sps[c_s].partners[c_m].props.distance = 0; | ||
853 | top->sps[c_s].partners[c_m].props.scope = GNUNET_NT_UNSPECIFIED; | ||
854 | top->sps[c_s].partners[c_m].props.utilization_in = 0; | ||
855 | top->sps[c_s].partners[c_m].props.utilization_out = 0; | ||
856 | } | ||
857 | /* Get configuration */ | ||
858 | top->sps[c_s].peer_id_op | ||
859 | = GNUNET_TESTBED_peer_get_information(top->sps[c_s].peer, | ||
860 | GNUNET_TESTBED_PIT_IDENTITY, | ||
861 | &peerinformation_cb, | ||
862 | &top->sps[c_s]); | ||
855 | } | 863 | } |
856 | /* Get configuration */ | ||
857 | top->sps[c_s].peer_id_op | ||
858 | = GNUNET_TESTBED_peer_get_information (top->sps[c_s].peer, | ||
859 | GNUNET_TESTBED_PIT_IDENTITY, | ||
860 | &peerinformation_cb, | ||
861 | &top->sps[c_s]); | ||
862 | } | ||
863 | } | 864 | } |
864 | 865 | ||
865 | 866 | ||
@@ -870,24 +871,26 @@ main_run (void *cls, | |||
870 | * @param event the controller event | 871 | * @param event the controller event |
871 | */ | 872 | */ |
872 | static void | 873 | static void |
873 | controller_event_cb (void *cls, | 874 | controller_event_cb(void *cls, |
874 | const struct GNUNET_TESTBED_EventInformation *event) | 875 | const struct GNUNET_TESTBED_EventInformation *event) |
875 | { | 876 | { |
876 | switch (event->type) | 877 | switch (event->type) |
877 | { | 878 | { |
878 | case GNUNET_TESTBED_ET_CONNECT: | 879 | case GNUNET_TESTBED_ET_CONNECT: |
879 | break; | 880 | break; |
880 | case GNUNET_TESTBED_ET_OPERATION_FINISHED: | 881 | |
881 | break; | 882 | case GNUNET_TESTBED_ET_OPERATION_FINISHED: |
882 | default: | 883 | break; |
883 | GNUNET_break(0); | 884 | |
884 | GNUNET_SCHEDULER_shutdown (); | 885 | default: |
885 | } | 886 | GNUNET_break(0); |
887 | GNUNET_SCHEDULER_shutdown(); | ||
888 | } | ||
886 | } | 889 | } |
887 | 890 | ||
888 | 891 | ||
889 | struct BenchmarkPeer * | 892 | struct BenchmarkPeer * |
890 | GNUNET_ATS_TEST_get_peer (int src) | 893 | GNUNET_ATS_TEST_get_peer(int src) |
891 | { | 894 | { |
892 | if (src > top->num_masters) | 895 | if (src > top->num_masters) |
893 | return NULL; | 896 | return NULL; |
@@ -896,8 +899,8 @@ GNUNET_ATS_TEST_get_peer (int src) | |||
896 | 899 | ||
897 | 900 | ||
898 | struct BenchmarkPartner * | 901 | struct BenchmarkPartner * |
899 | GNUNET_ATS_TEST_get_partner (int src, | 902 | GNUNET_ATS_TEST_get_partner(int src, |
900 | int dest) | 903 | int dest) |
901 | { | 904 | { |
902 | if (src > top->num_masters) | 905 | if (src > top->num_masters) |
903 | return NULL; | 906 | return NULL; |
@@ -920,37 +923,37 @@ GNUNET_ATS_TEST_get_partner (int src, | |||
920 | * @param log_request_cb callback to call when logging is required | 923 | * @param log_request_cb callback to call when logging is required |
921 | */ | 924 | */ |
922 | void | 925 | void |
923 | GNUNET_ATS_TEST_create_topology (char *name, char *cfg_file, | 926 | GNUNET_ATS_TEST_create_topology(char *name, char *cfg_file, |
924 | unsigned int num_slaves, | 927 | unsigned int num_slaves, |
925 | unsigned int num_masters, | 928 | unsigned int num_masters, |
926 | int test_core, | 929 | int test_core, |
927 | GNUNET_ATS_TEST_TopologySetupDoneCallback done_cb, | 930 | GNUNET_ATS_TEST_TopologySetupDoneCallback done_cb, |
928 | void *done_cb_cls, | 931 | void *done_cb_cls, |
929 | GNUNET_ATS_AddressInformationCallback log_request_cb) | 932 | GNUNET_ATS_AddressInformationCallback log_request_cb) |
930 | { | 933 | { |
931 | top = GNUNET_new (struct GNUNET_ATS_TEST_Topology); | 934 | top = GNUNET_new(struct GNUNET_ATS_TEST_Topology); |
932 | top->num_masters = num_masters; | 935 | top->num_masters = num_masters; |
933 | top->num_slaves = num_slaves; | 936 | top->num_slaves = num_slaves; |
934 | top->done_cb = done_cb; | 937 | top->done_cb = done_cb; |
935 | top->done_cb_cls = done_cb_cls; | 938 | top->done_cb_cls = done_cb_cls; |
936 | top->test_core = test_core; | 939 | top->test_core = test_core; |
937 | top->ats_perf_cb = log_request_cb; | 940 | top->ats_perf_cb = log_request_cb; |
938 | top->mps = GNUNET_new_array (num_masters, | 941 | top->mps = GNUNET_new_array(num_masters, |
939 | struct BenchmarkPeer); | 942 | struct BenchmarkPeer); |
940 | top->sps = GNUNET_new_array (num_slaves, | 943 | top->sps = GNUNET_new_array(num_slaves, |
941 | struct BenchmarkPeer); | 944 | struct BenchmarkPeer); |
942 | 945 | ||
943 | /* Start topology */ | 946 | /* Start topology */ |
944 | uint64_t event_mask; | 947 | uint64_t event_mask; |
945 | event_mask = 0; | 948 | event_mask = 0; |
946 | event_mask |= (1LL << GNUNET_TESTBED_ET_CONNECT); | 949 | event_mask |= (1LL << GNUNET_TESTBED_ET_CONNECT); |
947 | event_mask |= (1LL << GNUNET_TESTBED_ET_OPERATION_FINISHED); | 950 | event_mask |= (1LL << GNUNET_TESTBED_ET_OPERATION_FINISHED); |
948 | (void) GNUNET_TESTBED_test_run (name, | 951 | (void)GNUNET_TESTBED_test_run(name, |
949 | cfg_file, | 952 | cfg_file, |
950 | num_slaves + num_masters, | 953 | num_slaves + num_masters, |
951 | event_mask, | 954 | event_mask, |
952 | &controller_event_cb, NULL, | 955 | &controller_event_cb, NULL, |
953 | &main_run, NULL); | 956 | &main_run, NULL); |
954 | } | 957 | } |
955 | 958 | ||
956 | 959 | ||
@@ -958,7 +961,7 @@ GNUNET_ATS_TEST_create_topology (char *name, char *cfg_file, | |||
958 | * Shutdown topology | 961 | * Shutdown topology |
959 | */ | 962 | */ |
960 | void | 963 | void |
961 | GNUNET_ATS_TEST_shutdown_topology (void) | 964 | GNUNET_ATS_TEST_shutdown_topology(void) |
962 | { | 965 | { |
963 | if (NULL == top) | 966 | if (NULL == top) |
964 | return; | 967 | return; |
diff --git a/src/ats-tests/ats-testing.h b/src/ats-tests/ats-testing.h index f6df5a9bd..ff3a40837 100644 --- a/src/ats-tests/ats-testing.h +++ b/src/ats-tests/ats-testing.h | |||
@@ -1,19 +1,19 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2010-2013 GNUnet e.V. | 3 | Copyright (C) 2010-2013 GNUnet e.V. |
4 | 4 | ||
5 | GNUnet is free software: you can redistribute it and/or modify it | 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 | 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, | 7 | by the Free Software Foundation, either version 3 of the License, |
8 | or (at your option) any later version. | 8 | or (at your option) any later version. |
9 | 9 | ||
10 | GNUnet is distributed in the hope that it will be useful, but | 10 | GNUnet is distributed in the hope that it will be useful, but |
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Affero General Public License for more details. | 13 | Affero General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Affero General Public License | 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/>. | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | 17 | ||
18 | SPDX-License-Identifier: AGPL3.0-or-later | 18 | SPDX-License-Identifier: AGPL3.0-or-later |
19 | */ | 19 | */ |
@@ -48,11 +48,10 @@ | |||
48 | #define TEST_MESSAGE_SIZE 100 | 48 | #define TEST_MESSAGE_SIZE 100 |
49 | 49 | ||
50 | 50 | ||
51 | struct TestMessage | 51 | struct TestMessage { |
52 | { | ||
53 | struct GNUNET_MessageHeader header; | 52 | struct GNUNET_MessageHeader header; |
54 | 53 | ||
55 | uint8_t padding[TEST_MESSAGE_SIZE - sizeof (struct GNUNET_MessageHeader)]; | 54 | uint8_t padding[TEST_MESSAGE_SIZE - sizeof(struct GNUNET_MessageHeader)]; |
56 | }; | 55 | }; |
57 | 56 | ||
58 | 57 | ||
@@ -66,8 +65,7 @@ struct TrafficGenerator; | |||
66 | 65 | ||
67 | struct LoggingHandle; | 66 | struct LoggingHandle; |
68 | 67 | ||
69 | enum GeneratorType | 68 | enum GeneratorType { |
70 | { | ||
71 | GNUNET_ATS_TEST_TG_LINEAR, | 69 | GNUNET_ATS_TEST_TG_LINEAR, |
72 | GNUNET_ATS_TEST_TG_CONSTANT, | 70 | GNUNET_ATS_TEST_TG_CONSTANT, |
73 | GNUNET_ATS_TEST_TG_RANDOM, | 71 | GNUNET_ATS_TEST_TG_RANDOM, |
@@ -108,8 +106,7 @@ typedef void (*GNUNET_ATS_TEST_LogRequest) ( | |||
108 | /** | 106 | /** |
109 | * Information we track for a peer in the testbed. | 107 | * Information we track for a peer in the testbed. |
110 | */ | 108 | */ |
111 | struct BenchmarkPeer | 109 | struct BenchmarkPeer { |
112 | { | ||
113 | /** | 110 | /** |
114 | * Handle with testbed. | 111 | * Handle with testbed. |
115 | */ | 112 | */ |
@@ -227,8 +224,7 @@ struct BenchmarkPeer | |||
227 | unsigned int total_bytes_received; | 224 | unsigned int total_bytes_received; |
228 | }; | 225 | }; |
229 | 226 | ||
230 | struct TrafficGenerator | 227 | struct TrafficGenerator { |
231 | { | ||
232 | struct TrafficGenerator *prev; | 228 | struct TrafficGenerator *prev; |
233 | struct TrafficGenerator *next; | 229 | struct TrafficGenerator *next; |
234 | 230 | ||
@@ -247,8 +243,7 @@ struct TrafficGenerator | |||
247 | }; | 243 | }; |
248 | 244 | ||
249 | 245 | ||
250 | struct PreferenceGenerator | 246 | struct PreferenceGenerator { |
251 | { | ||
252 | struct PreferenceGenerator *prev; | 247 | struct PreferenceGenerator *prev; |
253 | struct PreferenceGenerator *next; | 248 | struct PreferenceGenerator *next; |
254 | 249 | ||
@@ -272,8 +267,7 @@ struct PreferenceGenerator | |||
272 | /** | 267 | /** |
273 | * Information about a benchmarking partner | 268 | * Information about a benchmarking partner |
274 | */ | 269 | */ |
275 | struct BenchmarkPartner | 270 | struct BenchmarkPartner { |
276 | { | ||
277 | /** | 271 | /** |
278 | * The peer itself this partner belongs to | 272 | * The peer itself this partner belongs to |
279 | */ | 273 | */ |
@@ -359,8 +353,7 @@ struct BenchmarkPartner | |||
359 | /** | 353 | /** |
360 | * Overall state of the performance benchmark | 354 | * Overall state of the performance benchmark |
361 | */ | 355 | */ |
362 | struct BenchmarkState | 356 | struct BenchmarkState { |
363 | { | ||
364 | /** | 357 | /** |
365 | * Are we connected to ATS service of all peers: GNUNET_YES/NO | 358 | * Are we connected to ATS service of all peers: GNUNET_YES/NO |
366 | */ | 359 | */ |
@@ -388,8 +381,7 @@ struct BenchmarkState | |||
388 | }; | 381 | }; |
389 | 382 | ||
390 | 383 | ||
391 | struct GNUNET_ATS_TEST_Topology | 384 | struct GNUNET_ATS_TEST_Topology { |
392 | { | ||
393 | /** | 385 | /** |
394 | * Progress task | 386 | * Progress task |
395 | */ | 387 | */ |
@@ -467,8 +459,7 @@ struct GNUNET_ATS_TEST_Topology | |||
467 | void *done_cb_cls; | 459 | void *done_cb_cls; |
468 | }; | 460 | }; |
469 | 461 | ||
470 | enum OperationType | 462 | enum OperationType { |
471 | { | ||
472 | START_SEND, | 463 | START_SEND, |
473 | STOP_SEND, | 464 | STOP_SEND, |
474 | START_PREFERENCE, | 465 | START_PREFERENCE, |
@@ -489,8 +480,7 @@ typedef void (*GNUNET_ATS_TESTING_ExperimentDoneCallback) ( | |||
489 | /** | 480 | /** |
490 | * An operation in an experiment | 481 | * An operation in an experiment |
491 | */ | 482 | */ |
492 | struct GNUNET_ATS_TEST_Operation | 483 | struct GNUNET_ATS_TEST_Operation { |
493 | { | ||
494 | struct GNUNET_ATS_TEST_Operation *next; | 484 | struct GNUNET_ATS_TEST_Operation *next; |
495 | struct GNUNET_ATS_TEST_Operation *prev; | 485 | struct GNUNET_ATS_TEST_Operation *prev; |
496 | 486 | ||
@@ -507,8 +497,7 @@ struct GNUNET_ATS_TEST_Operation | |||
507 | enum GNUNET_ATS_PreferenceKind pref_type; | 497 | enum GNUNET_ATS_PreferenceKind pref_type; |
508 | }; | 498 | }; |
509 | 499 | ||
510 | struct Episode | 500 | struct Episode { |
511 | { | ||
512 | int id; | 501 | int id; |
513 | struct Episode *next; | 502 | struct Episode *next; |
514 | struct GNUNET_TIME_Relative duration; | 503 | struct GNUNET_TIME_Relative duration; |
@@ -518,8 +507,7 @@ struct Episode | |||
518 | }; | 507 | }; |
519 | 508 | ||
520 | 509 | ||
521 | struct Experiment | 510 | struct Experiment { |
522 | { | ||
523 | char *name; | 511 | char *name; |
524 | char *cfg_file; | 512 | char *cfg_file; |
525 | unsigned long long int num_masters; | 513 | unsigned long long int num_masters; |
@@ -550,7 +538,7 @@ extern struct GNUNET_CONFIGURATION_Handle *cfg; | |||
550 | * @param e_done_cb the experiment is completed | 538 | * @param e_done_cb the experiment is completed |
551 | */ | 539 | */ |
552 | void | 540 | void |
553 | GNUNET_ATS_TEST_experimentation_run ( | 541 | GNUNET_ATS_TEST_experimentation_run( |
554 | struct Experiment *e, | 542 | struct Experiment *e, |
555 | GNUNET_ATS_TESTING_EpisodeDoneCallback ep_done_cb, | 543 | GNUNET_ATS_TESTING_EpisodeDoneCallback ep_done_cb, |
556 | GNUNET_ATS_TESTING_ExperimentDoneCallback e_done_cb); | 544 | GNUNET_ATS_TESTING_ExperimentDoneCallback e_done_cb); |
@@ -563,7 +551,7 @@ GNUNET_ATS_TEST_experimentation_run ( | |||
563 | * @return the Experiment or NULL on failure | 551 | * @return the Experiment or NULL on failure |
564 | */ | 552 | */ |
565 | struct Experiment * | 553 | struct Experiment * |
566 | GNUNET_ATS_TEST_experimentation_load (const char *filename); | 554 | GNUNET_ATS_TEST_experimentation_load(const char *filename); |
567 | 555 | ||
568 | 556 | ||
569 | /** | 557 | /** |
@@ -572,15 +560,15 @@ GNUNET_ATS_TEST_experimentation_load (const char *filename); | |||
572 | * @param e the experiment | 560 | * @param e the experiment |
573 | */ | 561 | */ |
574 | void | 562 | void |
575 | GNUNET_ATS_TEST_experimentation_stop (struct Experiment *e); | 563 | GNUNET_ATS_TEST_experimentation_stop(struct Experiment *e); |
576 | 564 | ||
577 | 565 | ||
578 | void | 566 | void |
579 | GNUNET_ATS_TEST_traffic_handle_ping (struct BenchmarkPartner *p); | 567 | GNUNET_ATS_TEST_traffic_handle_ping(struct BenchmarkPartner *p); |
580 | 568 | ||
581 | 569 | ||
582 | void | 570 | void |
583 | GNUNET_ATS_TEST_traffic_handle_pong (struct BenchmarkPartner *p); | 571 | GNUNET_ATS_TEST_traffic_handle_pong(struct BenchmarkPartner *p); |
584 | 572 | ||
585 | 573 | ||
586 | /** | 574 | /** |
@@ -597,24 +585,24 @@ GNUNET_ATS_TEST_traffic_handle_pong (struct BenchmarkPartner *p); | |||
597 | * @return the traffic generator | 585 | * @return the traffic generator |
598 | */ | 586 | */ |
599 | struct TrafficGenerator * | 587 | struct TrafficGenerator * |
600 | GNUNET_ATS_TEST_generate_traffic_start (struct BenchmarkPeer *src, | 588 | GNUNET_ATS_TEST_generate_traffic_start(struct BenchmarkPeer *src, |
601 | struct BenchmarkPartner *dest, | 589 | struct BenchmarkPartner *dest, |
602 | enum GeneratorType type, | 590 | enum GeneratorType type, |
603 | unsigned int base_rate, | 591 | unsigned int base_rate, |
604 | unsigned int max_rate, | 592 | unsigned int max_rate, |
605 | struct GNUNET_TIME_Relative period, | 593 | struct GNUNET_TIME_Relative period, |
606 | struct GNUNET_TIME_Relative duration); | 594 | struct GNUNET_TIME_Relative duration); |
607 | 595 | ||
608 | 596 | ||
609 | void | 597 | void |
610 | GNUNET_ATS_TEST_generate_traffic_stop (struct TrafficGenerator *tg); | 598 | GNUNET_ATS_TEST_generate_traffic_stop(struct TrafficGenerator *tg); |
611 | 599 | ||
612 | 600 | ||
613 | /** | 601 | /** |
614 | * Stop all traffic generators | 602 | * Stop all traffic generators |
615 | */ | 603 | */ |
616 | void | 604 | void |
617 | GNUNET_ATS_TEST_generate_traffic_stop_all (void); | 605 | GNUNET_ATS_TEST_generate_traffic_stop_all(void); |
618 | 606 | ||
619 | 607 | ||
620 | /** | 608 | /** |
@@ -632,7 +620,7 @@ GNUNET_ATS_TEST_generate_traffic_stop_all (void); | |||
632 | * @return the traffic generator | 620 | * @return the traffic generator |
633 | */ | 621 | */ |
634 | struct PreferenceGenerator * | 622 | struct PreferenceGenerator * |
635 | GNUNET_ATS_TEST_generate_preferences_start ( | 623 | GNUNET_ATS_TEST_generate_preferences_start( |
636 | struct BenchmarkPeer *src, | 624 | struct BenchmarkPeer *src, |
637 | struct BenchmarkPartner *dest, | 625 | struct BenchmarkPartner *dest, |
638 | enum GeneratorType type, | 626 | enum GeneratorType type, |
@@ -644,11 +632,11 @@ GNUNET_ATS_TEST_generate_preferences_start ( | |||
644 | 632 | ||
645 | 633 | ||
646 | void | 634 | void |
647 | GNUNET_ATS_TEST_generate_preferences_stop (struct PreferenceGenerator *pg); | 635 | GNUNET_ATS_TEST_generate_preferences_stop(struct PreferenceGenerator *pg); |
648 | 636 | ||
649 | 637 | ||
650 | void | 638 | void |
651 | GNUNET_ATS_TEST_generate_preferences_stop_all (void); | 639 | GNUNET_ATS_TEST_generate_preferences_stop_all(void); |
652 | 640 | ||
653 | 641 | ||
654 | /** | 642 | /** |
@@ -663,12 +651,12 @@ GNUNET_ATS_TEST_generate_preferences_stop_all (void); | |||
663 | * @return the logging handle or NULL on error | 651 | * @return the logging handle or NULL on error |
664 | */ | 652 | */ |
665 | struct LoggingHandle * | 653 | struct LoggingHandle * |
666 | GNUNET_ATS_TEST_logging_start (struct GNUNET_TIME_Relative log_frequency, | 654 | GNUNET_ATS_TEST_logging_start(struct GNUNET_TIME_Relative log_frequency, |
667 | const char *testname, | 655 | const char *testname, |
668 | struct BenchmarkPeer *masters, | 656 | struct BenchmarkPeer *masters, |
669 | int num_masters, | 657 | int num_masters, |
670 | int num_slaves, | 658 | int num_slaves, |
671 | int verbose); | 659 | int verbose); |
672 | 660 | ||
673 | 661 | ||
674 | /** | 662 | /** |
@@ -677,7 +665,7 @@ GNUNET_ATS_TEST_logging_start (struct GNUNET_TIME_Relative log_frequency, | |||
677 | * @param l the logging handle | 665 | * @param l the logging handle |
678 | */ | 666 | */ |
679 | void | 667 | void |
680 | GNUNET_ATS_TEST_logging_clean_up (struct LoggingHandle *l); | 668 | GNUNET_ATS_TEST_logging_clean_up(struct LoggingHandle *l); |
681 | 669 | ||
682 | 670 | ||
683 | /** | 671 | /** |
@@ -686,7 +674,7 @@ GNUNET_ATS_TEST_logging_clean_up (struct LoggingHandle *l); | |||
686 | * @param l the logging handle | 674 | * @param l the logging handle |
687 | */ | 675 | */ |
688 | void | 676 | void |
689 | GNUNET_ATS_TEST_logging_stop (struct LoggingHandle *l); | 677 | GNUNET_ATS_TEST_logging_stop(struct LoggingHandle *l); |
690 | 678 | ||
691 | 679 | ||
692 | /** | 680 | /** |
@@ -695,7 +683,7 @@ GNUNET_ATS_TEST_logging_stop (struct LoggingHandle *l); | |||
695 | * @param l logging handle to use | 683 | * @param l logging handle to use |
696 | */ | 684 | */ |
697 | void | 685 | void |
698 | GNUNET_ATS_TEST_logging_now (struct LoggingHandle *l); | 686 | GNUNET_ATS_TEST_logging_now(struct LoggingHandle *l); |
699 | 687 | ||
700 | 688 | ||
701 | /** | 689 | /** |
@@ -706,20 +694,20 @@ GNUNET_ATS_TEST_logging_now (struct LoggingHandle *l); | |||
706 | * @param plots create gnuplots: #GNUNET_YES or #GNUNET_NO | 694 | * @param plots create gnuplots: #GNUNET_YES or #GNUNET_NO |
707 | */ | 695 | */ |
708 | void | 696 | void |
709 | GNUNET_ATS_TEST_logging_write_to_file (struct LoggingHandle *l, | 697 | GNUNET_ATS_TEST_logging_write_to_file(struct LoggingHandle *l, |
710 | const char *test_name, | 698 | const char *test_name, |
711 | int plots); | 699 | int plots); |
712 | 700 | ||
713 | 701 | ||
714 | /** | 702 | /** |
715 | * Topology related functions | 703 | * Topology related functions |
716 | */ | 704 | */ |
717 | struct BenchmarkPeer * | 705 | struct BenchmarkPeer * |
718 | GNUNET_ATS_TEST_get_peer (int src); | 706 | GNUNET_ATS_TEST_get_peer(int src); |
719 | 707 | ||
720 | 708 | ||
721 | struct BenchmarkPartner * | 709 | struct BenchmarkPartner * |
722 | GNUNET_ATS_TEST_get_partner (int src, int dest); | 710 | GNUNET_ATS_TEST_get_partner(int src, int dest); |
723 | 711 | ||
724 | 712 | ||
725 | /** | 713 | /** |
@@ -736,7 +724,7 @@ GNUNET_ATS_TEST_get_partner (int src, int dest); | |||
736 | * @param log_request_cb callback to call when logging is required | 724 | * @param log_request_cb callback to call when logging is required |
737 | */ | 725 | */ |
738 | void | 726 | void |
739 | GNUNET_ATS_TEST_create_topology ( | 727 | GNUNET_ATS_TEST_create_topology( |
740 | char *name, | 728 | char *name, |
741 | char *cfg_file, | 729 | char *cfg_file, |
742 | unsigned int num_slaves, | 730 | unsigned int num_slaves, |
@@ -751,7 +739,7 @@ GNUNET_ATS_TEST_create_topology ( | |||
751 | * Shutdown topology | 739 | * Shutdown topology |
752 | */ | 740 | */ |
753 | void | 741 | void |
754 | GNUNET_ATS_TEST_shutdown_topology (void); | 742 | GNUNET_ATS_TEST_shutdown_topology(void); |
755 | 743 | ||
756 | 744 | ||
757 | /* end of file ats-testing.h */ | 745 | /* end of file ats-testing.h */ |
diff --git a/src/ats-tests/gnunet-ats-sim.c b/src/ats-tests/gnunet-ats-sim.c index af0eff534..d6168d388 100644 --- a/src/ats-tests/gnunet-ats-sim.c +++ b/src/ats-tests/gnunet-ats-sim.c | |||
@@ -1,19 +1,19 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2010-2013 GNUnet e.V. | 3 | Copyright (C) 2010-2013 GNUnet e.V. |
4 | 4 | ||
5 | GNUnet is free software: you can redistribute it and/or modify it | 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 | 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, | 7 | by the Free Software Foundation, either version 3 of the License, |
8 | or (at your option) any later version. | 8 | or (at your option) any later version. |
9 | 9 | ||
10 | GNUnet is distributed in the hope that it will be useful, but | 10 | GNUnet is distributed in the hope that it will be useful, but |
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Affero General Public License for more details. | 13 | Affero General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Affero General Public License | 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/>. | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | 17 | ||
18 | SPDX-License-Identifier: AGPL3.0-or-later | 18 | SPDX-License-Identifier: AGPL3.0-or-later |
19 | */ | 19 | */ |
@@ -32,7 +32,7 @@ | |||
32 | #include "gnunet_core_service.h" | 32 | #include "gnunet_core_service.h" |
33 | #include "ats-testing.h" | 33 | #include "ats-testing.h" |
34 | 34 | ||
35 | #define TEST_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10) | 35 | #define TEST_TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 10) |
36 | 36 | ||
37 | static struct BenchmarkPeer *masters_p; | 37 | static struct BenchmarkPeer *masters_p; |
38 | static struct BenchmarkPeer *slaves_p; | 38 | static struct BenchmarkPeer *slaves_p; |
@@ -65,7 +65,7 @@ static struct LoggingHandle *l; | |||
65 | 65 | ||
66 | 66 | ||
67 | static void | 67 | static void |
68 | evaluate (struct GNUNET_TIME_Relative duration_total) | 68 | evaluate(struct GNUNET_TIME_Relative duration_total) |
69 | { | 69 | { |
70 | int c_m; | 70 | int c_m; |
71 | int c_s; | 71 | int c_s; |
@@ -84,312 +84,313 @@ evaluate (struct GNUNET_TIME_Relative duration_total) | |||
84 | if (0 == duration) | 84 | if (0 == duration) |
85 | duration = 1; | 85 | duration = 1; |
86 | for (c_m = 0; c_m < e->num_masters; c_m++) | 86 | for (c_m = 0; c_m < e->num_masters; c_m++) |
87 | { | ||
88 | mp = &masters_p[c_m]; | ||
89 | fprintf (stderr, | ||
90 | _("Master [%u]: sent: %u KiB in %u sec. = %u KiB/s, received: %u KiB in %u sec. = %u KiB/s\n"), | ||
91 | mp->no, mp->total_bytes_sent / 1024, | ||
92 | duration, | ||
93 | (mp->total_bytes_sent / 1024) / duration, | ||
94 | mp->total_bytes_received / 1024, | ||
95 | duration, | ||
96 | (mp->total_bytes_received / 1024) / duration); | ||
97 | |||
98 | for (c_s = 0; c_s < e->num_slaves; c_s++) | ||
99 | { | 87 | { |
100 | p = &mp->partners[c_s]; | 88 | mp = &masters_p[c_m]; |
101 | 89 | fprintf(stderr, | |
102 | b_sent_sec = 0; | 90 | _("Master [%u]: sent: %u KiB in %u sec. = %u KiB/s, received: %u KiB in %u sec. = %u KiB/s\n"), |
103 | b_recv_sec = 0; | 91 | mp->no, mp->total_bytes_sent / 1024, |
104 | kb_sent_percent = 0.0; | 92 | duration, |
105 | kb_recv_percent = 0.0; | 93 | (mp->total_bytes_sent / 1024) / duration, |
106 | rtt = 0; | 94 | mp->total_bytes_received / 1024, |
107 | 95 | duration, | |
108 | if (duration > 0) | 96 | (mp->total_bytes_received / 1024) / duration); |
109 | { | 97 | |
110 | b_sent_sec = p->bytes_sent / duration; | 98 | for (c_s = 0; c_s < e->num_slaves; c_s++) |
111 | b_recv_sec = p->bytes_received / duration; | 99 | { |
112 | } | 100 | p = &mp->partners[c_s]; |
113 | 101 | ||
114 | if (mp->total_bytes_sent > 0) | 102 | b_sent_sec = 0; |
115 | kb_sent_percent = ((double) p->bytes_sent * 100) / mp->total_bytes_sent; | 103 | b_recv_sec = 0; |
116 | if (mp->total_bytes_received > 0) | 104 | kb_sent_percent = 0.0; |
117 | kb_recv_percent = ((double) p->bytes_received * 100) / mp->total_bytes_received; | 105 | kb_recv_percent = 0.0; |
118 | if (1000 * p->messages_sent > 0) | 106 | rtt = 0; |
119 | rtt = p->total_app_rtt / (1000 * p->messages_sent); | 107 | |
120 | fprintf (stderr, | 108 | if (duration > 0) |
121 | "%c Master [%u] -> Slave [%u]: sent %u Bips (%.2f %%), received %u Bips (%.2f %%)\n", | 109 | { |
122 | (mp->pref_partner == p->dest) ? '*' : ' ', | 110 | b_sent_sec = p->bytes_sent / duration; |
123 | mp->no, p->dest->no, | 111 | b_recv_sec = p->bytes_received / duration; |
124 | b_sent_sec, kb_sent_percent, | 112 | } |
113 | |||
114 | if (mp->total_bytes_sent > 0) | ||
115 | kb_sent_percent = ((double)p->bytes_sent * 100) / mp->total_bytes_sent; | ||
116 | if (mp->total_bytes_received > 0) | ||
117 | kb_recv_percent = ((double)p->bytes_received * 100) / mp->total_bytes_received; | ||
118 | if (1000 * p->messages_sent > 0) | ||
119 | rtt = p->total_app_rtt / (1000 * p->messages_sent); | ||
120 | fprintf(stderr, | ||
121 | "%c Master [%u] -> Slave [%u]: sent %u Bips (%.2f %%), received %u Bips (%.2f %%)\n", | ||
122 | (mp->pref_partner == p->dest) ? '*' : ' ', | ||
123 | mp->no, p->dest->no, | ||
124 | b_sent_sec, kb_sent_percent, | ||
125 | b_recv_sec, kb_recv_percent); | 125 | b_recv_sec, kb_recv_percent); |
126 | fprintf (stderr, | 126 | fprintf(stderr, |
127 | "%c Master [%u] -> Slave [%u]: Average application layer RTT: %u ms\n", | 127 | "%c Master [%u] -> Slave [%u]: Average application layer RTT: %u ms\n", |
128 | (mp->pref_partner == p->dest) ? '*' : ' ', | 128 | (mp->pref_partner == p->dest) ? '*' : ' ', |
129 | mp->no, p->dest->no, rtt); | 129 | mp->no, p->dest->no, rtt); |
130 | } | ||
130 | } | 131 | } |
131 | } | ||
132 | } | 132 | } |
133 | 133 | ||
134 | 134 | ||
135 | static void | 135 | static void |
136 | do_shutdown (void *cls) | 136 | do_shutdown(void *cls) |
137 | { | 137 | { |
138 | fprintf (stderr, "Shutdown\n"); | 138 | fprintf(stderr, "Shutdown\n"); |
139 | if (NULL != timeout_task) | 139 | if (NULL != timeout_task) |
140 | { | 140 | { |
141 | GNUNET_SCHEDULER_cancel (timeout_task); | 141 | GNUNET_SCHEDULER_cancel(timeout_task); |
142 | timeout_task = NULL; | 142 | timeout_task = NULL; |
143 | } | 143 | } |
144 | if (NULL != l) | 144 | if (NULL != l) |
145 | { | 145 | { |
146 | GNUNET_ATS_TEST_logging_stop (l); | 146 | GNUNET_ATS_TEST_logging_stop(l); |
147 | GNUNET_ATS_TEST_logging_clean_up (l); | 147 | GNUNET_ATS_TEST_logging_clean_up(l); |
148 | l = NULL; | 148 | l = NULL; |
149 | } | 149 | } |
150 | 150 | ||
151 | /* Stop traffic generation */ | 151 | /* Stop traffic generation */ |
152 | GNUNET_ATS_TEST_generate_traffic_stop_all(); | 152 | GNUNET_ATS_TEST_generate_traffic_stop_all(); |
153 | 153 | ||
154 | /* Stop all preference generations */ | 154 | /* Stop all preference generations */ |
155 | GNUNET_ATS_TEST_generate_preferences_stop_all (); | 155 | GNUNET_ATS_TEST_generate_preferences_stop_all(); |
156 | 156 | ||
157 | if (NULL != e) | 157 | if (NULL != e) |
158 | { | 158 | { |
159 | GNUNET_ATS_TEST_experimentation_stop (e); | 159 | GNUNET_ATS_TEST_experimentation_stop(e); |
160 | e = NULL; | 160 | e = NULL; |
161 | } | 161 | } |
162 | GNUNET_ATS_TEST_shutdown_topology (); | 162 | GNUNET_ATS_TEST_shutdown_topology(); |
163 | } | 163 | } |
164 | 164 | ||
165 | 165 | ||
166 | static void | 166 | static void |
167 | do_timeout (void *cls) | 167 | do_timeout(void *cls) |
168 | { | 168 | { |
169 | timeout_task = NULL; | 169 | timeout_task = NULL; |
170 | GNUNET_SCHEDULER_shutdown (); | 170 | GNUNET_SCHEDULER_shutdown(); |
171 | } | 171 | } |
172 | 172 | ||
173 | 173 | ||
174 | static void | 174 | static void |
175 | log_request__cb (void *cls, | 175 | log_request__cb(void *cls, |
176 | const struct GNUNET_HELLO_Address *address, | 176 | const struct GNUNET_HELLO_Address *address, |
177 | int address_active, | 177 | int address_active, |
178 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, | 178 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, |
179 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, | 179 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, |
180 | const struct GNUNET_ATS_Properties *ats) | 180 | const struct GNUNET_ATS_Properties *ats) |
181 | { | 181 | { |
182 | if (NULL != l) | 182 | if (NULL != l) |
183 | { | 183 | { |
184 | //GNUNET_break (0); | 184 | //GNUNET_break (0); |
185 | //GNUNET_ATS_TEST_logging_now (l); | 185 | //GNUNET_ATS_TEST_logging_now (l); |
186 | } | 186 | } |
187 | } | 187 | } |
188 | 188 | ||
189 | 189 | ||
190 | static void | 190 | static void |
191 | experiment_done_cb (struct Experiment *e, | 191 | experiment_done_cb(struct Experiment *e, |
192 | struct GNUNET_TIME_Relative duration, | 192 | struct GNUNET_TIME_Relative duration, |
193 | int success) | 193 | int success) |
194 | { | 194 | { |
195 | if (GNUNET_OK == success) | 195 | if (GNUNET_OK == success) |
196 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 196 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, |
197 | "Experiment done successful in %s\n", | 197 | "Experiment done successful in %s\n", |
198 | GNUNET_STRINGS_relative_time_to_string (duration, | 198 | GNUNET_STRINGS_relative_time_to_string(duration, |
199 | GNUNET_YES)); | 199 | GNUNET_YES)); |
200 | else | 200 | else |
201 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Experiment failed \n"); | 201 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Experiment failed \n"); |
202 | 202 | ||
203 | /* Stop logging */ | 203 | /* Stop logging */ |
204 | GNUNET_ATS_TEST_logging_stop (l); | 204 | GNUNET_ATS_TEST_logging_stop(l); |
205 | 205 | ||
206 | /* Stop traffic generation */ | 206 | /* Stop traffic generation */ |
207 | GNUNET_ATS_TEST_generate_traffic_stop_all(); | 207 | GNUNET_ATS_TEST_generate_traffic_stop_all(); |
208 | 208 | ||
209 | /* Stop all preference generations */ | 209 | /* Stop all preference generations */ |
210 | GNUNET_ATS_TEST_generate_preferences_stop_all (); | 210 | GNUNET_ATS_TEST_generate_preferences_stop_all(); |
211 | 211 | ||
212 | evaluate (duration); | 212 | evaluate(duration); |
213 | if (opt_log) | 213 | if (opt_log) |
214 | GNUNET_ATS_TEST_logging_write_to_file(l, opt_exp_file, opt_plot); | 214 | GNUNET_ATS_TEST_logging_write_to_file(l, opt_exp_file, opt_plot); |
215 | GNUNET_SCHEDULER_shutdown (); | 215 | GNUNET_SCHEDULER_shutdown(); |
216 | } | 216 | } |
217 | 217 | ||
218 | 218 | ||
219 | static void | 219 | static void |
220 | episode_done_cb (struct Episode *ep) | 220 | episode_done_cb(struct Episode *ep) |
221 | { | 221 | { |
222 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 222 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, |
223 | "Episode %u done\n", | 223 | "Episode %u done\n", |
224 | ep->id); | 224 | ep->id); |
225 | } | 225 | } |
226 | 226 | ||
227 | 227 | ||
228 | static void | 228 | static void |
229 | topology_setup_done (void *cls, | 229 | topology_setup_done(void *cls, |
230 | struct BenchmarkPeer *masters, | 230 | struct BenchmarkPeer *masters, |
231 | struct BenchmarkPeer *slaves) | 231 | struct BenchmarkPeer *slaves) |
232 | { | 232 | { |
233 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 233 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, |
234 | "Topology setup complete!\n"); | 234 | "Topology setup complete!\n"); |
235 | 235 | ||
236 | masters_p = masters; | 236 | masters_p = masters; |
237 | slaves_p = slaves; | 237 | slaves_p = slaves; |
238 | 238 | ||
239 | l = GNUNET_ATS_TEST_logging_start (e->log_freq, | 239 | l = GNUNET_ATS_TEST_logging_start(e->log_freq, |
240 | e->name, | 240 | e->name, |
241 | masters_p, | 241 | masters_p, |
242 | e->num_masters, e->num_slaves, | 242 | e->num_masters, e->num_slaves, |
243 | opt_verbose); | 243 | opt_verbose); |
244 | GNUNET_ATS_TEST_experimentation_run (e, | 244 | GNUNET_ATS_TEST_experimentation_run(e, |
245 | &episode_done_cb, | 245 | &episode_done_cb, |
246 | &experiment_done_cb); | 246 | &experiment_done_cb); |
247 | /* | 247 | /* |
248 | GNUNET_ATS_TEST_generate_preferences_start(&masters[0],&masters[0].partners[0], | 248 | GNUNET_ATS_TEST_generate_preferences_start(&masters[0],&masters[0].partners[0], |
249 | GNUNET_ATS_TEST_TG_CONSTANT, 1, 1, GNUNET_TIME_UNIT_SECONDS, | 249 | GNUNET_ATS_TEST_TG_CONSTANT, 1, 1, GNUNET_TIME_UNIT_SECONDS, |
250 | GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 250), | 250 | GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 250), |
251 | GNUNET_ATS_PREFERENCE_BANDWIDTH); | 251 | GNUNET_ATS_PREFERENCE_BANDWIDTH); |
252 | */ | 252 | */ |
253 | /* | 253 | /* |
254 | GNUNET_ATS_TEST_generate_preferences_start(&masters[0],&masters[0].partners[0], | 254 | GNUNET_ATS_TEST_generate_preferences_start(&masters[0],&masters[0].partners[0], |
255 | GNUNET_ATS_TEST_TG_LINEAR, 1, 50, | 255 | GNUNET_ATS_TEST_TG_LINEAR, 1, 50, |
256 | GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 2), | 256 | GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 2), |
257 | GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 250), | 257 | GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 250), |
258 | GNUNET_ATS_PREFERENCE_BANDWIDTH); | 258 | GNUNET_ATS_PREFERENCE_BANDWIDTH); |
259 | */ | 259 | */ |
260 | /* | 260 | /* |
261 | GNUNET_ATS_TEST_generate_preferences_start(&masters[0],&masters[0].partners[0], | 261 | GNUNET_ATS_TEST_generate_preferences_start(&masters[0],&masters[0].partners[0], |
262 | GNUNET_ATS_TEST_TG_RANDOM, 1, 50, | 262 | GNUNET_ATS_TEST_TG_RANDOM, 1, 50, |
263 | GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 2), | 263 | GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 2), |
264 | GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 250), | 264 | GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 250), |
265 | GNUNET_ATS_PREFERENCE_BANDWIDTH); | 265 | GNUNET_ATS_PREFERENCE_BANDWIDTH); |
266 | */ | 266 | */ |
267 | /* | 267 | /* |
268 | GNUNET_ATS_TEST_generate_preferences_start(&masters[0],&masters[0].partners[0], | 268 | GNUNET_ATS_TEST_generate_preferences_start(&masters[0],&masters[0].partners[0], |
269 | GNUNET_ATS_TEST_TG_SINUS, 10, 5, | 269 | GNUNET_ATS_TEST_TG_SINUS, 10, 5, |
270 | GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 5), | 270 | GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 5), |
271 | GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 250), | 271 | GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 250), |
272 | GNUNET_ATS_PREFERENCE_BANDWIDTH); | 272 | GNUNET_ATS_PREFERENCE_BANDWIDTH); |
273 | */ | 273 | */ |
274 | #if 0 | 274 | #if 0 |
275 | int c_m; | 275 | int c_m; |
276 | int c_s; | 276 | int c_s; |
277 | for (c_m = 0; c_m < e->num_masters; c_m++) | 277 | for (c_m = 0; c_m < e->num_masters; c_m++) |
278 | { | 278 | { |
279 | for (c_s = 0; c_s < e->num_slaves; c_s++) | 279 | for (c_s = 0; c_s < e->num_slaves; c_s++) |
280 | { | 280 | { |
281 | /* Generate maximum traffic to all peers */ | 281 | /* Generate maximum traffic to all peers */ |
282 | /* Example: Generate traffic with constant 10,000 Bytes/s */ | 282 | /* Example: Generate traffic with constant 10,000 Bytes/s */ |
283 | GNUNET_ATS_TEST_generate_traffic_start (&masters[c_m], | 283 | GNUNET_ATS_TEST_generate_traffic_start(&masters[c_m], |
284 | &masters[c_m].partners[c_s], | 284 | &masters[c_m].partners[c_s], |
285 | GNUNET_ATS_TEST_TG_CONSTANT, | 285 | GNUNET_ATS_TEST_TG_CONSTANT, |
286 | 10000, | 286 | 10000, |
287 | GNUNET_TIME_UNIT_FOREVER_REL); | 287 | GNUNET_TIME_UNIT_FOREVER_REL); |
288 | /* Example: Generate traffic with an increasing rate from 1000 to 2000 | 288 | /* Example: Generate traffic with an increasing rate from 1000 to 2000 |
289 | * Bytes/s with in a minute */ | 289 | * Bytes/s with in a minute */ |
290 | GNUNET_ATS_TEST_generate_traffic_start (&masters[c_m], | 290 | GNUNET_ATS_TEST_generate_traffic_start(&masters[c_m], |
291 | &masters[c_m].partners[c_s], | 291 | &masters[c_m].partners[c_s], |
292 | GNUNET_ATS_TEST_TG_LINEAR, | 292 | GNUNET_ATS_TEST_TG_LINEAR, |
293 | 1000, | 293 | 1000, |
294 | 2000, | 294 | 2000, |
295 | GNUNET_TIME_UNIT_MINUTES, | 295 | GNUNET_TIME_UNIT_MINUTES, |
296 | GNUNET_TIME_UNIT_FOREVER_REL); | 296 | GNUNET_TIME_UNIT_FOREVER_REL); |
297 | /* Example: Generate traffic with a random rate between 1000 to 2000 | 297 | /* Example: Generate traffic with a random rate between 1000 to 2000 |
298 | * Bytes/s */ | 298 | * Bytes/s */ |
299 | GNUNET_ATS_TEST_generate_traffic_start (&masters[c_m], | 299 | GNUNET_ATS_TEST_generate_traffic_start(&masters[c_m], |
300 | &masters[c_m].partners[c_s], | 300 | &masters[c_m].partners[c_s], |
301 | GNUNET_ATS_TEST_TG_RANDOM, | 301 | GNUNET_ATS_TEST_TG_RANDOM, |
302 | 1000, | 302 | 1000, |
303 | 2000, | 303 | 2000, |
304 | GNUNET_TIME_UNIT_FOREVER_REL, | 304 | GNUNET_TIME_UNIT_FOREVER_REL, |
305 | GNUNET_TIME_UNIT_FOREVER_REL); | 305 | GNUNET_TIME_UNIT_FOREVER_REL); |
306 | /* Example: Generate traffic with a sinus form, a base rate of | 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 */ | 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], | 308 | GNUNET_ATS_TEST_generate_traffic_start(&masters[c_m], |
309 | &masters[c_m].partners[c_s], | 309 | &masters[c_m].partners[c_s], |
310 | GNUNET_ATS_TEST_TG_SINUS, | 310 | GNUNET_ATS_TEST_TG_SINUS, |
311 | 1000, | 311 | 1000, |
312 | 2000, | 312 | 2000, |
313 | GNUNET_TIME_UNIT_MINUTES, | 313 | GNUNET_TIME_UNIT_MINUTES, |
314 | GNUNET_TIME_UNIT_FOREVER_REL); | 314 | GNUNET_TIME_UNIT_FOREVER_REL); |
315 | } | 315 | } |
316 | } | 316 | } |
317 | #endif | 317 | #endif |
318 | 318 | ||
319 | timeout_task | 319 | timeout_task |
320 | = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_add (GNUNET_TIME_UNIT_MINUTES, | 320 | = GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_add(GNUNET_TIME_UNIT_MINUTES, |
321 | e->max_duration), | 321 | e->max_duration), |
322 | &do_timeout, | 322 | &do_timeout, |
323 | NULL); | 323 | NULL); |
324 | GNUNET_SCHEDULER_add_shutdown (&do_shutdown, NULL); | 324 | GNUNET_SCHEDULER_add_shutdown(&do_shutdown, NULL); |
325 | } | 325 | } |
326 | 326 | ||
327 | 327 | ||
328 | static void | 328 | static void |
329 | parse_args (int argc, char *argv[]) | 329 | parse_args(int argc, char *argv[]) |
330 | { | 330 | { |
331 | int c; | 331 | int c; |
332 | |||
332 | opt_exp_file = NULL; | 333 | opt_exp_file = NULL; |
333 | opt_log = GNUNET_NO; | 334 | opt_log = GNUNET_NO; |
334 | opt_plot = GNUNET_NO; | 335 | opt_plot = GNUNET_NO; |
335 | 336 | ||
336 | for (c = 0; c < argc; c++) | 337 | for (c = 0; c < argc; c++) |
337 | { | ||
338 | if ((c < (argc - 1)) && (0 == strcmp (argv[c], "-e"))) | ||
339 | { | ||
340 | GNUNET_free_non_null (opt_exp_file); | ||
341 | opt_exp_file = GNUNET_strdup ( argv[c + 1]); | ||
342 | } | ||
343 | if (0 == strcmp (argv[c], "-l")) | ||
344 | { | ||
345 | opt_log = GNUNET_YES; | ||
346 | } | ||
347 | if (0 == strcmp (argv[c], "-p")) | ||
348 | { | 338 | { |
349 | opt_plot = GNUNET_YES; | 339 | if ((c < (argc - 1)) && (0 == strcmp(argv[c], "-e"))) |
340 | { | ||
341 | GNUNET_free_non_null(opt_exp_file); | ||
342 | opt_exp_file = GNUNET_strdup(argv[c + 1]); | ||
343 | } | ||
344 | if (0 == strcmp(argv[c], "-l")) | ||
345 | { | ||
346 | opt_log = GNUNET_YES; | ||
347 | } | ||
348 | if (0 == strcmp(argv[c], "-p")) | ||
349 | { | ||
350 | opt_plot = GNUNET_YES; | ||
351 | } | ||
352 | if (0 == strcmp(argv[c], "-v")) | ||
353 | { | ||
354 | opt_verbose = GNUNET_YES; | ||
355 | } | ||
350 | } | 356 | } |
351 | if (0 == strcmp (argv[c], "-v")) | ||
352 | { | ||
353 | opt_verbose = GNUNET_YES; | ||
354 | } | ||
355 | } | ||
356 | } | 357 | } |
357 | 358 | ||
358 | 359 | ||
359 | int | 360 | int |
360 | main (int argc, char *argv[]) | 361 | main(int argc, char *argv[]) |
361 | { | 362 | { |
362 | GNUNET_log_setup("gnunet-ats-sim", "INFO", NULL); | 363 | GNUNET_log_setup("gnunet-ats-sim", "INFO", NULL); |
363 | 364 | ||
364 | parse_args (argc, argv); | 365 | parse_args(argc, argv); |
365 | if (NULL == opt_exp_file ) | 366 | if (NULL == opt_exp_file) |
366 | { | 367 | { |
367 | fprintf (stderr, "No experiment given...\n"); | 368 | fprintf(stderr, "No experiment given...\n"); |
368 | return 1; | 369 | return 1; |
369 | } | 370 | } |
370 | 371 | ||
371 | fprintf (stderr, "Loading experiment `%s' \n", opt_exp_file ); | 372 | fprintf(stderr, "Loading experiment `%s' \n", opt_exp_file); |
372 | e = GNUNET_ATS_TEST_experimentation_load (opt_exp_file); | 373 | e = GNUNET_ATS_TEST_experimentation_load(opt_exp_file); |
373 | if (NULL == e) | 374 | if (NULL == e) |
374 | { | 375 | { |
375 | fprintf (stderr, "Invalid experiment\n"); | 376 | fprintf(stderr, "Invalid experiment\n"); |
376 | return 1; | 377 | return 1; |
377 | } | 378 | } |
378 | if (0 == e->num_episodes) | 379 | if (0 == e->num_episodes) |
379 | { | 380 | { |
380 | fprintf (stderr, "No episodes included\n"); | 381 | fprintf(stderr, "No episodes included\n"); |
381 | return 1; | 382 | return 1; |
382 | } | 383 | } |
383 | 384 | ||
384 | /* Setup a topology with */ | 385 | /* Setup a topology with */ |
385 | GNUNET_ATS_TEST_create_topology ("gnunet-ats-sim", e->cfg_file, | 386 | GNUNET_ATS_TEST_create_topology("gnunet-ats-sim", e->cfg_file, |
386 | e->num_slaves, | 387 | e->num_slaves, |
387 | e->num_masters, | 388 | e->num_masters, |
388 | GNUNET_NO, | 389 | GNUNET_NO, |
389 | &topology_setup_done, | 390 | &topology_setup_done, |
390 | NULL, | 391 | NULL, |
391 | &log_request__cb); | 392 | &log_request__cb); |
392 | GNUNET_free (opt_exp_file); | 393 | GNUNET_free(opt_exp_file); |
393 | return 0; | 394 | return 0; |
394 | } | 395 | } |
395 | /* end of file gnunet-ats-sim.c */ | 396 | /* 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 index cb1946448..b5e00bd6f 100644 --- a/src/ats-tests/gnunet-solver-eval.c +++ b/src/ats-tests/gnunet-solver-eval.c | |||
@@ -1,19 +1,19 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2010-2013 GNUnet e.V. | 3 | Copyright (C) 2010-2013 GNUnet e.V. |
4 | 4 | ||
5 | GNUnet is free software: you can redistribute it and/or modify it | 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 | 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, | 7 | by the Free Software Foundation, either version 3 of the License, |
8 | or (at your option) any later version. | 8 | or (at your option) any later version. |
9 | 9 | ||
10 | GNUnet is distributed in the hope that it will be useful, but | 10 | GNUnet is distributed in the hope that it will be useful, but |
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Affero General Public License for more details. | 13 | Affero General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Affero General Public License | 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/>. | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | 17 | ||
18 | SPDX-License-Identifier: AGPL3.0-or-later | 18 | SPDX-License-Identifier: AGPL3.0-or-later |
19 | */ | 19 | */ |
@@ -34,29 +34,35 @@ | |||
34 | * Experiments | 34 | * Experiments |
35 | */ | 35 | */ |
36 | const char * | 36 | const char * |
37 | print_op (enum OperationType op) | 37 | print_op(enum OperationType op) |
38 | { | 38 | { |
39 | switch (op) { | 39 | switch (op) |
40 | { | ||
40 | case START_SEND: | 41 | case START_SEND: |
41 | return "START_SEND"; | 42 | return "START_SEND"; |
43 | |||
42 | case STOP_SEND: | 44 | case STOP_SEND: |
43 | return "STOP_SEND"; | 45 | return "STOP_SEND"; |
46 | |||
44 | case START_PREFERENCE: | 47 | case START_PREFERENCE: |
45 | return "START_PREFERENCE"; | 48 | return "START_PREFERENCE"; |
49 | |||
46 | case STOP_PREFERENCE: | 50 | case STOP_PREFERENCE: |
47 | return "STOP_PREFERENCE"; | 51 | return "STOP_PREFERENCE"; |
52 | |||
48 | default: | 53 | default: |
49 | break; | 54 | break; |
50 | } | 55 | } |
51 | return ""; | 56 | return ""; |
52 | } | 57 | } |
53 | 58 | ||
54 | 59 | ||
55 | static struct Experiment * | 60 | static struct Experiment * |
56 | create_experiment () | 61 | create_experiment() |
57 | { | 62 | { |
58 | struct Experiment *e; | 63 | struct Experiment *e; |
59 | e = GNUNET_new (struct Experiment); | 64 | |
65 | e = GNUNET_new(struct Experiment); | ||
60 | e->name = NULL; | 66 | e->name = NULL; |
61 | e->num_masters = 0; | 67 | e->num_masters = 0; |
62 | e->num_slaves = 0; | 68 | e->num_slaves = 0; |
@@ -67,7 +73,7 @@ create_experiment () | |||
67 | 73 | ||
68 | 74 | ||
69 | static void | 75 | static void |
70 | free_experiment (struct Experiment *e) | 76 | free_experiment(struct Experiment *e) |
71 | { | 77 | { |
72 | struct Episode *cur; | 78 | struct Episode *cur; |
73 | struct Episode *next; | 79 | struct Episode *next; |
@@ -76,28 +82,28 @@ free_experiment (struct Experiment *e) | |||
76 | 82 | ||
77 | next = e->start; | 83 | next = e->start; |
78 | for (cur = next; NULL != cur; cur = next) | 84 | 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 | { |
85 | next_o = cur_o->next; | 86 | next = cur->next; |
86 | GNUNET_free (cur_o); | 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); | ||
87 | } | 95 | } |
88 | GNUNET_free (cur); | ||
89 | } | ||
90 | 96 | ||
91 | GNUNET_free_non_null (e->name); | 97 | GNUNET_free_non_null(e->name); |
92 | GNUNET_free_non_null (e->cfg_file); | 98 | GNUNET_free_non_null(e->cfg_file); |
93 | GNUNET_free (e); | 99 | GNUNET_free(e); |
94 | } | 100 | } |
95 | 101 | ||
96 | 102 | ||
97 | static int | 103 | static int |
98 | load_episode (struct Experiment *e, | 104 | load_episode(struct Experiment *e, |
99 | struct Episode *cur, | 105 | struct Episode *cur, |
100 | struct GNUNET_CONFIGURATION_Handle *cfg) | 106 | struct GNUNET_CONFIGURATION_Handle *cfg) |
101 | { | 107 | { |
102 | struct GNUNET_ATS_TEST_Operation *o; | 108 | struct GNUNET_ATS_TEST_Operation *o; |
103 | char *sec_name; | 109 | char *sec_name; |
@@ -106,284 +112,285 @@ load_episode (struct Experiment *e, | |||
106 | char *type; | 112 | char *type; |
107 | char *pref; | 113 | char *pref; |
108 | int op_counter = 0; | 114 | int op_counter = 0; |
109 | fprintf (stderr, "Parsing episode %u\n",cur->id); | 115 | |
116 | fprintf(stderr, "Parsing episode %u\n", cur->id); | ||
110 | GNUNET_asprintf(&sec_name, "episode-%u", cur->id); | 117 | GNUNET_asprintf(&sec_name, "episode-%u", cur->id); |
111 | 118 | ||
112 | while (1) | 119 | while (1) |
113 | { | ||
114 | /* Load operation */ | ||
115 | GNUNET_asprintf(&op_name, "op-%u-operation", op_counter); | ||
116 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string(cfg, | ||
117 | sec_name, op_name, &op)) | ||
118 | { | ||
119 | GNUNET_free (op_name); | ||
120 | break; | ||
121 | } | ||
122 | o = GNUNET_new (struct GNUNET_ATS_TEST_Operation); | ||
123 | /* operations = set_rate, start_send, stop_send, set_preference */ | ||
124 | if (0 == strcmp (op, "start_send")) | ||
125 | { | ||
126 | o->type = START_SEND; | ||
127 | } | ||
128 | else if (0 == strcmp (op, "stop_send")) | ||
129 | { | ||
130 | o->type = STOP_SEND; | ||
131 | } | ||
132 | else if (0 == strcmp (op, "start_preference")) | ||
133 | { | ||
134 | o->type = START_PREFERENCE; | ||
135 | } | ||
136 | else if (0 == strcmp (op, "stop_preference")) | ||
137 | { | ||
138 | o->type = STOP_PREFERENCE; | ||
139 | } | ||
140 | else | ||
141 | { | ||
142 | fprintf (stderr, "Invalid operation %u `%s' in episode %u\n", | ||
143 | op_counter, op, cur->id); | ||
144 | GNUNET_free (op); | ||
145 | GNUNET_free (op_name); | ||
146 | GNUNET_free (sec_name); | ||
147 | GNUNET_free (o); | ||
148 | return GNUNET_SYSERR; | ||
149 | } | ||
150 | GNUNET_free (op_name); | ||
151 | |||
152 | /* Get source */ | ||
153 | GNUNET_asprintf(&op_name, "op-%u-src", op_counter); | ||
154 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (cfg, | ||
155 | sec_name, op_name, &o->src_id)) | ||
156 | { | ||
157 | fprintf (stderr, "Missing src in operation %u `%s' in episode %u\n", | ||
158 | op_counter, op, cur->id); | ||
159 | GNUNET_free (op); | ||
160 | GNUNET_free (op_name); | ||
161 | GNUNET_free (sec_name); | ||
162 | GNUNET_free (o); | ||
163 | return GNUNET_SYSERR; | ||
164 | } | ||
165 | if (o->src_id > (e->num_masters - 1)) | ||
166 | { | ||
167 | fprintf (stderr, "Invalid src %llu in operation %u `%s' in episode %u\n", | ||
168 | o->src_id, 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 | GNUNET_free (op_name); | ||
176 | |||
177 | /* Get destination */ | ||
178 | GNUNET_asprintf(&op_name, "op-%u-dest", op_counter); | ||
179 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (cfg, | ||
180 | sec_name, op_name, &o->dest_id)) | ||
181 | { | 120 | { |
182 | fprintf (stderr, "Missing src in operation %u `%s' in episode %u\n", | 121 | /* Load operation */ |
183 | op_counter, op, cur->id); | 122 | GNUNET_asprintf(&op_name, "op-%u-operation", op_counter); |
184 | GNUNET_free (op); | 123 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string(cfg, |
185 | GNUNET_free (op_name); | 124 | sec_name, op_name, &op)) |
186 | GNUNET_free (sec_name); | 125 | { |
187 | GNUNET_free (o); | 126 | GNUNET_free(op_name); |
188 | return GNUNET_SYSERR; | 127 | break; |
189 | } | 128 | } |
190 | if (o->dest_id > (e->num_slaves - 1)) | 129 | o = GNUNET_new(struct GNUNET_ATS_TEST_Operation); |
191 | { | 130 | /* operations = set_rate, start_send, stop_send, set_preference */ |
192 | fprintf (stderr, | 131 | if (0 == strcmp(op, "start_send")) |
193 | "Invalid destination %llu in operation %u `%s' in episode %u\n", | 132 | { |
194 | o->dest_id, | 133 | o->type = START_SEND; |
195 | op_counter, | 134 | } |
196 | op, | 135 | else if (0 == strcmp(op, "stop_send")) |
197 | cur->id); | 136 | { |
198 | GNUNET_free (op); | 137 | o->type = STOP_SEND; |
199 | GNUNET_free (op_name); | 138 | } |
200 | GNUNET_free (sec_name); | 139 | else if (0 == strcmp(op, "start_preference")) |
201 | GNUNET_free (o); | 140 | { |
202 | return GNUNET_SYSERR; | 141 | o->type = START_PREFERENCE; |
203 | } | 142 | } |
204 | GNUNET_free (op_name); | 143 | else if (0 == strcmp(op, "stop_preference")) |
205 | 144 | { | |
206 | GNUNET_asprintf(&op_name, "op-%u-type", op_counter); | 145 | o->type = STOP_PREFERENCE; |
207 | if ( (GNUNET_SYSERR != | 146 | } |
208 | GNUNET_CONFIGURATION_get_value_string(cfg, | ||
209 | sec_name, | ||
210 | op_name, | ||
211 | &type)) && | ||
212 | (STOP_SEND != o->type) && | ||
213 | (STOP_PREFERENCE != o->type) ) | ||
214 | { | ||
215 | /* Load arguments for set_rate, start_send, set_preference */ | ||
216 | if (0 == strcmp (type, "constant")) | ||
217 | { | ||
218 | o->gen_type = GNUNET_ATS_TEST_TG_CONSTANT; | ||
219 | } | ||
220 | else if (0 == strcmp (type, "linear")) | ||
221 | { | ||
222 | o->gen_type = GNUNET_ATS_TEST_TG_LINEAR; | ||
223 | } | ||
224 | else if (0 == strcmp (type, "sinus")) | ||
225 | { | ||
226 | o->gen_type = GNUNET_ATS_TEST_TG_SINUS; | ||
227 | } | ||
228 | else if (0 == strcmp (type, "random")) | ||
229 | { | ||
230 | o->gen_type = GNUNET_ATS_TEST_TG_RANDOM; | ||
231 | } | ||
232 | else | 147 | else |
233 | { | ||
234 | fprintf (stderr, "Invalid type %u `%s' in episode %u\n", | ||
235 | op_counter, op, cur->id); | ||
236 | GNUNET_free (type); | ||
237 | GNUNET_free (op); | ||
238 | GNUNET_free (op_name); | ||
239 | GNUNET_free (sec_name); | ||
240 | GNUNET_free (o); | ||
241 | return GNUNET_SYSERR; | ||
242 | } | ||
243 | GNUNET_free (op_name); | ||
244 | |||
245 | /* Get base rate */ | ||
246 | GNUNET_asprintf(&op_name, "op-%u-base-rate", op_counter); | ||
247 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (cfg, | ||
248 | sec_name, op_name, &o->base_rate)) | ||
249 | { | ||
250 | fprintf (stderr, "Missing base rate in operation %u `%s' in episode %u\n", | ||
251 | op_counter, op, cur->id); | ||
252 | GNUNET_free (type); | ||
253 | GNUNET_free (op); | ||
254 | GNUNET_free (op_name); | ||
255 | GNUNET_free (sec_name); | ||
256 | GNUNET_free (o); | ||
257 | return GNUNET_SYSERR; | ||
258 | } | ||
259 | GNUNET_free (op_name); | ||
260 | |||
261 | /* Get max rate */ | ||
262 | GNUNET_asprintf(&op_name, "op-%u-max-rate", op_counter); | ||
263 | if (GNUNET_SYSERR == | ||
264 | GNUNET_CONFIGURATION_get_value_number (cfg, | ||
265 | sec_name, | ||
266 | op_name, | ||
267 | &o->max_rate)) | ||
268 | { | ||
269 | if ((GNUNET_ATS_TEST_TG_LINEAR == o->gen_type) || | ||
270 | (GNUNET_ATS_TEST_TG_RANDOM == o->gen_type) || | ||
271 | (GNUNET_ATS_TEST_TG_SINUS == o->gen_type)) | ||
272 | { | 148 | { |
273 | fprintf (stderr, "Missing max rate in operation %u `%s' in episode %u\n", | 149 | fprintf(stderr, "Invalid operation %u `%s' in episode %u\n", |
274 | op_counter, op, cur->id); | 150 | op_counter, op, cur->id); |
275 | GNUNET_free (type); | 151 | GNUNET_free(op); |
276 | GNUNET_free (op_name); | 152 | GNUNET_free(op_name); |
277 | GNUNET_free (op); | 153 | GNUNET_free(sec_name); |
278 | GNUNET_free (sec_name); | 154 | GNUNET_free(o); |
279 | GNUNET_free (o); | ||
280 | return GNUNET_SYSERR; | 155 | return GNUNET_SYSERR; |
281 | } | 156 | } |
282 | } | 157 | GNUNET_free(op_name); |
283 | GNUNET_free (op_name); | 158 | |
284 | 159 | /* Get source */ | |
285 | /* Get period */ | 160 | GNUNET_asprintf(&op_name, "op-%u-src", op_counter); |
286 | GNUNET_asprintf(&op_name, "op-%u-period", op_counter); | 161 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number(cfg, |
287 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_time (cfg, | 162 | sec_name, op_name, &o->src_id)) |
288 | sec_name, op_name, &o->period)) | 163 | { |
289 | { | 164 | fprintf(stderr, "Missing src in operation %u `%s' in episode %u\n", |
290 | o->period = cur->duration; | ||
291 | } | ||
292 | GNUNET_free (op_name); | ||
293 | |||
294 | if (START_PREFERENCE == o->type) | ||
295 | { | ||
296 | /* Get frequency */ | ||
297 | GNUNET_asprintf(&op_name, "op-%u-frequency", op_counter); | ||
298 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_time (cfg, | ||
299 | sec_name, op_name, &o->frequency)) | ||
300 | { | ||
301 | fprintf (stderr, "Missing frequency in operation %u `%s' in episode %u\n", | ||
302 | op_counter, op, cur->id); | 165 | op_counter, op, cur->id); |
303 | GNUNET_free (type); | 166 | GNUNET_free(op); |
304 | GNUNET_free (op_name); | 167 | GNUNET_free(op_name); |
305 | GNUNET_free (op); | 168 | GNUNET_free(sec_name); |
306 | GNUNET_free (sec_name); | 169 | GNUNET_free(o); |
307 | GNUNET_free (o); | 170 | return GNUNET_SYSERR; |
308 | return GNUNET_SYSERR; | 171 | } |
309 | } | 172 | if (o->src_id > (e->num_masters - 1)) |
310 | GNUNET_free (op_name); | 173 | { |
311 | 174 | fprintf(stderr, "Invalid src %llu in operation %u `%s' in episode %u\n", | |
312 | /* Get preference */ | 175 | o->src_id, op_counter, op, cur->id); |
313 | GNUNET_asprintf(&op_name, "op-%u-pref", op_counter); | 176 | GNUNET_free(op); |
314 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string (cfg, | 177 | GNUNET_free(op_name); |
315 | sec_name, op_name, &pref)) | 178 | GNUNET_free(sec_name); |
316 | { | 179 | GNUNET_free(o); |
317 | fprintf (stderr, "Missing preference in operation %u `%s' in episode %u\n", | 180 | return GNUNET_SYSERR; |
181 | } | ||
182 | GNUNET_free(op_name); | ||
183 | |||
184 | /* Get destination */ | ||
185 | GNUNET_asprintf(&op_name, "op-%u-dest", op_counter); | ||
186 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number(cfg, | ||
187 | sec_name, op_name, &o->dest_id)) | ||
188 | { | ||
189 | fprintf(stderr, "Missing src in operation %u `%s' in episode %u\n", | ||
318 | op_counter, op, cur->id); | 190 | op_counter, op, cur->id); |
319 | GNUNET_free (type); | 191 | GNUNET_free(op); |
320 | GNUNET_free (op_name); | 192 | GNUNET_free(op_name); |
321 | GNUNET_free (op); | 193 | GNUNET_free(sec_name); |
322 | GNUNET_free (sec_name); | 194 | GNUNET_free(o); |
323 | GNUNET_free_non_null (pref); | 195 | return GNUNET_SYSERR; |
324 | GNUNET_free (o); | 196 | } |
325 | return GNUNET_SYSERR; | 197 | if (o->dest_id > (e->num_slaves - 1)) |
326 | } | 198 | { |
199 | fprintf(stderr, | ||
200 | "Invalid destination %llu in operation %u `%s' in episode %u\n", | ||
201 | o->dest_id, | ||
202 | op_counter, | ||
203 | op, | ||
204 | cur->id); | ||
205 | GNUNET_free(op); | ||
206 | GNUNET_free(op_name); | ||
207 | GNUNET_free(sec_name); | ||
208 | GNUNET_free(o); | ||
209 | return GNUNET_SYSERR; | ||
210 | } | ||
211 | GNUNET_free(op_name); | ||
327 | 212 | ||
328 | if (0 == strcmp(pref, "bandwidth")) | 213 | GNUNET_asprintf(&op_name, "op-%u-type", op_counter); |
329 | o->pref_type = GNUNET_ATS_PREFERENCE_BANDWIDTH; | 214 | if ((GNUNET_SYSERR != |
330 | else if (0 == strcmp(pref, "latency")) | 215 | GNUNET_CONFIGURATION_get_value_string(cfg, |
331 | o->pref_type = GNUNET_ATS_PREFERENCE_LATENCY; | 216 | sec_name, |
217 | op_name, | ||
218 | &type)) && | ||
219 | (STOP_SEND != o->type) && | ||
220 | (STOP_PREFERENCE != o->type)) | ||
221 | { | ||
222 | /* Load arguments for set_rate, start_send, set_preference */ | ||
223 | if (0 == strcmp(type, "constant")) | ||
224 | { | ||
225 | o->gen_type = GNUNET_ATS_TEST_TG_CONSTANT; | ||
226 | } | ||
227 | else if (0 == strcmp(type, "linear")) | ||
228 | { | ||
229 | o->gen_type = GNUNET_ATS_TEST_TG_LINEAR; | ||
230 | } | ||
231 | else if (0 == strcmp(type, "sinus")) | ||
232 | { | ||
233 | o->gen_type = GNUNET_ATS_TEST_TG_SINUS; | ||
234 | } | ||
235 | else if (0 == strcmp(type, "random")) | ||
236 | { | ||
237 | o->gen_type = GNUNET_ATS_TEST_TG_RANDOM; | ||
238 | } | ||
332 | else | 239 | else |
333 | { | 240 | { |
334 | fprintf (stderr, | 241 | fprintf(stderr, "Invalid type %u `%s' in episode %u\n", |
335 | "Invalid preference in operation %u `%s' in episode %u\n", | 242 | op_counter, op, cur->id); |
336 | op_counter, | 243 | GNUNET_free(type); |
337 | op, | 244 | GNUNET_free(op); |
338 | cur->id); | 245 | GNUNET_free(op_name); |
339 | GNUNET_free (type); | 246 | GNUNET_free(sec_name); |
340 | GNUNET_free (op_name); | 247 | GNUNET_free(o); |
341 | GNUNET_free (op); | ||
342 | GNUNET_free (sec_name); | ||
343 | GNUNET_free_non_null (pref); | ||
344 | GNUNET_free (o); | ||
345 | return GNUNET_SYSERR; | 248 | return GNUNET_SYSERR; |
346 | } | 249 | } |
347 | GNUNET_free (pref); | 250 | GNUNET_free(op_name); |
348 | GNUNET_free (op_name); | 251 | |
349 | } | 252 | /* Get base rate */ |
350 | } | 253 | GNUNET_asprintf(&op_name, "op-%u-base-rate", op_counter); |
254 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number(cfg, | ||
255 | sec_name, op_name, &o->base_rate)) | ||
256 | { | ||
257 | fprintf(stderr, "Missing base rate in operation %u `%s' in episode %u\n", | ||
258 | op_counter, op, cur->id); | ||
259 | GNUNET_free(type); | ||
260 | GNUNET_free(op); | ||
261 | GNUNET_free(op_name); | ||
262 | GNUNET_free(sec_name); | ||
263 | GNUNET_free(o); | ||
264 | return GNUNET_SYSERR; | ||
265 | } | ||
266 | GNUNET_free(op_name); | ||
267 | |||
268 | /* Get max rate */ | ||
269 | GNUNET_asprintf(&op_name, "op-%u-max-rate", op_counter); | ||
270 | if (GNUNET_SYSERR == | ||
271 | GNUNET_CONFIGURATION_get_value_number(cfg, | ||
272 | sec_name, | ||
273 | op_name, | ||
274 | &o->max_rate)) | ||
275 | { | ||
276 | if ((GNUNET_ATS_TEST_TG_LINEAR == o->gen_type) || | ||
277 | (GNUNET_ATS_TEST_TG_RANDOM == o->gen_type) || | ||
278 | (GNUNET_ATS_TEST_TG_SINUS == o->gen_type)) | ||
279 | { | ||
280 | fprintf(stderr, "Missing max rate in operation %u `%s' in episode %u\n", | ||
281 | op_counter, op, cur->id); | ||
282 | GNUNET_free(type); | ||
283 | GNUNET_free(op_name); | ||
284 | GNUNET_free(op); | ||
285 | GNUNET_free(sec_name); | ||
286 | GNUNET_free(o); | ||
287 | return GNUNET_SYSERR; | ||
288 | } | ||
289 | } | ||
290 | GNUNET_free(op_name); | ||
291 | |||
292 | /* Get period */ | ||
293 | GNUNET_asprintf(&op_name, "op-%u-period", op_counter); | ||
294 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_time(cfg, | ||
295 | sec_name, op_name, &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, op_name, &o->frequency)) | ||
307 | { | ||
308 | fprintf(stderr, "Missing frequency in operation %u `%s' in episode %u\n", | ||
309 | op_counter, op, cur->id); | ||
310 | GNUNET_free(type); | ||
311 | GNUNET_free(op_name); | ||
312 | GNUNET_free(op); | ||
313 | GNUNET_free(sec_name); | ||
314 | GNUNET_free(o); | ||
315 | return GNUNET_SYSERR; | ||
316 | } | ||
317 | GNUNET_free(op_name); | ||
318 | |||
319 | /* Get preference */ | ||
320 | GNUNET_asprintf(&op_name, "op-%u-pref", op_counter); | ||
321 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string(cfg, | ||
322 | sec_name, op_name, &pref)) | ||
323 | { | ||
324 | fprintf(stderr, "Missing preference in operation %u `%s' in episode %u\n", | ||
325 | op_counter, op, cur->id); | ||
326 | GNUNET_free(type); | ||
327 | GNUNET_free(op_name); | ||
328 | GNUNET_free(op); | ||
329 | GNUNET_free(sec_name); | ||
330 | GNUNET_free_non_null(pref); | ||
331 | GNUNET_free(o); | ||
332 | return GNUNET_SYSERR; | ||
333 | } | ||
334 | |||
335 | if (0 == strcmp(pref, "bandwidth")) | ||
336 | o->pref_type = GNUNET_ATS_PREFERENCE_BANDWIDTH; | ||
337 | else if (0 == strcmp(pref, "latency")) | ||
338 | o->pref_type = GNUNET_ATS_PREFERENCE_LATENCY; | ||
339 | else | ||
340 | { | ||
341 | fprintf(stderr, | ||
342 | "Invalid preference in operation %u `%s' in episode %u\n", | ||
343 | op_counter, | ||
344 | op, | ||
345 | cur->id); | ||
346 | GNUNET_free(type); | ||
347 | GNUNET_free(op_name); | ||
348 | GNUNET_free(op); | ||
349 | GNUNET_free(sec_name); | ||
350 | GNUNET_free_non_null(pref); | ||
351 | GNUNET_free(o); | ||
352 | return GNUNET_SYSERR; | ||
353 | } | ||
354 | GNUNET_free(pref); | ||
355 | GNUNET_free(op_name); | ||
356 | } | ||
357 | } | ||
351 | 358 | ||
352 | /* Safety checks */ | 359 | /* Safety checks */ |
353 | if ((GNUNET_ATS_TEST_TG_LINEAR == o->gen_type) || | 360 | if ((GNUNET_ATS_TEST_TG_LINEAR == o->gen_type) || |
354 | (GNUNET_ATS_TEST_TG_SINUS == o->gen_type)) | 361 | (GNUNET_ATS_TEST_TG_SINUS == o->gen_type)) |
355 | { | 362 | { |
356 | if ((o->max_rate - o->base_rate) > o->base_rate) | 363 | if ((o->max_rate - o->base_rate) > o->base_rate) |
357 | { | 364 | { |
358 | /* This will cause an underflow */ | 365 | /* This will cause an underflow */ |
359 | GNUNET_break (0); | 366 | GNUNET_break(0); |
360 | } | 367 | } |
361 | fprintf (stderr, "Selected max rate and base rate cannot be used for desired traffic form!\n"); | 368 | fprintf(stderr, "Selected max rate and base rate cannot be used for desired traffic form!\n"); |
362 | } | 369 | } |
363 | 370 | ||
364 | if ((START_SEND == o->type) || (START_PREFERENCE == o->type)) | 371 | if ((START_SEND == o->type) || (START_PREFERENCE == o->type)) |
365 | fprintf (stderr, "Found operation %u in episode %u: %s [%llu]->[%llu] == %s, %llu -> %llu in %s\n", | 372 | fprintf(stderr, "Found operation %u in episode %u: %s [%llu]->[%llu] == %s, %llu -> %llu in %s\n", |
366 | op_counter, cur->id, print_op (o->type), o->src_id, | 373 | op_counter, cur->id, print_op(o->type), o->src_id, |
367 | o->dest_id, (NULL != type) ? type : "", | 374 | o->dest_id, (NULL != type) ? type : "", |
368 | o->base_rate, o->max_rate, | 375 | o->base_rate, o->max_rate, |
369 | GNUNET_STRINGS_relative_time_to_string (o->period, GNUNET_YES)); | 376 | GNUNET_STRINGS_relative_time_to_string(o->period, GNUNET_YES)); |
370 | else | 377 | else |
371 | fprintf (stderr, "Found operation %u in episode %u: %s [%llu]->[%llu]\n", | 378 | fprintf(stderr, "Found operation %u in episode %u: %s [%llu]->[%llu]\n", |
372 | op_counter, cur->id, print_op (o->type), o->src_id, o->dest_id); | 379 | op_counter, cur->id, print_op(o->type), o->src_id, o->dest_id); |
373 | 380 | ||
374 | GNUNET_free_non_null (type); | 381 | GNUNET_free_non_null(type); |
375 | GNUNET_free (op); | 382 | GNUNET_free(op); |
376 | 383 | ||
377 | GNUNET_CONTAINER_DLL_insert (cur->head,cur->tail, o); | 384 | GNUNET_CONTAINER_DLL_insert(cur->head, cur->tail, o); |
378 | op_counter++; | 385 | op_counter++; |
379 | } | 386 | } |
380 | GNUNET_free (sec_name); | 387 | GNUNET_free(sec_name); |
381 | 388 | ||
382 | return GNUNET_OK; | 389 | return GNUNET_OK; |
383 | } | 390 | } |
384 | 391 | ||
385 | static int | 392 | static int |
386 | load_episodes (struct Experiment *e, struct GNUNET_CONFIGURATION_Handle *cfg) | 393 | load_episodes(struct Experiment *e, struct GNUNET_CONFIGURATION_Handle *cfg) |
387 | { | 394 | { |
388 | int e_counter = 0; | 395 | int e_counter = 0; |
389 | char *sec_name; | 396 | char *sec_name; |
@@ -394,438 +401,446 @@ load_episodes (struct Experiment *e, struct GNUNET_CONFIGURATION_Handle *cfg) | |||
394 | e_counter = 0; | 401 | e_counter = 0; |
395 | last = NULL; | 402 | last = NULL; |
396 | while (1) | 403 | while (1) |
397 | { | ||
398 | GNUNET_asprintf(&sec_name, "episode-%u", e_counter); | ||
399 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_time(cfg, | ||
400 | sec_name, "duration", &e_duration)) | ||
401 | { | 404 | { |
402 | GNUNET_free (sec_name); | 405 | GNUNET_asprintf(&sec_name, "episode-%u", e_counter); |
403 | break; | 406 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_time(cfg, |
404 | } | 407 | sec_name, "duration", &e_duration)) |
408 | { | ||
409 | GNUNET_free(sec_name); | ||
410 | break; | ||
411 | } | ||
405 | 412 | ||
406 | cur = GNUNET_new (struct Episode); | 413 | cur = GNUNET_new(struct Episode); |
407 | cur->duration = e_duration; | 414 | cur->duration = e_duration; |
408 | cur->id = e_counter; | 415 | cur->id = e_counter; |
409 | 416 | ||
410 | if (GNUNET_OK != load_episode (e, cur, cfg)) | 417 | if (GNUNET_OK != load_episode(e, cur, cfg)) |
411 | { | 418 | { |
412 | GNUNET_free (sec_name); | 419 | GNUNET_free(sec_name); |
413 | GNUNET_free (cur); | 420 | GNUNET_free(cur); |
414 | return GNUNET_SYSERR; | 421 | return GNUNET_SYSERR; |
415 | } | 422 | } |
423 | |||
424 | fprintf(stderr, "Found episode %u with duration %s \n", | ||
425 | e_counter, | ||
426 | GNUNET_STRINGS_relative_time_to_string(cur->duration, GNUNET_YES)); | ||
427 | |||
428 | /* Update experiment */ | ||
429 | e->num_episodes++; | ||
430 | e->total_duration = GNUNET_TIME_relative_add(e->total_duration, cur->duration); | ||
431 | /* Put in linked list */ | ||
432 | if (NULL == last) | ||
433 | e->start = cur; | ||
434 | else | ||
435 | last->next = cur; | ||
416 | 436 | ||
417 | fprintf (stderr, "Found episode %u with duration %s \n", | 437 | GNUNET_free(sec_name); |
418 | e_counter, | 438 | e_counter++; |
419 | GNUNET_STRINGS_relative_time_to_string(cur->duration, GNUNET_YES)); | 439 | last = cur; |
420 | 440 | } | |
421 | /* Update experiment */ | ||
422 | e->num_episodes ++; | ||
423 | e->total_duration = GNUNET_TIME_relative_add(e->total_duration, cur->duration); | ||
424 | /* Put in linked list */ | ||
425 | if (NULL == last) | ||
426 | e->start = cur; | ||
427 | else | ||
428 | last->next = cur; | ||
429 | |||
430 | GNUNET_free (sec_name); | ||
431 | e_counter ++; | ||
432 | last = cur; | ||
433 | } | ||
434 | return e_counter; | 441 | return e_counter; |
435 | } | 442 | } |
436 | 443 | ||
437 | 444 | ||
438 | static void | 445 | static void |
439 | timeout_experiment (void *cls) | 446 | timeout_experiment(void *cls) |
440 | { | 447 | { |
441 | struct Experiment *e = cls; | 448 | struct Experiment *e = cls; |
449 | |||
442 | e->experiment_timeout_task = NULL; | 450 | e->experiment_timeout_task = NULL; |
443 | fprintf (stderr, "Experiment timeout!\n"); | 451 | fprintf(stderr, "Experiment timeout!\n"); |
444 | 452 | ||
445 | if (NULL != e->episode_timeout_task) | 453 | if (NULL != e->episode_timeout_task) |
446 | { | 454 | { |
447 | GNUNET_SCHEDULER_cancel (e->episode_timeout_task); | 455 | GNUNET_SCHEDULER_cancel(e->episode_timeout_task); |
448 | e->episode_timeout_task = NULL; | 456 | e->episode_timeout_task = NULL; |
449 | } | 457 | } |
450 | 458 | ||
451 | e->e_done_cb (e, GNUNET_TIME_absolute_get_duration(e->start_time), | 459 | e->e_done_cb(e, GNUNET_TIME_absolute_get_duration(e->start_time), |
452 | GNUNET_SYSERR); | 460 | GNUNET_SYSERR); |
453 | } | 461 | } |
454 | 462 | ||
455 | 463 | ||
456 | static void | 464 | static void |
457 | enforce_start_send (struct GNUNET_ATS_TEST_Operation *op) | 465 | enforce_start_send(struct GNUNET_ATS_TEST_Operation *op) |
458 | { | 466 | { |
459 | /* | 467 | /* |
460 | struct BenchmarkPeer *peer; | 468 | struct BenchmarkPeer *peer; |
461 | struct BenchmarkPartner *partner; | 469 | struct BenchmarkPartner *partner; |
462 | 470 | ||
463 | peer = GNUNET_ATS_TEST_get_peer (op->src_id); | 471 | peer = GNUNET_ATS_TEST_get_peer (op->src_id); |
464 | if (NULL == peer) | 472 | if (NULL == peer) |
465 | { | 473 | { |
466 | GNUNET_break (0); | 474 | GNUNET_break (0); |
467 | return; | 475 | return; |
468 | } | 476 | } |
469 | 477 | ||
470 | partner = GNUNET_ATS_TEST_get_partner (op->src_id, op->dest_id); | 478 | partner = GNUNET_ATS_TEST_get_partner (op->src_id, op->dest_id); |
471 | if (NULL == partner) | 479 | if (NULL == partner) |
472 | { | 480 | { |
473 | GNUNET_break (0); | 481 | GNUNET_break (0); |
474 | return; | 482 | return; |
475 | } | 483 | } |
476 | 484 | ||
477 | fprintf (stderr, "Found master %llu slave %llu\n",op->src_id, op->dest_id); | 485 | fprintf (stderr, "Found master %llu slave %llu\n",op->src_id, op->dest_id); |
478 | 486 | ||
479 | if (NULL != partner->tg) | 487 | if (NULL != partner->tg) |
480 | { | 488 | { |
481 | fprintf (stderr, "Stopping traffic between master %llu slave %llu\n",op->src_id, op->dest_id); | 489 | fprintf (stderr, "Stopping traffic between master %llu slave %llu\n",op->src_id, op->dest_id); |
482 | GNUNET_ATS_TEST_generate_traffic_stop(partner->tg); | 490 | GNUNET_ATS_TEST_generate_traffic_stop(partner->tg); |
483 | partner->tg = NULL; | 491 | partner->tg = NULL; |
484 | } | 492 | } |
485 | 493 | ||
486 | partner->tg = GNUNET_ATS_TEST_generate_traffic_start(peer, partner, | 494 | partner->tg = GNUNET_ATS_TEST_generate_traffic_start(peer, partner, |
487 | op->tg_type, op->base_rate, op->max_rate, op->period, | 495 | op->tg_type, op->base_rate, op->max_rate, op->period, |
488 | GNUNET_TIME_UNIT_FOREVER_REL); | 496 | GNUNET_TIME_UNIT_FOREVER_REL); |
489 | */ | 497 | */ |
490 | } | 498 | } |
491 | 499 | ||
492 | static void | 500 | static void |
493 | enforce_stop_send (struct GNUNET_ATS_TEST_Operation *op) | 501 | enforce_stop_send(struct GNUNET_ATS_TEST_Operation *op) |
494 | { | 502 | { |
495 | /* | 503 | /* |
496 | struct BenchmarkPartner *p; | 504 | struct BenchmarkPartner *p; |
497 | p = GNUNET_ATS_TEST_get_partner (op->src_id, op->dest_id); | 505 | p = GNUNET_ATS_TEST_get_partner (op->src_id, op->dest_id); |
498 | if (NULL == p) | 506 | if (NULL == p) |
499 | { | 507 | { |
500 | GNUNET_break (0); | 508 | GNUNET_break (0); |
501 | return; | 509 | return; |
502 | } | 510 | } |
503 | 511 | ||
504 | fprintf (stderr, "Found master %llu slave %llu\n",op->src_id, op->dest_id); | 512 | fprintf (stderr, "Found master %llu slave %llu\n",op->src_id, op->dest_id); |
505 | 513 | ||
506 | if (NULL != p->tg) | 514 | if (NULL != p->tg) |
507 | { | 515 | { |
508 | fprintf (stderr, "Stopping traffic between master %llu slave %llu\n", | 516 | fprintf (stderr, "Stopping traffic between master %llu slave %llu\n", |
509 | op->src_id, op->dest_id); | 517 | op->src_id, op->dest_id); |
510 | GNUNET_ATS_TEST_generate_traffic_stop(p->tg); | 518 | GNUNET_ATS_TEST_generate_traffic_stop(p->tg); |
511 | p->tg = NULL; | 519 | p->tg = NULL; |
512 | } | 520 | } |
513 | */ | 521 | */ |
514 | } | 522 | } |
515 | 523 | ||
516 | 524 | ||
517 | static void | 525 | static void |
518 | enforce_start_preference (struct GNUNET_ATS_TEST_Operation *op) | 526 | enforce_start_preference(struct GNUNET_ATS_TEST_Operation *op) |
519 | { | 527 | { |
520 | /* | 528 | /* |
521 | struct BenchmarkPeer *peer; | 529 | struct BenchmarkPeer *peer; |
522 | struct BenchmarkPartner *partner; | 530 | struct BenchmarkPartner *partner; |
523 | 531 | ||
524 | peer = GNUNET_ATS_TEST_get_peer (op->src_id); | 532 | peer = GNUNET_ATS_TEST_get_peer (op->src_id); |
525 | if (NULL == peer) | 533 | if (NULL == peer) |
526 | { | 534 | { |
527 | GNUNET_break (0); | 535 | GNUNET_break (0); |
528 | return; | 536 | return; |
529 | } | 537 | } |
530 | 538 | ||
531 | partner = GNUNET_ATS_TEST_get_partner (op->src_id, op->dest_id); | 539 | partner = GNUNET_ATS_TEST_get_partner (op->src_id, op->dest_id); |
532 | if (NULL == partner) | 540 | if (NULL == partner) |
533 | { | 541 | { |
534 | GNUNET_break (0); | 542 | GNUNET_break (0); |
535 | return; | 543 | return; |
536 | } | 544 | } |
537 | 545 | ||
538 | fprintf (stderr, "Found master %llu slave %llu\n",op->src_id, op->dest_id); | 546 | fprintf (stderr, "Found master %llu slave %llu\n",op->src_id, op->dest_id); |
539 | 547 | ||
540 | if (NULL != partner->pg) | 548 | if (NULL != partner->pg) |
541 | { | 549 | { |
542 | fprintf (stderr, "Stopping traffic between master %llu slave %llu\n", | 550 | fprintf (stderr, "Stopping traffic between master %llu slave %llu\n", |
543 | op->src_id, op->dest_id); | 551 | op->src_id, op->dest_id); |
544 | GNUNET_ATS_TEST_generate_preferences_stop(partner->pg); | 552 | GNUNET_ATS_TEST_generate_preferences_stop(partner->pg); |
545 | partner->pg = NULL; | 553 | partner->pg = NULL; |
546 | } | 554 | } |
547 | 555 | ||
548 | partner->pg = GNUNET_ATS_TEST_generate_preferences_start(peer, partner, | 556 | partner->pg = GNUNET_ATS_TEST_generate_preferences_start(peer, partner, |
549 | op->tg_type, op->base_rate, op->max_rate, op->period, op->frequency, | 557 | op->tg_type, op->base_rate, op->max_rate, op->period, op->frequency, |
550 | op->pref_type); | 558 | op->pref_type); |
551 | */ | 559 | */ |
552 | } | 560 | } |
553 | 561 | ||
554 | static void | 562 | static void |
555 | enforce_stop_preference (struct GNUNET_ATS_TEST_Operation *op) | 563 | enforce_stop_preference(struct GNUNET_ATS_TEST_Operation *op) |
556 | { | 564 | { |
557 | /* | 565 | /* |
558 | struct BenchmarkPartner *p; | 566 | struct BenchmarkPartner *p; |
559 | p = GNUNET_ATS_TEST_get_partner (op->src_id, op->dest_id); | 567 | p = GNUNET_ATS_TEST_get_partner (op->src_id, op->dest_id); |
560 | if (NULL == p) | 568 | if (NULL == p) |
561 | { | 569 | { |
562 | GNUNET_break (0); | 570 | GNUNET_break (0); |
563 | return; | 571 | return; |
564 | } | 572 | } |
565 | 573 | ||
566 | fprintf (stderr, "Found master %llu slave %llu\n",op->src_id, op->dest_id); | 574 | fprintf (stderr, "Found master %llu slave %llu\n",op->src_id, op->dest_id); |
567 | 575 | ||
568 | if (NULL != p->pg) | 576 | if (NULL != p->pg) |
569 | { | 577 | { |
570 | fprintf (stderr, "Stopping preference between master %llu slave %llu\n", | 578 | fprintf (stderr, "Stopping preference between master %llu slave %llu\n", |
571 | op->src_id, op->dest_id); | 579 | op->src_id, op->dest_id); |
572 | GNUNET_ATS_TEST_generate_preferences_stop (p->pg); | 580 | GNUNET_ATS_TEST_generate_preferences_stop (p->pg); |
573 | p->pg = NULL; | 581 | p->pg = NULL; |
574 | } | 582 | } |
575 | */ | 583 | */ |
576 | } | 584 | } |
577 | 585 | ||
578 | static void enforce_episode (struct Episode *ep) | 586 | static void enforce_episode(struct Episode *ep) |
579 | { | 587 | { |
580 | struct GNUNET_ATS_TEST_Operation *cur; | 588 | struct GNUNET_ATS_TEST_Operation *cur; |
589 | |||
581 | for (cur = ep->head; NULL != cur; cur = cur->next) | 590 | for (cur = ep->head; NULL != cur; cur = cur->next) |
582 | { | 591 | { |
592 | fprintf(stderr, "Enforcing operation: %s [%llu]->[%llu] == %llu\n", | ||
593 | print_op(cur->type), cur->src_id, cur->dest_id, cur->base_rate); | ||
594 | switch (cur->type) | ||
595 | { | ||
596 | case START_SEND: | ||
597 | enforce_start_send(cur); | ||
598 | break; | ||
599 | |||
600 | case STOP_SEND: | ||
601 | enforce_stop_send(cur); | ||
602 | break; | ||
583 | 603 | ||
584 | fprintf (stderr, "Enforcing operation: %s [%llu]->[%llu] == %llu\n", | 604 | case START_PREFERENCE: |
585 | print_op (cur->type), cur->src_id, cur->dest_id, cur->base_rate); | 605 | enforce_start_preference(cur); |
586 | switch (cur->type) { | 606 | break; |
587 | case START_SEND: | 607 | |
588 | enforce_start_send (cur); | 608 | case STOP_PREFERENCE: |
589 | break; | 609 | enforce_stop_preference(cur); |
590 | case STOP_SEND: | 610 | break; |
591 | enforce_stop_send (cur); | 611 | |
592 | break; | 612 | default: |
593 | case START_PREFERENCE: | 613 | break; |
594 | enforce_start_preference (cur); | 614 | } |
595 | break; | ||
596 | case STOP_PREFERENCE: | ||
597 | enforce_stop_preference (cur); | ||
598 | break; | ||
599 | default: | ||
600 | break; | ||
601 | } | 615 | } |
602 | } | ||
603 | } | 616 | } |
604 | 617 | ||
605 | 618 | ||
606 | static void | 619 | static void |
607 | timeout_episode (void *cls) | 620 | timeout_episode(void *cls) |
608 | { | 621 | { |
609 | struct Experiment *e = cls; | 622 | struct Experiment *e = cls; |
623 | |||
610 | e->episode_timeout_task = NULL; | 624 | e->episode_timeout_task = NULL; |
611 | if (NULL != e->ep_done_cb) | 625 | if (NULL != e->ep_done_cb) |
612 | e->ep_done_cb (e->cur); | 626 | e->ep_done_cb(e->cur); |
613 | 627 | ||
614 | /* Scheduling next */ | 628 | /* Scheduling next */ |
615 | e->cur = e->cur->next; | 629 | e->cur = e->cur->next; |
616 | if (NULL == e->cur) | 630 | if (NULL == e->cur) |
617 | { | ||
618 | /* done */ | ||
619 | fprintf (stderr, "Last episode done!\n"); | ||
620 | if (NULL != e->experiment_timeout_task) | ||
621 | { | 631 | { |
622 | GNUNET_SCHEDULER_cancel (e->experiment_timeout_task); | 632 | /* done */ |
623 | e->experiment_timeout_task = NULL; | 633 | fprintf(stderr, "Last episode done!\n"); |
634 | if (NULL != e->experiment_timeout_task) | ||
635 | { | ||
636 | GNUNET_SCHEDULER_cancel(e->experiment_timeout_task); | ||
637 | e->experiment_timeout_task = NULL; | ||
638 | } | ||
639 | e->e_done_cb(e, GNUNET_TIME_absolute_get_duration(e->start_time), GNUNET_OK); | ||
640 | return; | ||
624 | } | 641 | } |
625 | e->e_done_cb (e, GNUNET_TIME_absolute_get_duration(e->start_time), GNUNET_OK); | ||
626 | return; | ||
627 | } | ||
628 | 642 | ||
629 | fprintf (stderr, "Running episode %u with timeout %s\n", | 643 | fprintf(stderr, "Running episode %u with timeout %s\n", |
630 | e->cur->id, | 644 | e->cur->id, |
631 | GNUNET_STRINGS_relative_time_to_string(e->cur->duration, GNUNET_YES)); | 645 | GNUNET_STRINGS_relative_time_to_string(e->cur->duration, GNUNET_YES)); |
632 | enforce_episode(e->cur); | 646 | enforce_episode(e->cur); |
633 | 647 | ||
634 | e->episode_timeout_task = GNUNET_SCHEDULER_add_delayed (e->cur->duration, | 648 | e->episode_timeout_task = GNUNET_SCHEDULER_add_delayed(e->cur->duration, |
635 | &timeout_episode, e); | 649 | &timeout_episode, e); |
636 | } | 650 | } |
637 | 651 | ||
638 | 652 | ||
639 | void | 653 | void |
640 | GNUNET_ATS_solvers_experimentation_run (struct Experiment *e, | 654 | GNUNET_ATS_solvers_experimentation_run(struct Experiment *e, |
641 | GNUNET_ATS_TESTING_EpisodeDoneCallback ep_done_cb, | 655 | GNUNET_ATS_TESTING_EpisodeDoneCallback ep_done_cb, |
642 | GNUNET_ATS_TESTING_ExperimentDoneCallback e_done_cb) | 656 | GNUNET_ATS_TESTING_ExperimentDoneCallback e_done_cb) |
643 | { | 657 | { |
644 | fprintf (stderr, "Running experiment `%s' with timeout %s\n", e->name, | 658 | fprintf(stderr, "Running experiment `%s' with timeout %s\n", e->name, |
645 | GNUNET_STRINGS_relative_time_to_string(e->max_duration, GNUNET_YES)); | 659 | GNUNET_STRINGS_relative_time_to_string(e->max_duration, GNUNET_YES)); |
646 | e->e_done_cb = e_done_cb; | 660 | e->e_done_cb = e_done_cb; |
647 | e->ep_done_cb = ep_done_cb; | 661 | e->ep_done_cb = ep_done_cb; |
648 | e->start_time = GNUNET_TIME_absolute_get(); | 662 | e->start_time = GNUNET_TIME_absolute_get(); |
649 | 663 | ||
650 | /* Start total time out */ | 664 | /* Start total time out */ |
651 | e->experiment_timeout_task = GNUNET_SCHEDULER_add_delayed (e->max_duration, | 665 | e->experiment_timeout_task = GNUNET_SCHEDULER_add_delayed(e->max_duration, |
652 | &timeout_experiment, e); | 666 | &timeout_experiment, e); |
653 | 667 | ||
654 | /* Start */ | 668 | /* Start */ |
655 | e->cur = e->start; | 669 | e->cur = e->start; |
656 | fprintf (stderr, "Running episode %u with timeout %s\n", | 670 | fprintf(stderr, "Running episode %u with timeout %s\n", |
657 | e->cur->id, | 671 | e->cur->id, |
658 | GNUNET_STRINGS_relative_time_to_string(e->cur->duration, GNUNET_YES)); | 672 | GNUNET_STRINGS_relative_time_to_string(e->cur->duration, GNUNET_YES)); |
659 | enforce_episode(e->cur); | 673 | enforce_episode(e->cur); |
660 | e->episode_timeout_task = GNUNET_SCHEDULER_add_delayed (e->cur->duration, | 674 | e->episode_timeout_task = GNUNET_SCHEDULER_add_delayed(e->cur->duration, |
661 | &timeout_episode, e); | 675 | &timeout_episode, e); |
662 | |||
663 | |||
664 | } | 676 | } |
665 | 677 | ||
666 | 678 | ||
667 | struct Experiment * | 679 | struct Experiment * |
668 | GNUNET_ATS_solvers_experimentation_load (char *filename) | 680 | GNUNET_ATS_solvers_experimentation_load(char *filename) |
669 | { | 681 | { |
670 | struct Experiment *e; | 682 | struct Experiment *e; |
671 | struct GNUNET_CONFIGURATION_Handle *cfg; | 683 | struct GNUNET_CONFIGURATION_Handle *cfg; |
684 | |||
672 | e = NULL; | 685 | e = NULL; |
673 | 686 | ||
674 | cfg = GNUNET_CONFIGURATION_create(); | 687 | cfg = GNUNET_CONFIGURATION_create(); |
675 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_load (cfg, filename)) | 688 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_load(cfg, filename)) |
676 | { | 689 | { |
677 | fprintf (stderr, "Failed to load `%s'\n", filename); | 690 | fprintf(stderr, "Failed to load `%s'\n", filename); |
678 | GNUNET_CONFIGURATION_destroy (cfg); | 691 | GNUNET_CONFIGURATION_destroy(cfg); |
679 | return NULL; | 692 | return NULL; |
680 | } | 693 | } |
681 | 694 | ||
682 | e = create_experiment (); | 695 | e = create_experiment(); |
683 | 696 | ||
684 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string(cfg, "experiment", | 697 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string(cfg, "experiment", |
685 | "name", &e->name)) | 698 | "name", &e->name)) |
686 | { | 699 | { |
687 | fprintf (stderr, "Invalid %s", "name"); | 700 | fprintf(stderr, "Invalid %s", "name"); |
688 | free_experiment (e); | 701 | free_experiment(e); |
689 | return NULL; | 702 | return NULL; |
690 | } | 703 | } |
691 | else | 704 | else |
692 | fprintf (stderr, "Experiment name: `%s'\n", e->name); | 705 | fprintf(stderr, "Experiment name: `%s'\n", e->name); |
693 | 706 | ||
694 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_filename (cfg, "experiment", | 707 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_filename(cfg, "experiment", |
695 | "cfg_file", &e->cfg_file)) | 708 | "cfg_file", &e->cfg_file)) |
696 | { | 709 | { |
697 | fprintf (stderr, "Invalid %s", "cfg_file"); | 710 | fprintf(stderr, "Invalid %s", "cfg_file"); |
698 | free_experiment (e); | 711 | free_experiment(e); |
699 | return NULL; | 712 | return NULL; |
700 | } | 713 | } |
701 | else | 714 | else |
702 | fprintf (stderr, "Experiment name: `%s'\n", e->cfg_file); | 715 | fprintf(stderr, "Experiment name: `%s'\n", e->cfg_file); |
703 | 716 | ||
704 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number(cfg, "experiment", | 717 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number(cfg, "experiment", |
705 | "masters", &e->num_masters)) | 718 | "masters", &e->num_masters)) |
706 | { | 719 | { |
707 | fprintf (stderr, "Invalid %s", "masters"); | 720 | fprintf(stderr, "Invalid %s", "masters"); |
708 | free_experiment (e); | 721 | free_experiment(e); |
709 | return NULL; | 722 | return NULL; |
710 | } | 723 | } |
711 | else | 724 | else |
712 | fprintf (stderr, "Experiment masters: `%llu'\n", | 725 | fprintf(stderr, "Experiment masters: `%llu'\n", |
713 | e->num_masters); | 726 | e->num_masters); |
714 | 727 | ||
715 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number(cfg, "experiment", | 728 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number(cfg, "experiment", |
716 | "slaves", &e->num_slaves)) | 729 | "slaves", &e->num_slaves)) |
717 | { | 730 | { |
718 | fprintf (stderr, "Invalid %s", "slaves"); | 731 | fprintf(stderr, "Invalid %s", "slaves"); |
719 | free_experiment (e); | 732 | free_experiment(e); |
720 | return NULL; | 733 | return NULL; |
721 | } | 734 | } |
722 | else | 735 | else |
723 | fprintf (stderr, "Experiment slaves: `%llu'\n", | 736 | fprintf(stderr, "Experiment slaves: `%llu'\n", |
724 | e->num_slaves); | 737 | e->num_slaves); |
725 | 738 | ||
726 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_time(cfg, "experiment", | 739 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_time(cfg, "experiment", |
727 | "log_freq", &e->log_freq)) | 740 | "log_freq", &e->log_freq)) |
728 | { | 741 | { |
729 | fprintf (stderr, "Invalid %s", "log_freq"); | 742 | fprintf(stderr, "Invalid %s", "log_freq"); |
730 | free_experiment (e); | 743 | free_experiment(e); |
731 | return NULL; | 744 | return NULL; |
732 | } | 745 | } |
733 | else | 746 | else |
734 | fprintf (stderr, "Experiment logging frequency: `%s'\n", | 747 | fprintf(stderr, "Experiment logging frequency: `%s'\n", |
735 | GNUNET_STRINGS_relative_time_to_string (e->log_freq, GNUNET_YES)); | 748 | GNUNET_STRINGS_relative_time_to_string(e->log_freq, GNUNET_YES)); |
736 | 749 | ||
737 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_time(cfg, "experiment", | 750 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_time(cfg, "experiment", |
738 | "max_duration", &e->max_duration)) | 751 | "max_duration", &e->max_duration)) |
739 | { | 752 | { |
740 | fprintf (stderr, "Invalid %s", "max_duration"); | 753 | fprintf(stderr, "Invalid %s", "max_duration"); |
741 | free_experiment (e); | 754 | free_experiment(e); |
742 | return NULL; | 755 | return NULL; |
743 | } | 756 | } |
744 | else | 757 | else |
745 | fprintf (stderr, "Experiment duration: `%s'\n", | 758 | fprintf(stderr, "Experiment duration: `%s'\n", |
746 | GNUNET_STRINGS_relative_time_to_string (e->max_duration, GNUNET_YES)); | 759 | GNUNET_STRINGS_relative_time_to_string(e->max_duration, GNUNET_YES)); |
747 | 760 | ||
748 | load_episodes (e, cfg); | 761 | load_episodes(e, cfg); |
749 | fprintf (stderr, "Loaded %u episodes with total duration %s\n", | 762 | fprintf(stderr, "Loaded %u episodes with total duration %s\n", |
750 | e->num_episodes, | 763 | e->num_episodes, |
751 | GNUNET_STRINGS_relative_time_to_string (e->total_duration, GNUNET_YES)); | 764 | GNUNET_STRINGS_relative_time_to_string(e->total_duration, GNUNET_YES)); |
752 | 765 | ||
753 | GNUNET_CONFIGURATION_destroy (cfg); | 766 | GNUNET_CONFIGURATION_destroy(cfg); |
754 | return e; | 767 | return e; |
755 | } | 768 | } |
756 | 769 | ||
757 | void | 770 | void |
758 | GNUNET_ATS_solvers_experimentation_stop (struct Experiment *e) | 771 | GNUNET_ATS_solvers_experimentation_stop(struct Experiment *e) |
759 | { | 772 | { |
760 | if (NULL != e->experiment_timeout_task) | 773 | if (NULL != e->experiment_timeout_task) |
761 | { | 774 | { |
762 | GNUNET_SCHEDULER_cancel (e->experiment_timeout_task); | 775 | GNUNET_SCHEDULER_cancel(e->experiment_timeout_task); |
763 | e->experiment_timeout_task = NULL; | 776 | e->experiment_timeout_task = NULL; |
764 | } | 777 | } |
765 | if (NULL != e->episode_timeout_task) | 778 | if (NULL != e->episode_timeout_task) |
766 | { | 779 | { |
767 | GNUNET_SCHEDULER_cancel (e->episode_timeout_task); | 780 | GNUNET_SCHEDULER_cancel(e->episode_timeout_task); |
768 | e->episode_timeout_task = NULL; | 781 | e->episode_timeout_task = NULL; |
769 | } | 782 | } |
770 | free_experiment (e); | 783 | free_experiment(e); |
771 | } | 784 | } |
772 | 785 | ||
773 | /** | 786 | /** |
774 | * Solver | 787 | * Solver |
775 | */ | 788 | */ |
776 | 789 | ||
777 | struct GNUNET_ATS_TESTING_SolverHandle | 790 | struct GNUNET_ATS_TESTING_SolverHandle { |
778 | { | ||
779 | char * plugin; | 791 | char * plugin; |
780 | struct GNUNET_ATS_PluginEnvironment env; | 792 | struct GNUNET_ATS_PluginEnvironment env; |
781 | void *solver; | 793 | void *solver; |
782 | }; | 794 | }; |
783 | 795 | ||
784 | enum GNUNET_ATS_Solvers | 796 | enum GNUNET_ATS_Solvers { |
785 | { | ||
786 | GNUNET_ATS_SOLVER_PROPORTIONAL, | 797 | GNUNET_ATS_SOLVER_PROPORTIONAL, |
787 | GNUNET_ATS_SOLVER_MLP, | 798 | GNUNET_ATS_SOLVER_MLP, |
788 | GNUNET_ATS_SOLVER_RIL, | 799 | GNUNET_ATS_SOLVER_RIL, |
789 | }; | 800 | }; |
790 | 801 | ||
791 | void | 802 | void |
792 | GNUNET_ATS_solvers_solver_stop (struct GNUNET_ATS_TESTING_SolverHandle *sh) | 803 | GNUNET_ATS_solvers_solver_stop(struct GNUNET_ATS_TESTING_SolverHandle *sh) |
793 | { | 804 | { |
794 | GNUNET_PLUGIN_unload (sh->plugin, sh->solver); | 805 | GNUNET_PLUGIN_unload(sh->plugin, sh->solver); |
795 | GNUNET_free (sh->plugin); | 806 | GNUNET_free(sh->plugin); |
796 | GNUNET_free (sh); | 807 | GNUNET_free(sh); |
797 | } | 808 | } |
798 | 809 | ||
799 | struct GNUNET_ATS_TESTING_SolverHandle * | 810 | struct GNUNET_ATS_TESTING_SolverHandle * |
800 | GNUNET_ATS_solvers_solver_start (enum GNUNET_ATS_Solvers type) | 811 | GNUNET_ATS_solvers_solver_start(enum GNUNET_ATS_Solvers type) |
801 | { | 812 | { |
802 | struct GNUNET_ATS_TESTING_SolverHandle *sh; | 813 | struct GNUNET_ATS_TESTING_SolverHandle *sh; |
803 | char * solver_str; | 814 | char * solver_str; |
804 | 815 | ||
805 | switch (type) { | 816 | switch (type) |
817 | { | ||
806 | case GNUNET_ATS_SOLVER_PROPORTIONAL: | 818 | case GNUNET_ATS_SOLVER_PROPORTIONAL: |
807 | solver_str = "proportional"; | 819 | solver_str = "proportional"; |
808 | break; | 820 | break; |
821 | |||
809 | case GNUNET_ATS_SOLVER_MLP: | 822 | case GNUNET_ATS_SOLVER_MLP: |
810 | solver_str = "mlp"; | 823 | solver_str = "mlp"; |
811 | break; | 824 | break; |
825 | |||
812 | case GNUNET_ATS_SOLVER_RIL: | 826 | case GNUNET_ATS_SOLVER_RIL: |
813 | solver_str = "ril"; | 827 | solver_str = "ril"; |
814 | break; | 828 | break; |
829 | |||
815 | default: | 830 | default: |
816 | GNUNET_break (0); | 831 | GNUNET_break(0); |
817 | return NULL; | 832 | return NULL; |
818 | break; | 833 | break; |
819 | } | 834 | } |
820 | 835 | ||
821 | sh = GNUNET_new (struct GNUNET_ATS_TESTING_SolverHandle); | 836 | sh = GNUNET_new(struct GNUNET_ATS_TESTING_SolverHandle); |
822 | GNUNET_asprintf (&sh->plugin, "libgnunet_plugin_ats_%s", solver_str); | 837 | GNUNET_asprintf(&sh->plugin, "libgnunet_plugin_ats_%s", solver_str); |
823 | //sh->solver = GNUNET_PLUGIN_load (sh->plugin, &sh->env); | 838 | //sh->solver = GNUNET_PLUGIN_load (sh->plugin, &sh->env); |
824 | if (NULL == sh->solver) | 839 | if (NULL == sh->solver) |
825 | { | 840 | { |
826 | fprintf (stderr, "Failed to load solver `%s'\n", sh->plugin); | 841 | fprintf(stderr, "Failed to load solver `%s'\n", sh->plugin); |
827 | exit (1); | 842 | exit(1); |
828 | } | 843 | } |
829 | 844 | ||
830 | return sh; | 845 | return sh; |
831 | } | 846 | } |
@@ -857,56 +872,56 @@ static int opt_plot; | |||
857 | static int opt_verbose; | 872 | static int opt_verbose; |
858 | 873 | ||
859 | static void | 874 | static void |
860 | run (void *cls, char * const *args, const char *cfgfile, | 875 | run(void *cls, char * const *args, const char *cfgfile, |
861 | const struct GNUNET_CONFIGURATION_Handle *cfg) | 876 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
862 | { | 877 | { |
863 | enum GNUNET_ATS_Solvers solver; | 878 | enum GNUNET_ATS_Solvers solver; |
864 | 879 | ||
865 | if (NULL == opt_exp_file) | 880 | if (NULL == opt_exp_file) |
866 | { | 881 | { |
867 | fprintf (stderr, "No experiment given ...\n"); | 882 | fprintf(stderr, "No experiment given ...\n"); |
868 | exit (1); | 883 | exit(1); |
869 | } | 884 | } |
870 | 885 | ||
871 | if (NULL == opt_solver) | 886 | if (NULL == opt_solver) |
872 | { | 887 | { |
873 | fprintf (stderr, "No solver given ...\n"); | 888 | fprintf(stderr, "No solver given ...\n"); |
874 | exit (1); | 889 | exit(1); |
875 | } | 890 | } |
876 | 891 | ||
877 | if (0 == strcmp(opt_solver, "mlp")) | 892 | if (0 == strcmp(opt_solver, "mlp")) |
878 | { | 893 | { |
879 | solver = GNUNET_ATS_SOLVER_MLP; | 894 | solver = GNUNET_ATS_SOLVER_MLP; |
880 | } | 895 | } |
881 | else if (0 == strcmp(opt_solver, "proportional")) | 896 | else if (0 == strcmp(opt_solver, "proportional")) |
882 | { | 897 | { |
883 | solver = GNUNET_ATS_SOLVER_PROPORTIONAL; | 898 | solver = GNUNET_ATS_SOLVER_PROPORTIONAL; |
884 | } | 899 | } |
885 | else if (0 == strcmp(opt_solver, "ril")) | 900 | else if (0 == strcmp(opt_solver, "ril")) |
886 | { | 901 | { |
887 | solver = GNUNET_ATS_SOLVER_RIL; | 902 | solver = GNUNET_ATS_SOLVER_RIL; |
888 | } | 903 | } |
889 | else | 904 | else |
890 | { | 905 | { |
891 | fprintf (stderr, "No solver given ..."); | 906 | fprintf(stderr, "No solver given ..."); |
892 | return; | 907 | return; |
893 | } | 908 | } |
894 | 909 | ||
895 | /* load experiment */ | 910 | /* load experiment */ |
896 | e = GNUNET_ATS_solvers_experimentation_load (opt_exp_file); | 911 | e = GNUNET_ATS_solvers_experimentation_load(opt_exp_file); |
897 | if (NULL == e) | 912 | if (NULL == e) |
898 | { | 913 | { |
899 | fprintf (stderr, "Failed to load experiment ...\n"); | 914 | fprintf(stderr, "Failed to load experiment ...\n"); |
900 | return; | 915 | return; |
901 | } | 916 | } |
902 | 917 | ||
903 | /* load solver */ | 918 | /* load solver */ |
904 | sh = GNUNET_ATS_solvers_solver_start (solver); | 919 | sh = GNUNET_ATS_solvers_solver_start(solver); |
905 | if (NULL == sh) | 920 | if (NULL == sh) |
906 | { | 921 | { |
907 | fprintf (stderr, "Failed to start solver ...\n"); | 922 | fprintf(stderr, "Failed to start solver ...\n"); |
908 | return; | 923 | return; |
909 | } | 924 | } |
910 | 925 | ||
911 | /* start logging */ | 926 | /* start logging */ |
912 | 927 | ||
@@ -923,9 +938,8 @@ run (void *cls, char * const *args, const char *cfgfile, | |||
923 | * @param argv argument values | 938 | * @param argv argument values |
924 | */ | 939 | */ |
925 | int | 940 | int |
926 | main (int argc, char *argv[]) | 941 | main(int argc, char *argv[]) |
927 | { | 942 | { |
928 | |||
929 | opt_exp_file = NULL; | 943 | opt_exp_file = NULL; |
930 | opt_solver = NULL; | 944 | opt_solver = NULL; |
931 | opt_log = GNUNET_NO; | 945 | opt_log = GNUNET_NO; |
@@ -933,31 +947,31 @@ main (int argc, char *argv[]) | |||
933 | 947 | ||
934 | struct GNUNET_GETOPT_CommandLineOption options[] = | 948 | struct GNUNET_GETOPT_CommandLineOption options[] = |
935 | { | 949 | { |
936 | GNUNET_GETOPT_option_string ('s', | 950 | GNUNET_GETOPT_option_string('s', |
937 | "solver", | 951 | "solver", |
938 | NULL, | 952 | NULL, |
939 | gettext_noop ("solver to use"), | 953 | gettext_noop("solver to use"), |
940 | &opt_solver), | 954 | &opt_solver), |
941 | 955 | ||
942 | GNUNET_GETOPT_option_string ('e', | 956 | GNUNET_GETOPT_option_string('e', |
943 | "experiment", | 957 | "experiment", |
944 | NULL, | 958 | NULL, |
945 | gettext_noop ("experiment to use"), | 959 | gettext_noop("experiment to use"), |
946 | &opt_exp_file), | 960 | &opt_exp_file), |
947 | 961 | ||
948 | GNUNET_GETOPT_option_flag ('e', | 962 | GNUNET_GETOPT_option_flag('e', |
949 | "experiment", | 963 | "experiment", |
950 | gettext_noop ("experiment to use"), | 964 | gettext_noop("experiment to use"), |
951 | &opt_verbose), | 965 | &opt_verbose), |
952 | GNUNET_GETOPT_OPTION_END | 966 | GNUNET_GETOPT_OPTION_END |
953 | }; | 967 | }; |
954 | 968 | ||
955 | if (GNUNET_OK != | 969 | if (GNUNET_OK != |
956 | GNUNET_PROGRAM_run (argc, | 970 | GNUNET_PROGRAM_run(argc, |
957 | argv, argv[0], | 971 | argv, argv[0], |
958 | NULL, | 972 | NULL, |
959 | options, | 973 | options, |
960 | &run, argv[0])) | 974 | &run, argv[0])) |
961 | return 1; | 975 | return 1; |
962 | 976 | ||
963 | return 0; | 977 | return 0; |
diff --git a/src/ats-tests/perf_ats.c b/src/ats-tests/perf_ats.c index b8ab35f99..c31e8a1c4 100644 --- a/src/ats-tests/perf_ats.c +++ b/src/ats-tests/perf_ats.c | |||
@@ -1,19 +1,19 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2010-2013, 2016 GNUnet e.V. | 3 | Copyright (C) 2010-2013, 2016 GNUnet e.V. |
4 | 4 | ||
5 | GNUnet is free software: you can redistribute it and/or modify it | 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 | 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, | 7 | by the Free Software Foundation, either version 3 of the License, |
8 | or (at your option) any later version. | 8 | or (at your option) any later version. |
9 | 9 | ||
10 | GNUnet is distributed in the hope that it will be useful, but | 10 | GNUnet is distributed in the hope that it will be useful, but |
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Affero General Public License for more details. | 13 | Affero General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Affero General Public License | 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/>. | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | 17 | ||
18 | SPDX-License-Identifier: AGPL3.0-or-later | 18 | SPDX-License-Identifier: AGPL3.0-or-later |
19 | */ | 19 | */ |
@@ -31,15 +31,15 @@ | |||
31 | #include "ats-testing.h" | 31 | #include "ats-testing.h" |
32 | 32 | ||
33 | 33 | ||
34 | #define TEST_ATS_PREFRENCE_FREQUENCY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1) | 34 | #define TEST_ATS_PREFRENCE_FREQUENCY GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 1) |
35 | #define TEST_ATS_PREFRENCE_START 1.0 | 35 | #define TEST_ATS_PREFRENCE_START 1.0 |
36 | #define TEST_ATS_PREFRENCE_DELTA 1.0 | 36 | #define TEST_ATS_PREFRENCE_DELTA 1.0 |
37 | 37 | ||
38 | #define TEST_MESSAGE_FREQUENCY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1) | 38 | #define TEST_MESSAGE_FREQUENCY GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 1) |
39 | 39 | ||
40 | #define TEST_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 120) | 40 | #define TEST_TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 120) |
41 | #define BENCHMARK_DURATION GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10) | 41 | #define BENCHMARK_DURATION GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 10) |
42 | #define LOGGING_FREQUENCY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 500) | 42 | #define LOGGING_FREQUENCY GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 500) |
43 | #define TESTNAME_PREFIX "perf_ats_" | 43 | #define TESTNAME_PREFIX "perf_ats_" |
44 | #define DEFAULT_SLAVES_NUM 2 | 44 | #define DEFAULT_SLAVES_NUM 2 |
45 | #define DEFAULT_MASTERS_NUM 1 | 45 | #define DEFAULT_MASTERS_NUM 1 |
@@ -123,7 +123,7 @@ static struct LoggingHandle *l; | |||
123 | 123 | ||
124 | 124 | ||
125 | static void | 125 | static void |
126 | evaluate () | 126 | evaluate() |
127 | { | 127 | { |
128 | int c_m; | 128 | int c_m; |
129 | int c_s; | 129 | int c_s; |
@@ -139,48 +139,48 @@ evaluate () | |||
139 | 139 | ||
140 | duration = 1 + (perf_duration.rel_value_us / (1000 * 1000)); | 140 | duration = 1 + (perf_duration.rel_value_us / (1000 * 1000)); |
141 | for (c_m = 0; c_m < num_masters; c_m++) | 141 | for (c_m = 0; c_m < num_masters; c_m++) |
142 | { | ||
143 | mp = &mps[c_m]; | ||
144 | fprintf (stderr, | ||
145 | "Master [%u]: sent: %u KiB in %u sec. = %u KiB/s, received: %u KiB in %u sec. = %u KiB/s\n", | ||
146 | mp->no, mp->total_bytes_sent / 1024, duration, | ||
147 | (mp->total_bytes_sent / 1024) / duration, | ||
148 | mp->total_bytes_received / 1024, duration, | ||
149 | (mp->total_bytes_received / 1024) / duration); | ||
150 | |||
151 | for (c_s = 0; c_s < num_slaves; c_s++) | ||
152 | { | 142 | { |
153 | p = &mp->partners[c_s]; | 143 | mp = &mps[c_m]; |
154 | kb_sent_sec = 0; | 144 | fprintf(stderr, |
155 | kb_recv_sec = 0; | 145 | "Master [%u]: sent: %u KiB in %u sec. = %u KiB/s, received: %u KiB in %u sec. = %u KiB/s\n", |
156 | kb_sent_percent = 0.0; | 146 | mp->no, mp->total_bytes_sent / 1024, duration, |
157 | kb_recv_percent = 0.0; | 147 | (mp->total_bytes_sent / 1024) / duration, |
158 | rtt = 0; | 148 | mp->total_bytes_received / 1024, duration, |
159 | 149 | (mp->total_bytes_received / 1024) / duration); | |
160 | if (duration > 0) | 150 | |
161 | { | 151 | for (c_s = 0; c_s < num_slaves; c_s++) |
162 | kb_sent_sec = (p->bytes_sent / 1024) / duration; | 152 | { |
163 | kb_recv_sec = (p->bytes_received / 1024) / duration; | 153 | p = &mp->partners[c_s]; |
164 | } | 154 | kb_sent_sec = 0; |
165 | 155 | kb_recv_sec = 0; | |
166 | if (mp->total_bytes_sent > 0) | 156 | kb_sent_percent = 0.0; |
167 | kb_sent_percent = ((double) p->bytes_sent * 100) / mp->total_bytes_sent; | 157 | kb_recv_percent = 0.0; |
168 | if (mp->total_bytes_received > 0) | 158 | rtt = 0; |
169 | kb_recv_percent = ((double) p->bytes_received * 100) / mp->total_bytes_received; | 159 | |
170 | if (1000 * p->messages_sent > 0) | 160 | if (duration > 0) |
171 | rtt = p->total_app_rtt / (1000 * p->messages_sent); | 161 | { |
172 | fprintf (stderr, | 162 | kb_sent_sec = (p->bytes_sent / 1024) / duration; |
173 | "%c Master [%u] -> Slave [%u]: sent %u KiB/s (%.2f %%), received %u KiB/s (%.2f %%)\n", | 163 | kb_recv_sec = (p->bytes_received / 1024) / duration; |
174 | (mp->pref_partner == p->dest) ? '*' : ' ', | 164 | } |
175 | mp->no, p->dest->no, | 165 | |
176 | kb_sent_sec, kb_sent_percent, | 166 | if (mp->total_bytes_sent > 0) |
177 | kb_recv_sec, kb_recv_percent); | 167 | kb_sent_percent = ((double)p->bytes_sent * 100) / mp->total_bytes_sent; |
178 | fprintf (stderr, | 168 | if (mp->total_bytes_received > 0) |
179 | "%c Master [%u] -> Slave [%u]: Average application layer RTT: %u ms\n", | 169 | kb_recv_percent = ((double)p->bytes_received * 100) / mp->total_bytes_received; |
180 | (mp->pref_partner == p->dest) ? '*' : ' ', | 170 | if (1000 * p->messages_sent > 0) |
181 | mp->no, p->dest->no, rtt); | 171 | rtt = p->total_app_rtt / (1000 * p->messages_sent); |
172 | fprintf(stderr, | ||
173 | "%c Master [%u] -> Slave [%u]: sent %u KiB/s (%.2f %%), received %u KiB/s (%.2f %%)\n", | ||
174 | (mp->pref_partner == p->dest) ? '*' : ' ', | ||
175 | mp->no, p->dest->no, | ||
176 | kb_sent_sec, kb_sent_percent, | ||
177 | kb_recv_sec, kb_recv_percent); | ||
178 | fprintf(stderr, | ||
179 | "%c Master [%u] -> Slave [%u]: Average application layer RTT: %u ms\n", | ||
180 | (mp->pref_partner == p->dest) ? '*' : ' ', | ||
181 | mp->no, p->dest->no, rtt); | ||
182 | } | ||
182 | } | 183 | } |
183 | } | ||
184 | } | 184 | } |
185 | 185 | ||
186 | 186 | ||
@@ -190,24 +190,24 @@ evaluate () | |||
190 | * @param cls NULL | 190 | * @param cls NULL |
191 | */ | 191 | */ |
192 | static void | 192 | static void |
193 | do_shutdown (void *cls) | 193 | do_shutdown(void *cls) |
194 | { | 194 | { |
195 | if (GNUNET_YES == logging) | 195 | if (GNUNET_YES == logging) |
196 | GNUNET_ATS_TEST_logging_clean_up(l); | 196 | GNUNET_ATS_TEST_logging_clean_up(l); |
197 | if (NULL != timeout_task) | 197 | if (NULL != timeout_task) |
198 | { | 198 | { |
199 | GNUNET_SCHEDULER_cancel (timeout_task); | 199 | GNUNET_SCHEDULER_cancel(timeout_task); |
200 | timeout_task = NULL; | 200 | timeout_task = NULL; |
201 | } | 201 | } |
202 | if (NULL != progress_task) | 202 | if (NULL != progress_task) |
203 | { | 203 | { |
204 | fprintf (stderr, "0\n"); | 204 | fprintf(stderr, "0\n"); |
205 | GNUNET_SCHEDULER_cancel (progress_task); | 205 | GNUNET_SCHEDULER_cancel(progress_task); |
206 | progress_task = NULL; | 206 | progress_task = NULL; |
207 | } | 207 | } |
208 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 208 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, |
209 | "Benchmarking done\n"); | 209 | "Benchmarking done\n"); |
210 | GNUNET_ATS_TEST_shutdown_topology (); | 210 | GNUNET_ATS_TEST_shutdown_topology(); |
211 | } | 211 | } |
212 | 212 | ||
213 | 213 | ||
@@ -217,162 +217,163 @@ do_shutdown (void *cls) | |||
217 | * @param cls NULL | 217 | * @param cls NULL |
218 | */ | 218 | */ |
219 | static void | 219 | static void |
220 | do_timeout (void *cls) | 220 | do_timeout(void *cls) |
221 | { | 221 | { |
222 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 222 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, |
223 | "Terminating with timeout\n"); | 223 | "Terminating with timeout\n"); |
224 | timeout_task = NULL; | 224 | timeout_task = NULL; |
225 | evaluate (); | 225 | evaluate(); |
226 | GNUNET_SCHEDULER_shutdown (); | 226 | GNUNET_SCHEDULER_shutdown(); |
227 | } | 227 | } |
228 | 228 | ||
229 | 229 | ||
230 | static void | 230 | static void |
231 | print_progress (void *cls) | 231 | print_progress(void *cls) |
232 | { | 232 | { |
233 | static int calls; | 233 | static int calls; |
234 | 234 | ||
235 | progress_task = NULL; | 235 | progress_task = NULL; |
236 | fprintf (stderr, | 236 | fprintf(stderr, |
237 | "%llu..", | 237 | "%llu..", |
238 | (long long unsigned) perf_duration.rel_value_us / (1000 * 1000) - calls); | 238 | (long long unsigned)perf_duration.rel_value_us / (1000 * 1000) - calls); |
239 | calls++; | 239 | calls++; |
240 | 240 | ||
241 | progress_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, | 241 | progress_task = GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_UNIT_SECONDS, |
242 | &print_progress, | 242 | &print_progress, |
243 | NULL); | 243 | NULL); |
244 | } | 244 | } |
245 | 245 | ||
246 | 246 | ||
247 | static void | 247 | static void |
248 | ats_pref_task (void *cls) | 248 | ats_pref_task(void *cls) |
249 | { | 249 | { |
250 | struct BenchmarkPeer *me = cls; | 250 | struct BenchmarkPeer *me = cls; |
251 | 251 | ||
252 | me->ats_task = NULL; | 252 | me->ats_task = NULL; |
253 | 253 | ||
254 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, " Master [%u] set preference for slave [%u] to %f\n", | 254 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, " Master [%u] set preference for slave [%u] to %f\n", |
255 | me->no, me->pref_partner->no, me->pref_value); | 255 | me->no, me->pref_partner->no, me->pref_value); |
256 | GNUNET_ATS_performance_change_preference (me->ats_perf_handle, | 256 | GNUNET_ATS_performance_change_preference(me->ats_perf_handle, |
257 | &me->pref_partner->id, | 257 | &me->pref_partner->id, |
258 | pref_val, me->pref_value, GNUNET_ATS_PREFERENCE_END); | 258 | pref_val, me->pref_value, GNUNET_ATS_PREFERENCE_END); |
259 | me->pref_value += TEST_ATS_PREFRENCE_DELTA; | 259 | me->pref_value += TEST_ATS_PREFRENCE_DELTA; |
260 | me->ats_task = GNUNET_SCHEDULER_add_delayed (TEST_ATS_PREFRENCE_FREQUENCY, | 260 | me->ats_task = GNUNET_SCHEDULER_add_delayed(TEST_ATS_PREFRENCE_FREQUENCY, |
261 | &ats_pref_task, cls); | 261 | &ats_pref_task, cls); |
262 | } | 262 | } |
263 | 263 | ||
264 | 264 | ||
265 | static void | 265 | static void |
266 | start_benchmark (void *cls) | 266 | start_benchmark(void *cls) |
267 | { | 267 | { |
268 | int c_m; | 268 | int c_m; |
269 | int c_s; | 269 | int c_s; |
270 | 270 | ||
271 | progress_task = GNUNET_SCHEDULER_add_now (&print_progress, | 271 | progress_task = GNUNET_SCHEDULER_add_now(&print_progress, |
272 | NULL); | 272 | NULL); |
273 | 273 | ||
274 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, | 274 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, |
275 | "Topology connected, start benchmarking...\n"); | 275 | "Topology connected, start benchmarking...\n"); |
276 | 276 | ||
277 | /* Start sending test messages */ | 277 | /* Start sending test messages */ |
278 | for (c_m = 0; c_m < num_masters; c_m++) | 278 | for (c_m = 0; c_m < num_masters; c_m++) |
279 | { | ||
280 | for (c_s = 0; c_s < num_slaves; c_s++) | ||
281 | { | 279 | { |
282 | GNUNET_ATS_TEST_generate_traffic_start (&mps[c_m], | 280 | for (c_s = 0; c_s < num_slaves; c_s++) |
283 | &mps[c_m].partners[c_s], | 281 | { |
284 | GNUNET_ATS_TEST_TG_LINEAR, | 282 | GNUNET_ATS_TEST_generate_traffic_start(&mps[c_m], |
285 | UINT32_MAX, | 283 | &mps[c_m].partners[c_s], |
286 | UINT32_MAX, | 284 | GNUNET_ATS_TEST_TG_LINEAR, |
287 | GNUNET_TIME_UNIT_MINUTES, | 285 | UINT32_MAX, |
288 | GNUNET_TIME_UNIT_FOREVER_REL); | 286 | UINT32_MAX, |
287 | GNUNET_TIME_UNIT_MINUTES, | ||
288 | GNUNET_TIME_UNIT_FOREVER_REL); | ||
289 | } | ||
290 | if (pref_val != GNUNET_ATS_PREFERENCE_END) | ||
291 | mps[c_m].ats_task = GNUNET_SCHEDULER_add_now(&ats_pref_task, | ||
292 | &mps[c_m]); | ||
289 | } | 293 | } |
290 | if (pref_val != GNUNET_ATS_PREFERENCE_END) | ||
291 | mps[c_m].ats_task = GNUNET_SCHEDULER_add_now (&ats_pref_task, | ||
292 | &mps[c_m]); | ||
293 | } | ||
294 | 294 | ||
295 | if (GNUNET_YES == logging) | 295 | if (GNUNET_YES == logging) |
296 | l = GNUNET_ATS_TEST_logging_start (log_frequency, | 296 | l = GNUNET_ATS_TEST_logging_start(log_frequency, |
297 | testname, mps, | 297 | testname, mps, |
298 | num_masters, num_slaves, | 298 | num_masters, num_slaves, |
299 | GNUNET_NO); | 299 | GNUNET_NO); |
300 | } | 300 | } |
301 | 301 | ||
302 | 302 | ||
303 | static void | 303 | static void |
304 | do_benchmark (void *cls, | 304 | do_benchmark(void *cls, |
305 | struct BenchmarkPeer *masters, | 305 | struct BenchmarkPeer *masters, |
306 | struct BenchmarkPeer *slaves) | 306 | struct BenchmarkPeer *slaves) |
307 | { | 307 | { |
308 | mps = masters; | 308 | mps = masters; |
309 | sps = slaves; | 309 | sps = slaves; |
310 | GNUNET_SCHEDULER_add_shutdown (&do_shutdown, | 310 | GNUNET_SCHEDULER_add_shutdown(&do_shutdown, |
311 | NULL); | 311 | NULL); |
312 | timeout_task = GNUNET_SCHEDULER_add_delayed (perf_duration, | 312 | timeout_task = GNUNET_SCHEDULER_add_delayed(perf_duration, |
313 | &do_timeout, | 313 | &do_timeout, |
314 | NULL); | 314 | NULL); |
315 | progress_task = GNUNET_SCHEDULER_add_now (&start_benchmark, | 315 | progress_task = GNUNET_SCHEDULER_add_now(&start_benchmark, |
316 | NULL); | 316 | NULL); |
317 | } | 317 | } |
318 | 318 | ||
319 | 319 | ||
320 | static struct BenchmarkPartner * | 320 | static struct BenchmarkPartner * |
321 | find_partner (struct BenchmarkPeer *me, | 321 | find_partner(struct BenchmarkPeer *me, |
322 | const struct GNUNET_PeerIdentity *peer) | 322 | const struct GNUNET_PeerIdentity *peer) |
323 | { | 323 | { |
324 | int c_m; | 324 | int c_m; |
325 | GNUNET_assert (NULL != me); | 325 | |
326 | GNUNET_assert (NULL != peer); | 326 | GNUNET_assert(NULL != me); |
327 | GNUNET_assert(NULL != peer); | ||
327 | 328 | ||
328 | for (c_m = 0; c_m < me->num_partners; c_m++) | 329 | for (c_m = 0; c_m < me->num_partners; c_m++) |
329 | { | ||
330 | /* Find a partner with other as destination */ | ||
331 | if (0 == GNUNET_memcmp (peer, &me->partners[c_m].dest->id)) | ||
332 | { | 330 | { |
333 | return &me->partners[c_m]; | 331 | /* Find a partner with other as destination */ |
332 | if (0 == GNUNET_memcmp(peer, &me->partners[c_m].dest->id)) | ||
333 | { | ||
334 | return &me->partners[c_m]; | ||
335 | } | ||
334 | } | 336 | } |
335 | } | ||
336 | return NULL; | 337 | return NULL; |
337 | } | 338 | } |
338 | 339 | ||
339 | 340 | ||
340 | static void | 341 | static void |
341 | log_request_cb (void *cls, | 342 | log_request_cb(void *cls, |
342 | const struct GNUNET_HELLO_Address *address, | 343 | const struct GNUNET_HELLO_Address *address, |
343 | int address_active, | 344 | int address_active, |
344 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, | 345 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, |
345 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, | 346 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, |
346 | const struct GNUNET_ATS_Properties *ats) | 347 | const struct GNUNET_ATS_Properties *ats) |
347 | { | 348 | { |
348 | struct BenchmarkPeer *me = cls; | 349 | struct BenchmarkPeer *me = cls; |
349 | struct BenchmarkPartner *p; | 350 | struct BenchmarkPartner *p; |
350 | char *peer_id; | 351 | char *peer_id; |
351 | 352 | ||
352 | p = find_partner (me, &address->peer); | 353 | p = find_partner(me, &address->peer); |
353 | if (NULL == p) | 354 | if (NULL == p) |
354 | { | 355 | { |
355 | /* This is not one of my partners | 356 | /* This is not one of my partners |
356 | * Will happen since the peers will connect to each other due to gossiping | 357 | * Will happen since the peers will connect to each other due to gossiping |
357 | */ | 358 | */ |
358 | return; | 359 | return; |
359 | } | 360 | } |
360 | peer_id = GNUNET_strdup (GNUNET_i2s (&me->id)); | 361 | peer_id = GNUNET_strdup(GNUNET_i2s(&me->id)); |
361 | 362 | ||
362 | if ((p->bandwidth_in != ntohl (bandwidth_in.value__)) || | 363 | if ((p->bandwidth_in != ntohl(bandwidth_in.value__)) || |
363 | (p->bandwidth_out != ntohl (bandwidth_out.value__))) | 364 | (p->bandwidth_out != ntohl(bandwidth_out.value__))) |
364 | p->bandwidth_in = ntohl (bandwidth_in.value__); | 365 | p->bandwidth_in = ntohl(bandwidth_in.value__); |
365 | p->bandwidth_out = ntohl (bandwidth_out.value__); | 366 | p->bandwidth_out = ntohl(bandwidth_out.value__); |
366 | 367 | ||
367 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 368 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
368 | "%s [%u] received ATS information for peers `%s'\n", | 369 | "%s [%u] received ATS information for peers `%s'\n", |
369 | (GNUNET_YES == p->me->master) ? "Master" : "Slave", | 370 | (GNUNET_YES == p->me->master) ? "Master" : "Slave", |
370 | p->me->no, | 371 | p->me->no, |
371 | GNUNET_i2s (&p->dest->id)); | 372 | GNUNET_i2s(&p->dest->id)); |
372 | 373 | ||
373 | GNUNET_free (peer_id); | 374 | GNUNET_free(peer_id); |
374 | if (NULL != l) | 375 | if (NULL != l) |
375 | GNUNET_ATS_TEST_logging_now (l); | 376 | GNUNET_ATS_TEST_logging_now(l); |
376 | } | 377 | } |
377 | 378 | ||
378 | 379 | ||
@@ -380,7 +381,7 @@ log_request_cb (void *cls, | |||
380 | * Start the performance test case | 381 | * Start the performance test case |
381 | */ | 382 | */ |
382 | int | 383 | int |
383 | main (int argc, char *argv[]) | 384 | main(int argc, char *argv[]) |
384 | { | 385 | { |
385 | char *tmp; | 386 | char *tmp; |
386 | char *tmp_sep; | 387 | char *tmp_sep; |
@@ -397,187 +398,187 @@ main (int argc, char *argv[]) | |||
397 | * perf_ats_<solver>_<transport>_<preference>[.exe]*/ | 398 | * perf_ats_<solver>_<transport>_<preference>[.exe]*/ |
398 | 399 | ||
399 | /* Find test prefix, store in temp */ | 400 | /* Find test prefix, store in temp */ |
400 | tmp = strstr (argv[0], TESTNAME_PREFIX); | 401 | tmp = strstr(argv[0], TESTNAME_PREFIX); |
401 | if (NULL == tmp) | 402 | if (NULL == tmp) |
402 | { | 403 | { |
403 | fprintf (stderr, "Unable to parse test name `%s'\n", argv[0]); | 404 | fprintf(stderr, "Unable to parse test name `%s'\n", argv[0]); |
404 | return GNUNET_SYSERR; | 405 | return GNUNET_SYSERR; |
405 | } | 406 | } |
406 | 407 | ||
407 | /* Set tmp to end of test name prefix */ | 408 | /* Set tmp to end of test name prefix */ |
408 | tmp += strlen (TESTNAME_PREFIX); | 409 | tmp += strlen(TESTNAME_PREFIX); |
409 | 410 | ||
410 | /* Determine solver name */ | 411 | /* Determine solver name */ |
411 | solver = GNUNET_strdup (tmp); | 412 | solver = GNUNET_strdup(tmp); |
412 | /* Remove .exe prefix */ | 413 | /* Remove .exe prefix */ |
413 | if (NULL != (dotexe = strstr (solver, ".exe")) && dotexe[4] == '\0') | 414 | if (NULL != (dotexe = strstr(solver, ".exe")) && dotexe[4] == '\0') |
414 | dotexe[0] = '\0'; | 415 | dotexe[0] = '\0'; |
415 | 416 | ||
416 | /* Determine first '_' after solver */ | 417 | /* Determine first '_' after solver */ |
417 | tmp_sep = strchr (solver, '_'); | 418 | tmp_sep = strchr(solver, '_'); |
418 | if (NULL == tmp_sep) | 419 | if (NULL == tmp_sep) |
419 | { | 420 | { |
420 | fprintf (stderr, "Unable to parse test name `%s'\n", argv[0]); | 421 | fprintf(stderr, "Unable to parse test name `%s'\n", argv[0]); |
421 | GNUNET_free(solver); | 422 | GNUNET_free(solver); |
422 | return GNUNET_SYSERR; | 423 | return GNUNET_SYSERR; |
423 | } | 424 | } |
424 | tmp_sep[0] = '\0'; | 425 | tmp_sep[0] = '\0'; |
425 | comm_name = GNUNET_strdup (&tmp_sep[1]); | 426 | comm_name = GNUNET_strdup(&tmp_sep[1]); |
426 | tmp_sep = strchr (comm_name, '_'); | 427 | tmp_sep = strchr(comm_name, '_'); |
427 | if (NULL == tmp_sep) | 428 | if (NULL == tmp_sep) |
428 | { | 429 | { |
429 | fprintf (stderr, "Unable to parse test name `%s'\n", argv[0]); | 430 | fprintf(stderr, "Unable to parse test name `%s'\n", argv[0]); |
430 | GNUNET_free(solver); | 431 | GNUNET_free(solver); |
431 | return GNUNET_SYSERR; | 432 | return GNUNET_SYSERR; |
432 | } | 433 | } |
433 | tmp_sep[0] = '\0'; | 434 | tmp_sep[0] = '\0'; |
434 | for (c = 0; c <= strlen (comm_name); c++) | 435 | for (c = 0; c <= strlen(comm_name); c++) |
435 | comm_name[c] = toupper (comm_name[c]); | 436 | comm_name[c] = toupper(comm_name[c]); |
436 | if (0 == strcmp (comm_name, "CORE")) | 437 | if (0 == strcmp(comm_name, "CORE")) |
437 | test_core = GNUNET_YES; | 438 | test_core = GNUNET_YES; |
438 | else if (0 == strcmp (comm_name, "TRANSPORT")) | 439 | else if (0 == strcmp(comm_name, "TRANSPORT")) |
439 | test_core = GNUNET_NO; | 440 | test_core = GNUNET_NO; |
440 | else | 441 | else |
441 | { | 442 | { |
442 | GNUNET_free (comm_name); | 443 | GNUNET_free(comm_name); |
443 | GNUNET_free (solver); | 444 | GNUNET_free(solver); |
444 | return GNUNET_SYSERR; | 445 | return GNUNET_SYSERR; |
445 | } | 446 | } |
446 | 447 | ||
447 | pref_str = GNUNET_strdup(tmp_sep + 1); | 448 | pref_str = GNUNET_strdup(tmp_sep + 1); |
448 | 449 | ||
449 | GNUNET_asprintf (&conf_name, "%s%s_%s.conf", TESTNAME_PREFIX, solver, | 450 | GNUNET_asprintf(&conf_name, "%s%s_%s.conf", TESTNAME_PREFIX, solver, |
450 | pref_str); | 451 | pref_str); |
451 | GNUNET_asprintf (&test_name, "%s%s_%s", TESTNAME_PREFIX, solver, pref_str); | 452 | GNUNET_asprintf(&test_name, "%s%s_%s", TESTNAME_PREFIX, solver, pref_str); |
452 | 453 | ||
453 | for (c = 0; c <= strlen (pref_str); c++) | 454 | for (c = 0; c <= strlen(pref_str); c++) |
454 | pref_str[c] = toupper (pref_str[c]); | 455 | pref_str[c] = toupper(pref_str[c]); |
455 | pref_val = -1; | 456 | pref_val = -1; |
456 | 457 | ||
457 | if (0 != strcmp (pref_str, "NONE")) | 458 | if (0 != strcmp(pref_str, "NONE")) |
458 | { | ||
459 | for (c = 0; c < GNUNET_ATS_PREFERENCE_END; c++) | ||
460 | { | 459 | { |
461 | if (0 == strcmp (pref_str, prefs[c])) | 460 | for (c = 0; c < GNUNET_ATS_PREFERENCE_END; c++) |
462 | { | 461 | { |
463 | pref_val = c; | 462 | if (0 == strcmp(pref_str, prefs[c])) |
464 | break; | 463 | { |
465 | } | 464 | pref_val = c; |
465 | break; | ||
466 | } | ||
467 | } | ||
466 | } | 468 | } |
467 | } | ||
468 | else | 469 | else |
469 | { | 470 | { |
470 | /* abuse terminator to indicate no pref */ | 471 | /* abuse terminator to indicate no pref */ |
471 | pref_val = GNUNET_ATS_PREFERENCE_END; | 472 | pref_val = GNUNET_ATS_PREFERENCE_END; |
472 | } | 473 | } |
473 | if (-1 == pref_val) | 474 | if (-1 == pref_val) |
474 | { | 475 | { |
475 | fprintf (stderr, "Unknown preference: `%s'\n", pref_str); | 476 | fprintf(stderr, "Unknown preference: `%s'\n", pref_str); |
476 | GNUNET_free(solver); | 477 | GNUNET_free(solver); |
477 | GNUNET_free(pref_str); | 478 | GNUNET_free(pref_str); |
478 | GNUNET_free (comm_name); | 479 | GNUNET_free(comm_name); |
479 | return -1; | 480 | return -1; |
480 | } | 481 | } |
481 | 482 | ||
482 | for (c = 0; c < (argc - 1); c++) | 483 | for (c = 0; c < (argc - 1); c++) |
483 | { | 484 | { |
484 | if (0 == strcmp (argv[c], "-d")) | 485 | if (0 == strcmp(argv[c], "-d")) |
485 | break; | 486 | break; |
486 | } | 487 | } |
487 | if (c < argc - 1) | 488 | if (c < argc - 1) |
488 | { | 489 | { |
489 | if (GNUNET_OK != GNUNET_STRINGS_fancy_time_to_relative (argv[c + 1], &perf_duration)) | 490 | if (GNUNET_OK != GNUNET_STRINGS_fancy_time_to_relative(argv[c + 1], &perf_duration)) |
490 | fprintf (stderr, "Failed to parse duration `%s'\n", argv[c + 1]); | 491 | fprintf(stderr, "Failed to parse duration `%s'\n", argv[c + 1]); |
491 | } | 492 | } |
492 | else | 493 | else |
493 | { | 494 | { |
494 | perf_duration = BENCHMARK_DURATION; | 495 | perf_duration = BENCHMARK_DURATION; |
495 | } | 496 | } |
496 | fprintf (stderr, "Running benchmark for %llu secs\n", (unsigned long long) (perf_duration.rel_value_us) / (1000 * 1000)); | 497 | fprintf(stderr, "Running benchmark for %llu secs\n", (unsigned long long)(perf_duration.rel_value_us) / (1000 * 1000)); |
497 | 498 | ||
498 | for (c = 0; c < (argc - 1); c++) | 499 | for (c = 0; c < (argc - 1); c++) |
499 | { | 500 | { |
500 | if (0 == strcmp (argv[c], "-s")) | 501 | if (0 == strcmp(argv[c], "-s")) |
501 | break; | 502 | break; |
502 | } | 503 | } |
503 | if (c < argc - 1) | 504 | if (c < argc - 1) |
504 | { | 505 | { |
505 | if ((0L != (num_slaves = strtol (argv[c + 1], NULL, 10))) | 506 | if ((0L != (num_slaves = strtol(argv[c + 1], NULL, 10))) |
506 | && (num_slaves >= 1)) | 507 | && (num_slaves >= 1)) |
507 | fprintf (stderr, "Starting %u slave peers\n", num_slaves); | 508 | fprintf(stderr, "Starting %u slave peers\n", num_slaves); |
508 | else | 509 | else |
509 | num_slaves = DEFAULT_SLAVES_NUM; | 510 | num_slaves = DEFAULT_SLAVES_NUM; |
510 | } | 511 | } |
511 | else | 512 | else |
512 | num_slaves = DEFAULT_SLAVES_NUM; | 513 | num_slaves = DEFAULT_SLAVES_NUM; |
513 | 514 | ||
514 | for (c = 0; c < (argc - 1); c++) | 515 | for (c = 0; c < (argc - 1); c++) |
515 | { | 516 | { |
516 | if (0 == strcmp (argv[c], "-m")) | 517 | if (0 == strcmp(argv[c], "-m")) |
517 | break; | 518 | break; |
518 | } | 519 | } |
519 | if (c < argc - 1) | 520 | if (c < argc - 1) |
520 | { | 521 | { |
521 | if ((0L != (num_masters = strtol (argv[c + 1], NULL, 10))) | 522 | if ((0L != (num_masters = strtol(argv[c + 1], NULL, 10))) |
522 | && (num_masters >= 2)) | 523 | && (num_masters >= 2)) |
523 | fprintf (stderr, "Starting %u master peers\n", num_masters); | 524 | fprintf(stderr, "Starting %u master peers\n", num_masters); |
524 | else | 525 | else |
525 | num_masters = DEFAULT_MASTERS_NUM; | 526 | num_masters = DEFAULT_MASTERS_NUM; |
526 | } | 527 | } |
527 | else | 528 | else |
528 | num_masters = DEFAULT_MASTERS_NUM; | 529 | num_masters = DEFAULT_MASTERS_NUM; |
529 | 530 | ||
530 | logging = GNUNET_NO; | 531 | logging = GNUNET_NO; |
531 | for (c = 0; c < argc; c++) | 532 | for (c = 0; c < argc; c++) |
532 | { | ||
533 | if (0 == strcmp (argv[c], "-l")) | ||
534 | logging = GNUNET_YES; | ||
535 | } | ||
536 | |||
537 | if (GNUNET_YES == logging) | ||
538 | { | ||
539 | for (c = 0; c < (argc - 1); c++) | ||
540 | { | 533 | { |
541 | if (0 == strcmp (argv[c], "-f")) | 534 | if (0 == strcmp(argv[c], "-l")) |
542 | break; | 535 | logging = GNUNET_YES; |
543 | } | 536 | } |
544 | if (c < argc - 1) | 537 | |
545 | { | 538 | if (GNUNET_YES == logging) |
546 | if (GNUNET_OK != GNUNET_STRINGS_fancy_time_to_relative (argv[c + 1], &log_frequency)) | ||
547 | fprintf (stderr, "Failed to parse duration `%s'\n", argv[c + 1]); | ||
548 | } | ||
549 | else | ||
550 | { | 539 | { |
551 | log_frequency = LOGGING_FREQUENCY; | 540 | for (c = 0; c < (argc - 1); c++) |
541 | { | ||
542 | if (0 == strcmp(argv[c], "-f")) | ||
543 | break; | ||
544 | } | ||
545 | if (c < argc - 1) | ||
546 | { | ||
547 | if (GNUNET_OK != GNUNET_STRINGS_fancy_time_to_relative(argv[c + 1], &log_frequency)) | ||
548 | fprintf(stderr, "Failed to parse duration `%s'\n", argv[c + 1]); | ||
549 | } | ||
550 | else | ||
551 | { | ||
552 | log_frequency = LOGGING_FREQUENCY; | ||
553 | } | ||
554 | fprintf(stderr, "Using log frequency %llu ms\n", | ||
555 | (unsigned long long)(log_frequency.rel_value_us) / (1000)); | ||
552 | } | 556 | } |
553 | fprintf (stderr, "Using log frequency %llu ms\n", | ||
554 | (unsigned long long) (log_frequency.rel_value_us) / (1000)); | ||
555 | } | ||
556 | 557 | ||
557 | GNUNET_asprintf (&testname, "%s_%s_%s",solver, comm_name, pref_str); | 558 | GNUNET_asprintf(&testname, "%s_%s_%s", solver, comm_name, pref_str); |
558 | 559 | ||
559 | if (num_slaves < num_masters) | 560 | if (num_slaves < num_masters) |
560 | { | 561 | { |
561 | fprintf (stderr, | 562 | fprintf(stderr, |
562 | "Number of master peers is lower than slaves! exit...\n"); | 563 | "Number of master peers is lower than slaves! exit...\n"); |
563 | GNUNET_free(test_name); | 564 | GNUNET_free(test_name); |
564 | GNUNET_free(solver); | 565 | GNUNET_free(solver); |
565 | GNUNET_free(pref_str); | 566 | GNUNET_free(pref_str); |
566 | GNUNET_free (comm_name); | 567 | GNUNET_free(comm_name); |
567 | return GNUNET_SYSERR; | 568 | return GNUNET_SYSERR; |
568 | } | 569 | } |
569 | 570 | ||
570 | /** | 571 | /** |
571 | * Setup the topology | 572 | * Setup the topology |
572 | */ | 573 | */ |
573 | GNUNET_ATS_TEST_create_topology ("perf-ats", | 574 | GNUNET_ATS_TEST_create_topology("perf-ats", |
574 | conf_name, | 575 | conf_name, |
575 | num_slaves, | 576 | num_slaves, |
576 | num_masters, | 577 | num_masters, |
577 | test_core, | 578 | test_core, |
578 | &do_benchmark, | 579 | &do_benchmark, |
579 | NULL, | 580 | NULL, |
580 | &log_request_cb); | 581 | &log_request_cb); |
581 | 582 | ||
582 | return result; | 583 | return result; |
583 | } | 584 | } |
diff --git a/src/ats-tests/perf_ats.h b/src/ats-tests/perf_ats.h index 4b52d4482..2d552a5d7 100644 --- a/src/ats-tests/perf_ats.h +++ b/src/ats-tests/perf_ats.h | |||
@@ -1,19 +1,19 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2010-2013 GNUnet e.V. | 3 | Copyright (C) 2010-2013 GNUnet e.V. |
4 | 4 | ||
5 | GNUnet is free software: you can redistribute it and/or modify it | 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 | 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, | 7 | by the Free Software Foundation, either version 3 of the License, |
8 | or (at your option) any later version. | 8 | or (at your option) any later version. |
9 | 9 | ||
10 | GNUnet is distributed in the hope that it will be useful, but | 10 | GNUnet is distributed in the hope that it will be useful, but |
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Affero General Public License for more details. | 13 | Affero General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Affero General Public License | 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/>. | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | 17 | ||
18 | SPDX-License-Identifier: AGPL3.0-or-later | 18 | SPDX-License-Identifier: AGPL3.0-or-later |
19 | */ | 19 | */ |
@@ -30,27 +30,26 @@ | |||
30 | #include "gnunet_core_service.h" | 30 | #include "gnunet_core_service.h" |
31 | #include "ats-testing.h" | 31 | #include "ats-testing.h" |
32 | 32 | ||
33 | #define TEST_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 120) | 33 | #define TEST_TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 120) |
34 | #define BENCHMARK_DURATION GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10) | 34 | #define BENCHMARK_DURATION GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 10) |
35 | #define LOGGING_FREQUENCY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 500) | 35 | #define LOGGING_FREQUENCY GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 500) |
36 | #define TESTNAME_PREFIX "perf_ats_" | 36 | #define TESTNAME_PREFIX "perf_ats_" |
37 | #define DEFAULT_SLAVES_NUM 2 | 37 | #define DEFAULT_SLAVES_NUM 2 |
38 | #define DEFAULT_MASTERS_NUM 1 | 38 | #define DEFAULT_MASTERS_NUM 1 |
39 | 39 | ||
40 | #define TEST_ATS_PREFRENCE_FREQUENCY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1) | 40 | #define TEST_ATS_PREFRENCE_FREQUENCY GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 1) |
41 | #define TEST_ATS_PREFRENCE_START 1.0 | 41 | #define TEST_ATS_PREFRENCE_START 1.0 |
42 | #define TEST_ATS_PREFRENCE_DELTA 1.0 | 42 | #define TEST_ATS_PREFRENCE_DELTA 1.0 |
43 | 43 | ||
44 | #define TEST_MESSAGE_TYPE_PING 12345 | 44 | #define TEST_MESSAGE_TYPE_PING 12345 |
45 | #define TEST_MESSAGE_TYPE_PONG 12346 | 45 | #define TEST_MESSAGE_TYPE_PONG 12346 |
46 | #define TEST_MESSAGE_SIZE 1000 | 46 | #define TEST_MESSAGE_SIZE 1000 |
47 | #define TEST_MESSAGE_FREQUENCY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1) | 47 | #define TEST_MESSAGE_FREQUENCY GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 1) |
48 | 48 | ||
49 | /** | 49 | /** |
50 | * Information about a benchmarking partner | 50 | * Information about a benchmarking partner |
51 | */ | 51 | */ |
52 | struct BenchmarkPartner | 52 | struct BenchmarkPartner { |
53 | { | ||
54 | /** | 53 | /** |
55 | * The peer itself this partner belongs to | 54 | * The peer itself this partner belongs to |
56 | */ | 55 | */ |
@@ -128,8 +127,7 @@ struct BenchmarkPartner | |||
128 | /** | 127 | /** |
129 | * Information we track for a peer in the testbed. | 128 | * Information we track for a peer in the testbed. |
130 | */ | 129 | */ |
131 | struct BenchmarkPeer | 130 | struct BenchmarkPeer { |
132 | { | ||
133 | /** | 131 | /** |
134 | * Handle with testbed. | 132 | * Handle with testbed. |
135 | */ | 133 | */ |
diff --git a/src/ats-tests/perf_ats_logging.c b/src/ats-tests/perf_ats_logging.c index 4b59515d3..e0f192ae4 100644 --- a/src/ats-tests/perf_ats_logging.c +++ b/src/ats-tests/perf_ats_logging.c | |||
@@ -1,19 +1,19 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2010-2013 GNUnet e.V. | 3 | Copyright (C) 2010-2013 GNUnet e.V. |
4 | 4 | ||
5 | GNUnet is free software: you can redistribute it and/or modify it | 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 | 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, | 7 | by the Free Software Foundation, either version 3 of the License, |
8 | or (at your option) any later version. | 8 | or (at your option) any later version. |
9 | 9 | ||
10 | GNUnet is distributed in the hope that it will be useful, but | 10 | GNUnet is distributed in the hope that it will be useful, but |
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Affero General Public License for more details. | 13 | Affero General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Affero General Public License | 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/>. | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | 17 | ||
18 | SPDX-License-Identifier: AGPL3.0-or-later | 18 | SPDX-License-Identifier: AGPL3.0-or-later |
19 | */ | 19 | */ |
@@ -28,25 +28,25 @@ | |||
28 | #include "perf_ats.h" | 28 | #include "perf_ats.h" |
29 | 29 | ||
30 | #define THROUGHPUT_TEMPLATE "#!/usr/bin/gnuplot \n" \ | 30 | #define THROUGHPUT_TEMPLATE "#!/usr/bin/gnuplot \n" \ |
31 | "set datafile separator ';' \n" \ | 31 | "set datafile separator ';' \n" \ |
32 | "set title \"Throughput between Master and Slaves\" \n" \ | 32 | "set title \"Throughput between Master and Slaves\" \n" \ |
33 | "set xlabel \"Time in ms\" \n" \ | 33 | "set xlabel \"Time in ms\" \n" \ |
34 | "set ylabel \"Bytes/s\" \n" \ | 34 | "set ylabel \"Bytes/s\" \n" \ |
35 | "set grid \n" | 35 | "set grid \n" |
36 | 36 | ||
37 | #define RTT_TEMPLATE "#!/usr/bin/gnuplot \n" \ | 37 | #define RTT_TEMPLATE "#!/usr/bin/gnuplot \n" \ |
38 | "set datafile separator ';' \n" \ | 38 | "set datafile separator ';' \n" \ |
39 | "set title \"Application level roundtrip time between Master and Slaves\" \n" \ | 39 | "set title \"Application level roundtrip time between Master and Slaves\" \n" \ |
40 | "set xlabel \"Time in ms\" \n" \ | 40 | "set xlabel \"Time in ms\" \n" \ |
41 | "set ylabel \"ms\" \n" \ | 41 | "set ylabel \"ms\" \n" \ |
42 | "set grid \n" | 42 | "set grid \n" |
43 | 43 | ||
44 | #define BW_TEMPLATE "#!/usr/bin/gnuplot \n" \ | 44 | #define BW_TEMPLATE "#!/usr/bin/gnuplot \n" \ |
45 | "set datafile separator ';' \n" \ | 45 | "set datafile separator ';' \n" \ |
46 | "set title \"Bandwidth inbound and outbound between Master and Slaves\" \n" \ | 46 | "set title \"Bandwidth inbound and outbound between Master and Slaves\" \n" \ |
47 | "set xlabel \"Time in ms\" \n" \ | 47 | "set xlabel \"Time in ms\" \n" \ |
48 | "set ylabel \"Bytes / s \" \n" \ | 48 | "set ylabel \"Bytes / s \" \n" \ |
49 | "set grid \n" | 49 | "set grid \n" |
50 | 50 | ||
51 | #define LOG_ITEMS_TIME 2 | 51 | #define LOG_ITEMS_TIME 2 |
52 | #define LOG_ITEMS_PER_PEER 17 | 52 | #define LOG_ITEMS_PER_PEER 17 |
@@ -85,8 +85,7 @@ static struct GNUNET_TIME_Relative frequency; | |||
85 | /** | 85 | /** |
86 | * A single logging time step for a partner | 86 | * A single logging time step for a partner |
87 | */ | 87 | */ |
88 | struct PartnerLoggingTimestep | 88 | struct PartnerLoggingTimestep { |
89 | { | ||
90 | /** | 89 | /** |
91 | * Peer | 90 | * Peer |
92 | */ | 91 | */ |
@@ -159,8 +158,7 @@ struct PartnerLoggingTimestep | |||
159 | /** | 158 | /** |
160 | * A single logging time step for a peer | 159 | * A single logging time step for a peer |
161 | */ | 160 | */ |
162 | struct PeerLoggingTimestep | 161 | struct PeerLoggingTimestep { |
163 | { | ||
164 | /** | 162 | /** |
165 | * Next in DLL | 163 | * Next in DLL |
166 | */ | 164 | */ |
@@ -215,8 +213,7 @@ struct PeerLoggingTimestep | |||
215 | /** | 213 | /** |
216 | * Entry for a benchmark peer | 214 | * Entry for a benchmark peer |
217 | */ | 215 | */ |
218 | struct LoggingPeer | 216 | struct LoggingPeer { |
219 | { | ||
220 | /** | 217 | /** |
221 | * Peer | 218 | * Peer |
222 | */ | 219 | */ |
@@ -245,7 +242,7 @@ static struct LoggingPeer *lp; | |||
245 | 242 | ||
246 | 243 | ||
247 | static void | 244 | static void |
248 | write_throughput_gnuplot_script (char * fn, struct LoggingPeer *lp) | 245 | write_throughput_gnuplot_script(char * fn, struct LoggingPeer *lp) |
249 | { | 246 | { |
250 | struct GNUNET_DISK_FileHandle *f; | 247 | struct GNUNET_DISK_FileHandle *f; |
251 | char * gfn; | 248 | char * gfn; |
@@ -253,57 +250,57 @@ write_throughput_gnuplot_script (char * fn, struct LoggingPeer *lp) | |||
253 | int c_s; | 250 | int c_s; |
254 | int peer_index; | 251 | int peer_index; |
255 | 252 | ||
256 | GNUNET_asprintf (&gfn, "gnuplot_throughput_%s",fn); | 253 | GNUNET_asprintf(&gfn, "gnuplot_throughput_%s", fn); |
257 | f = GNUNET_DISK_file_open (gfn, | 254 | f = GNUNET_DISK_file_open(gfn, |
258 | GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE, | 255 | GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE, |
259 | GNUNET_DISK_PERM_USER_EXEC | GNUNET_DISK_PERM_USER_READ | GNUNET_DISK_PERM_USER_WRITE); | 256 | GNUNET_DISK_PERM_USER_EXEC | GNUNET_DISK_PERM_USER_READ | GNUNET_DISK_PERM_USER_WRITE); |
260 | if (NULL == f) | 257 | if (NULL == f) |
261 | { | 258 | { |
262 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot open gnuplot file `%s'\n", gfn); | 259 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Cannot open gnuplot file `%s'\n", gfn); |
263 | GNUNET_free (gfn); | 260 | GNUNET_free(gfn); |
264 | return; | 261 | return; |
265 | } | 262 | } |
266 | 263 | ||
267 | /* Write header */ | 264 | /* Write header */ |
268 | 265 | ||
269 | if (GNUNET_SYSERR == GNUNET_DISK_file_write(f, THROUGHPUT_TEMPLATE, strlen(THROUGHPUT_TEMPLATE))) | 266 | if (GNUNET_SYSERR == GNUNET_DISK_file_write(f, THROUGHPUT_TEMPLATE, strlen(THROUGHPUT_TEMPLATE))) |
270 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot write data to plot file `%s'\n", gfn); | 267 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Cannot write data to plot file `%s'\n", gfn); |
271 | 268 | ||
272 | /* Write master data */ | 269 | /* Write master data */ |
273 | peer_index = LOG_ITEMS_TIME; | 270 | peer_index = LOG_ITEMS_TIME; |
274 | GNUNET_asprintf (&data, "plot '%s' using 2:%u with lines title 'Master %u send total', \\\n" \ | 271 | GNUNET_asprintf(&data, "plot '%s' using 2:%u with lines title 'Master %u send total', \\\n" \ |
275 | "'%s' using 2:%u with lines title 'Master %u receive total', \\\n", | 272 | "'%s' using 2:%u with lines title 'Master %u receive total', \\\n", |
276 | fn, peer_index + LOG_ITEM_THROUGHPUT_SENT, lp->peer->no, | 273 | fn, peer_index + LOG_ITEM_THROUGHPUT_SENT, lp->peer->no, |
277 | fn, peer_index + LOG_ITEM_THROUGHPUT_RECV, lp->peer->no); | 274 | fn, peer_index + LOG_ITEM_THROUGHPUT_RECV, lp->peer->no); |
278 | if (GNUNET_SYSERR == GNUNET_DISK_file_write(f, data, strlen(data))) | 275 | if (GNUNET_SYSERR == GNUNET_DISK_file_write(f, data, strlen(data))) |
279 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot write data to plot file `%s'\n", gfn); | 276 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Cannot write data to plot file `%s'\n", gfn); |
280 | GNUNET_free (data); | 277 | GNUNET_free(data); |
281 | 278 | ||
282 | peer_index = LOG_ITEMS_TIME + LOG_ITEMS_PER_PEER ; | 279 | peer_index = LOG_ITEMS_TIME + LOG_ITEMS_PER_PEER; |
283 | for (c_s = 0; c_s < lp->peer->num_partners; c_s++) | 280 | for (c_s = 0; c_s < lp->peer->num_partners; c_s++) |
284 | { | 281 | { |
285 | GNUNET_asprintf (&data, "'%s' using 2:%u with lines title 'Master %u - Slave %u send', \\\n" \ | 282 | GNUNET_asprintf(&data, "'%s' using 2:%u with lines title 'Master %u - Slave %u send', \\\n" \ |
286 | "'%s' using 2:%u with lines title 'Master %u - Slave %u receive'%s\n", | 283 | "'%s' using 2:%u with lines title 'Master %u - Slave %u receive'%s\n", |
287 | fn, peer_index + LOG_ITEM_THROUGHPUT_SENT, lp->peer->no, lp->peer->partners[c_s].dest->no, | 284 | fn, peer_index + LOG_ITEM_THROUGHPUT_SENT, lp->peer->no, lp->peer->partners[c_s].dest->no, |
288 | fn, peer_index + LOG_ITEM_THROUGHPUT_RECV, lp->peer->no, lp->peer->partners[c_s].dest->no, | 285 | fn, peer_index + LOG_ITEM_THROUGHPUT_RECV, lp->peer->no, lp->peer->partners[c_s].dest->no, |
289 | (c_s < lp->peer->num_partners -1) ? ", \\" : "\n pause -1"); | 286 | (c_s < lp->peer->num_partners - 1) ? ", \\" : "\n pause -1"); |
290 | if (GNUNET_SYSERR == GNUNET_DISK_file_write(f, data, strlen(data))) | 287 | if (GNUNET_SYSERR == GNUNET_DISK_file_write(f, data, strlen(data))) |
291 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot write data to plot file `%s'\n", gfn); | 288 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Cannot write data to plot file `%s'\n", gfn); |
292 | GNUNET_free (data); | 289 | GNUNET_free(data); |
293 | peer_index += LOG_ITEMS_PER_PEER; | 290 | peer_index += LOG_ITEMS_PER_PEER; |
294 | } | 291 | } |
295 | 292 | ||
296 | if (GNUNET_SYSERR == GNUNET_DISK_file_close(f)) | 293 | if (GNUNET_SYSERR == GNUNET_DISK_file_close(f)) |
297 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot close gnuplot file `%s'\n", gfn); | 294 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Cannot close gnuplot file `%s'\n", gfn); |
298 | else | 295 | else |
299 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Data successfully written to plot file `%s'\n", gfn); | 296 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Data successfully written to plot file `%s'\n", gfn); |
300 | 297 | ||
301 | GNUNET_free (gfn); | 298 | GNUNET_free(gfn); |
302 | } | 299 | } |
303 | 300 | ||
304 | 301 | ||
305 | static void | 302 | static void |
306 | write_rtt_gnuplot_script (char * fn, struct LoggingPeer *lp) | 303 | write_rtt_gnuplot_script(char * fn, struct LoggingPeer *lp) |
307 | { | 304 | { |
308 | struct GNUNET_DISK_FileHandle *f; | 305 | struct GNUNET_DISK_FileHandle *f; |
309 | char * gfn; | 306 | char * gfn; |
@@ -311,44 +308,44 @@ write_rtt_gnuplot_script (char * fn, struct LoggingPeer *lp) | |||
311 | int c_s; | 308 | int c_s; |
312 | int index; | 309 | int index; |
313 | 310 | ||
314 | GNUNET_asprintf (&gfn, "gnuplot_rtt_%s",fn); | 311 | GNUNET_asprintf(&gfn, "gnuplot_rtt_%s", fn); |
315 | f = GNUNET_DISK_file_open (gfn, | 312 | f = GNUNET_DISK_file_open(gfn, |
316 | GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE, | 313 | GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE, |
317 | GNUNET_DISK_PERM_USER_EXEC | GNUNET_DISK_PERM_USER_READ | GNUNET_DISK_PERM_USER_WRITE); | 314 | GNUNET_DISK_PERM_USER_EXEC | GNUNET_DISK_PERM_USER_READ | GNUNET_DISK_PERM_USER_WRITE); |
318 | if (NULL == f) | 315 | if (NULL == f) |
319 | { | 316 | { |
320 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot open gnuplot file `%s'\n", gfn); | 317 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Cannot open gnuplot file `%s'\n", gfn); |
321 | GNUNET_free (gfn); | 318 | GNUNET_free(gfn); |
322 | return; | 319 | return; |
323 | } | 320 | } |
324 | 321 | ||
325 | /* Write header */ | 322 | /* Write header */ |
326 | 323 | ||
327 | if (GNUNET_SYSERR == GNUNET_DISK_file_write(f, RTT_TEMPLATE, strlen(RTT_TEMPLATE))) | 324 | if (GNUNET_SYSERR == GNUNET_DISK_file_write(f, RTT_TEMPLATE, strlen(RTT_TEMPLATE))) |
328 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot write data to plot file `%s'\n", gfn); | 325 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Cannot write data to plot file `%s'\n", gfn); |
329 | 326 | ||
330 | index = LOG_ITEMS_TIME + LOG_ITEMS_PER_PEER; | 327 | index = LOG_ITEMS_TIME + LOG_ITEMS_PER_PEER; |
331 | for (c_s = 0; c_s < lp->peer->num_partners; c_s++) | 328 | for (c_s = 0; c_s < lp->peer->num_partners; c_s++) |
332 | { | 329 | { |
333 | GNUNET_asprintf (&data, "%s'%s' using 2:%u with lines title 'Master %u - Slave %u '%s\n", | 330 | GNUNET_asprintf(&data, "%s'%s' using 2:%u with lines title 'Master %u - Slave %u '%s\n", |
334 | (0 == c_s) ? "plot " :"", | 331 | (0 == c_s) ? "plot " : "", |
335 | fn, index + LOG_ITEM_APP_RTT, lp->peer->no, lp->peer->partners[c_s].dest->no, | 332 | fn, index + LOG_ITEM_APP_RTT, lp->peer->no, lp->peer->partners[c_s].dest->no, |
336 | (c_s < lp->peer->num_partners -1) ? ", \\" : "\n pause -1"); | 333 | (c_s < lp->peer->num_partners - 1) ? ", \\" : "\n pause -1"); |
337 | if (GNUNET_SYSERR == GNUNET_DISK_file_write(f, data, strlen(data))) | 334 | if (GNUNET_SYSERR == GNUNET_DISK_file_write(f, data, strlen(data))) |
338 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot write data to plot file `%s'\n", gfn); | 335 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Cannot write data to plot file `%s'\n", gfn); |
339 | GNUNET_free (data); | 336 | GNUNET_free(data); |
340 | index += LOG_ITEMS_PER_PEER; | 337 | index += LOG_ITEMS_PER_PEER; |
341 | } | 338 | } |
342 | 339 | ||
343 | if (GNUNET_SYSERR == GNUNET_DISK_file_close(f)) | 340 | if (GNUNET_SYSERR == GNUNET_DISK_file_close(f)) |
344 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot close gnuplot file `%s'\n", gfn); | 341 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Cannot close gnuplot file `%s'\n", gfn); |
345 | else | 342 | else |
346 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Data successfully written to plot file `%s'\n", gfn); | 343 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Data successfully written to plot file `%s'\n", gfn); |
347 | GNUNET_free (gfn); | 344 | GNUNET_free(gfn); |
348 | } | 345 | } |
349 | 346 | ||
350 | static void | 347 | static void |
351 | write_bw_gnuplot_script (char * fn, struct LoggingPeer *lp) | 348 | write_bw_gnuplot_script(char * fn, struct LoggingPeer *lp) |
352 | { | 349 | { |
353 | struct GNUNET_DISK_FileHandle *f; | 350 | struct GNUNET_DISK_FileHandle *f; |
354 | char * gfn; | 351 | char * gfn; |
@@ -356,49 +353,49 @@ write_bw_gnuplot_script (char * fn, struct LoggingPeer *lp) | |||
356 | int c_s; | 353 | int c_s; |
357 | int index; | 354 | int index; |
358 | 355 | ||
359 | GNUNET_asprintf (&gfn, "gnuplot_bw_%s",fn); | 356 | GNUNET_asprintf(&gfn, "gnuplot_bw_%s", fn); |
360 | f = GNUNET_DISK_file_open (gfn, | 357 | f = GNUNET_DISK_file_open(gfn, |
361 | GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE, | 358 | GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE, |
362 | GNUNET_DISK_PERM_USER_EXEC | GNUNET_DISK_PERM_USER_READ | GNUNET_DISK_PERM_USER_WRITE); | 359 | GNUNET_DISK_PERM_USER_EXEC | GNUNET_DISK_PERM_USER_READ | GNUNET_DISK_PERM_USER_WRITE); |
363 | if (NULL == f) | 360 | if (NULL == f) |
364 | { | 361 | { |
365 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot open gnuplot file `%s'\n", gfn); | 362 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Cannot open gnuplot file `%s'\n", gfn); |
366 | GNUNET_free (gfn); | 363 | GNUNET_free(gfn); |
367 | return; | 364 | return; |
368 | } | 365 | } |
369 | 366 | ||
370 | /* Write header */ | 367 | /* Write header */ |
371 | 368 | ||
372 | if (GNUNET_SYSERR == GNUNET_DISK_file_write(f, BW_TEMPLATE, strlen(BW_TEMPLATE))) | 369 | if (GNUNET_SYSERR == GNUNET_DISK_file_write(f, BW_TEMPLATE, strlen(BW_TEMPLATE))) |
373 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot write data to plot file `%s'\n", gfn); | 370 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Cannot write data to plot file `%s'\n", gfn); |
374 | 371 | ||
375 | index = LOG_ITEMS_TIME + LOG_ITEMS_PER_PEER; | 372 | index = LOG_ITEMS_TIME + LOG_ITEMS_PER_PEER; |
376 | for (c_s = 0; c_s < lp->peer->num_partners; c_s++) | 373 | for (c_s = 0; c_s < lp->peer->num_partners; c_s++) |
377 | { | 374 | { |
378 | GNUNET_asprintf (&data, "%s"\ | 375 | GNUNET_asprintf(&data, "%s" \ |
379 | "'%s' using 2:%u with lines title 'BW out master %u - Slave %u ', \\\n" \ | 376 | "'%s' using 2:%u with lines title 'BW out master %u - Slave %u ', \\\n" \ |
380 | "'%s' using 2:%u with lines title 'BW in master %u - Slave %u '"\ | 377 | "'%s' using 2:%u with lines title 'BW in master %u - Slave %u '" \ |
381 | "%s\n", | 378 | "%s\n", |
382 | (0 == c_s) ? "plot " :"", | 379 | (0 == c_s) ? "plot " : "", |
383 | fn, index + LOG_ITEM_ATS_BW_OUT, lp->peer->no, lp->peer->partners[c_s].dest->no, | 380 | fn, index + LOG_ITEM_ATS_BW_OUT, lp->peer->no, lp->peer->partners[c_s].dest->no, |
384 | fn, index + LOG_ITEM_ATS_BW_IN, lp->peer->no, lp->peer->partners[c_s].dest->no, | 381 | fn, index + LOG_ITEM_ATS_BW_IN, lp->peer->no, lp->peer->partners[c_s].dest->no, |
385 | (c_s < lp->peer->num_partners -1) ? ", \\" : "\n pause -1"); | 382 | (c_s < lp->peer->num_partners - 1) ? ", \\" : "\n pause -1"); |
386 | if (GNUNET_SYSERR == GNUNET_DISK_file_write(f, data, strlen(data))) | 383 | if (GNUNET_SYSERR == GNUNET_DISK_file_write(f, data, strlen(data))) |
387 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot write data to plot file `%s'\n", gfn); | 384 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Cannot write data to plot file `%s'\n", gfn); |
388 | GNUNET_free (data); | 385 | GNUNET_free(data); |
389 | index += LOG_ITEMS_PER_PEER; | 386 | index += LOG_ITEMS_PER_PEER; |
390 | } | 387 | } |
391 | 388 | ||
392 | if (GNUNET_SYSERR == GNUNET_DISK_file_close(f)) | 389 | if (GNUNET_SYSERR == GNUNET_DISK_file_close(f)) |
393 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot close gnuplot file `%s'\n", gfn); | 390 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Cannot close gnuplot file `%s'\n", gfn); |
394 | else | 391 | else |
395 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Data successfully written to plot file `%s'\n", gfn); | 392 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Data successfully written to plot file `%s'\n", gfn); |
396 | GNUNET_free (gfn); | 393 | GNUNET_free(gfn); |
397 | } | 394 | } |
398 | 395 | ||
399 | 396 | ||
400 | static void | 397 | static void |
401 | write_to_file () | 398 | write_to_file() |
402 | { | 399 | { |
403 | struct GNUNET_DISK_FileHandle *f; | 400 | struct GNUNET_DISK_FileHandle *f; |
404 | 401 | ||
@@ -412,88 +409,88 @@ write_to_file () | |||
412 | int c_s; | 409 | int c_s; |
413 | 410 | ||
414 | for (c_m = 0; c_m < num_peers; c_m++) | 411 | for (c_m = 0; c_m < num_peers; c_m++) |
415 | { | ||
416 | GNUNET_asprintf (&filename, "%llu_master_%u_%s_%s.data", GNUNET_TIME_absolute_get().abs_value_us, | ||
417 | lp[c_m].peer->no, GNUNET_i2s(&lp[c_m].peer->id), name); | ||
418 | |||
419 | f = GNUNET_DISK_file_open (filename, | ||
420 | GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE, | ||
421 | GNUNET_DISK_PERM_USER_READ | GNUNET_DISK_PERM_USER_WRITE); | ||
422 | if (NULL == f) | ||
423 | { | 412 | { |
424 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot open log file `%s'\n", filename); | 413 | GNUNET_asprintf(&filename, "%llu_master_%u_%s_%s.data", GNUNET_TIME_absolute_get().abs_value_us, |
425 | GNUNET_free (filename); | 414 | lp[c_m].peer->no, GNUNET_i2s(&lp[c_m].peer->id), name); |
426 | return; | 415 | |
416 | f = GNUNET_DISK_file_open(filename, | ||
417 | GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE, | ||
418 | GNUNET_DISK_PERM_USER_READ | GNUNET_DISK_PERM_USER_WRITE); | ||
419 | if (NULL == f) | ||
420 | { | ||
421 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Cannot open log file `%s'\n", filename); | ||
422 | GNUNET_free(filename); | ||
423 | return; | ||
424 | } | ||
425 | |||
426 | for (cur_lt = lp[c_m].head; NULL != cur_lt; cur_lt = cur_lt->next) | ||
427 | { | ||
428 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, | ||
429 | "Master [%u]: timestamp %llu %llu ; %u %u %u ; %u %u %u\n", lp[c_m].peer->no, | ||
430 | cur_lt->timestamp, GNUNET_TIME_absolute_get_difference(lp[c_m].start, cur_lt->timestamp).rel_value_us / 1000, | ||
431 | cur_lt->total_messages_sent, cur_lt->total_bytes_sent, cur_lt->total_throughput_send, | ||
432 | cur_lt->total_messages_received, cur_lt->total_bytes_received, cur_lt->total_throughput_recv); | ||
433 | |||
434 | slave_string = GNUNET_strdup(";"); | ||
435 | for (c_s = 0; c_s < lp[c_m].peer->num_partners; c_s++) | ||
436 | { | ||
437 | plt = &cur_lt->slaves_log[c_s]; | ||
438 | /* Log partners */ | ||
439 | |||
440 | /* Assembling slave string */ | ||
441 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, | ||
442 | "\t Slave [%u]: %u %u %u ; %u %u %u rtt %u delay %u bw_in %u bw_out %u \n", plt->slave->no, | ||
443 | plt->total_messages_sent, plt->total_bytes_sent, plt->throughput_sent, | ||
444 | plt->total_messages_received, plt->total_bytes_received, plt->throughput_recv, | ||
445 | plt->app_rtt, plt->ats_delay, | ||
446 | plt->bandwidth_in, plt->bandwidth_out); | ||
447 | |||
448 | GNUNET_asprintf(&slave_string_tmp, "%s%u;%u;%u;%u;%u;%u;%.3f;%u;%u;%u;%u;%u;%u;%u;%u;%u;%u;", slave_string, | ||
449 | plt->total_messages_sent, plt->total_bytes_sent, plt->throughput_sent, | ||
450 | plt->total_messages_received, plt->total_bytes_received, plt->throughput_sent, | ||
451 | (double)plt->app_rtt / 1000, | ||
452 | plt->bandwidth_in, plt->bandwidth_out, | ||
453 | plt->ats_cost_lan, plt->ats_cost_wan, plt->ats_cost_wlan, | ||
454 | plt->ats_delay, plt->ats_distance, plt->ats_network_type, | ||
455 | plt->ats_utilization_up, plt->ats_utilization_down); | ||
456 | GNUNET_free(slave_string); | ||
457 | slave_string = slave_string_tmp; | ||
458 | } | ||
459 | /* Assembling master string */ | ||
460 | |||
461 | |||
462 | |||
463 | GNUNET_asprintf(&data, "%llu;%llu;%u;%u;%u;%u;%u;%u;;;;;;;;;;;%s\n", | ||
464 | cur_lt->timestamp, | ||
465 | GNUNET_TIME_absolute_get_difference(lp[c_m].start, cur_lt->timestamp).rel_value_us / 1000, | ||
466 | cur_lt->total_messages_sent, cur_lt->total_bytes_sent, cur_lt->total_throughput_send, | ||
467 | cur_lt->total_messages_received, cur_lt->total_bytes_received, cur_lt->total_throughput_recv, | ||
468 | slave_string); | ||
469 | GNUNET_free(slave_string); | ||
470 | |||
471 | if (GNUNET_SYSERR == GNUNET_DISK_file_write(f, data, strlen(data))) | ||
472 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Cannot write data to log file `%s'\n", filename); | ||
473 | GNUNET_free(data); | ||
474 | } | ||
475 | if (GNUNET_SYSERR == GNUNET_DISK_file_close(f)) | ||
476 | { | ||
477 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Cannot close log file `%s'\n", filename); | ||
478 | GNUNET_free(filename); | ||
479 | return; | ||
480 | } | ||
481 | |||
482 | write_throughput_gnuplot_script(filename, lp); | ||
483 | write_rtt_gnuplot_script(filename, lp); | ||
484 | write_bw_gnuplot_script(filename, lp); | ||
485 | |||
486 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Data file successfully written to log file `%s'\n", filename); | ||
487 | GNUNET_free(filename); | ||
427 | } | 488 | } |
428 | |||
429 | for (cur_lt = lp[c_m].head; NULL != cur_lt; cur_lt = cur_lt->next) | ||
430 | { | ||
431 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, | ||
432 | "Master [%u]: timestamp %llu %llu ; %u %u %u ; %u %u %u\n", lp[c_m].peer->no, | ||
433 | cur_lt->timestamp, GNUNET_TIME_absolute_get_difference(lp[c_m].start,cur_lt->timestamp).rel_value_us / 1000, | ||
434 | cur_lt->total_messages_sent, cur_lt->total_bytes_sent, cur_lt->total_throughput_send, | ||
435 | cur_lt->total_messages_received, cur_lt->total_bytes_received, cur_lt->total_throughput_recv); | ||
436 | |||
437 | slave_string = GNUNET_strdup (";"); | ||
438 | for (c_s = 0; c_s < lp[c_m].peer->num_partners; c_s++) | ||
439 | { | ||
440 | plt = &cur_lt->slaves_log[c_s]; | ||
441 | /* Log partners */ | ||
442 | |||
443 | /* Assembling slave string */ | ||
444 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, | ||
445 | "\t Slave [%u]: %u %u %u ; %u %u %u rtt %u delay %u bw_in %u bw_out %u \n", plt->slave->no, | ||
446 | plt->total_messages_sent, plt->total_bytes_sent, plt->throughput_sent, | ||
447 | plt->total_messages_received, plt->total_bytes_received, plt->throughput_recv, | ||
448 | plt->app_rtt, plt->ats_delay, | ||
449 | plt->bandwidth_in, plt->bandwidth_out); | ||
450 | |||
451 | GNUNET_asprintf(&slave_string_tmp, "%s%u;%u;%u;%u;%u;%u;%.3f;%u;%u;%u;%u;%u;%u;%u;%u;%u;%u;",slave_string, | ||
452 | plt->total_messages_sent, plt->total_bytes_sent, plt->throughput_sent, | ||
453 | plt->total_messages_received, plt->total_bytes_received, plt->throughput_sent, | ||
454 | (double) plt->app_rtt / 1000, | ||
455 | plt->bandwidth_in,plt->bandwidth_out, | ||
456 | plt->ats_cost_lan, plt->ats_cost_wan, plt->ats_cost_wlan, | ||
457 | plt->ats_delay, plt->ats_distance, plt->ats_network_type, | ||
458 | plt->ats_utilization_up, plt->ats_utilization_down); | ||
459 | GNUNET_free (slave_string); | ||
460 | slave_string = slave_string_tmp; | ||
461 | } | ||
462 | /* Assembling master string */ | ||
463 | |||
464 | |||
465 | |||
466 | GNUNET_asprintf (&data, "%llu;%llu;%u;%u;%u;%u;%u;%u;;;;;;;;;;;%s\n", | ||
467 | cur_lt->timestamp, | ||
468 | GNUNET_TIME_absolute_get_difference(lp[c_m].start,cur_lt->timestamp).rel_value_us / 1000, | ||
469 | cur_lt->total_messages_sent, cur_lt->total_bytes_sent, cur_lt->total_throughput_send, | ||
470 | cur_lt->total_messages_received, cur_lt->total_bytes_received, cur_lt->total_throughput_recv, | ||
471 | slave_string); | ||
472 | GNUNET_free (slave_string); | ||
473 | |||
474 | if (GNUNET_SYSERR == GNUNET_DISK_file_write(f, data, strlen(data))) | ||
475 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot write data to log file `%s'\n", filename); | ||
476 | GNUNET_free (data); | ||
477 | } | ||
478 | if (GNUNET_SYSERR == GNUNET_DISK_file_close(f)) | ||
479 | { | ||
480 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot close log file `%s'\n", filename); | ||
481 | GNUNET_free (filename); | ||
482 | return; | ||
483 | } | ||
484 | |||
485 | write_throughput_gnuplot_script (filename, lp); | ||
486 | write_rtt_gnuplot_script (filename, lp); | ||
487 | write_bw_gnuplot_script (filename, lp); | ||
488 | |||
489 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Data file successfully written to log file `%s'\n", filename); | ||
490 | GNUNET_free (filename); | ||
491 | } | ||
492 | } | 489 | } |
493 | 490 | ||
494 | 491 | ||
495 | void | 492 | void |
496 | collect_log_now (void) | 493 | collect_log_now(void) |
497 | { | 494 | { |
498 | struct LoggingPeer *bp; | 495 | struct LoggingPeer *bp; |
499 | struct PeerLoggingTimestep *mlt; | 496 | struct PeerLoggingTimestep *mlt; |
@@ -511,143 +508,143 @@ collect_log_now (void) | |||
511 | return; | 508 | return; |
512 | 509 | ||
513 | for (c_m = 0; c_m < num_peers; c_m++) | 510 | for (c_m = 0; c_m < num_peers; c_m++) |
514 | { | ||
515 | bp = &lp[c_m]; | ||
516 | mlt = GNUNET_new (struct PeerLoggingTimestep); | ||
517 | GNUNET_CONTAINER_DLL_insert_tail(bp->head, bp->tail, mlt); | ||
518 | prev_log_mlt = mlt->prev; | ||
519 | |||
520 | /* Collect data */ | ||
521 | |||
522 | /* Current master state */ | ||
523 | mlt->timestamp = GNUNET_TIME_absolute_get(); | ||
524 | mlt->total_bytes_sent = bp->peer->total_bytes_sent; | ||
525 | mlt->total_messages_sent = bp->peer->total_messages_sent; | ||
526 | mlt->total_bytes_received = bp->peer->total_bytes_received; | ||
527 | mlt->total_messages_received = bp->peer->total_messages_received; | ||
528 | |||
529 | /* Throughput */ | ||
530 | if (NULL == prev_log_mlt) | ||
531 | { | ||
532 | /* Get difference to start */ | ||
533 | delta = GNUNET_TIME_absolute_get_difference (lp[c_m].start, mlt->timestamp); | ||
534 | } | ||
535 | else | ||
536 | { | ||
537 | /* Get difference to last timestep */ | ||
538 | delta = GNUNET_TIME_absolute_get_difference (mlt->prev->timestamp, mlt->timestamp); | ||
539 | } | ||
540 | |||
541 | /* Multiplication factor for throughput calculation */ | ||
542 | mult = (1.0 * 1000 * 1000) / (delta.rel_value_us); | ||
543 | |||
544 | /* Total throughput */ | ||
545 | if (NULL != prev_log_mlt) | ||
546 | { | ||
547 | if (mlt->total_bytes_sent - mlt->prev->total_bytes_sent > 0) | ||
548 | mlt->total_throughput_send = mult * (mlt->total_bytes_sent - mlt->prev->total_bytes_sent); | ||
549 | else | ||
550 | mlt->total_throughput_send = prev_log_mlt->total_throughput_send; /* no msgs send */ | ||
551 | |||
552 | if (mlt->total_bytes_received - mlt->prev->total_bytes_received > 0) | ||
553 | mlt->total_throughput_recv = mult * (mlt->total_bytes_received - mlt->prev->total_bytes_received); | ||
554 | else | ||
555 | mlt->total_throughput_recv = prev_log_mlt->total_throughput_recv; /* no msgs received */ | ||
556 | } | ||
557 | else | ||
558 | { | ||
559 | mlt->total_throughput_send = mult * mlt->total_bytes_sent; | ||
560 | mlt->total_throughput_send = mult * mlt->total_bytes_received; | ||
561 | } | ||
562 | |||
563 | mlt->slaves_log = GNUNET_malloc (bp->peer->num_partners * | ||
564 | sizeof (struct PartnerLoggingTimestep)); | ||
565 | |||
566 | for (c_s = 0; c_s < bp->peer->num_partners; c_s++) | ||
567 | { | 511 | { |
568 | p = &bp->peer->partners[c_s]; | 512 | bp = &lp[c_m]; |
569 | slt = &mlt->slaves_log[c_s]; | 513 | mlt = GNUNET_new(struct PeerLoggingTimestep); |
570 | 514 | GNUNET_CONTAINER_DLL_insert_tail(bp->head, bp->tail, mlt); | |
571 | slt->slave = p->dest; | 515 | prev_log_mlt = mlt->prev; |
572 | /* Bytes sent from master to this slave */ | 516 | |
573 | slt->total_bytes_sent = p->bytes_sent; | 517 | /* Collect data */ |
574 | /* Messages sent from master to this slave */ | 518 | |
575 | slt->total_messages_sent = p->messages_sent; | 519 | /* Current master state */ |
576 | /* Bytes master received from this slave */ | 520 | mlt->timestamp = GNUNET_TIME_absolute_get(); |
577 | slt->total_bytes_received = p->bytes_received; | 521 | mlt->total_bytes_sent = bp->peer->total_bytes_sent; |
578 | /* Messages master received from this slave */ | 522 | mlt->total_messages_sent = bp->peer->total_messages_sent; |
579 | slt->total_messages_received = p->messages_received; | 523 | mlt->total_bytes_received = bp->peer->total_bytes_received; |
580 | slt->total_app_rtt = p->total_app_rtt; | 524 | mlt->total_messages_received = bp->peer->total_messages_received; |
581 | /* ats performance information */ | 525 | |
582 | slt->ats_cost_lan = p->ats_cost_lan; | 526 | /* Throughput */ |
583 | slt->ats_cost_wan = p->ats_cost_wan; | ||
584 | slt->ats_cost_wlan = p->ats_cost_wlan; | ||
585 | slt->ats_delay = p->ats_delay; | ||
586 | slt->ats_distance = p->ats_distance; | ||
587 | slt->ats_network_type = p->ats_network_type; | ||
588 | slt->ats_utilization_down = p->ats_utilization_down; | ||
589 | slt->ats_utilization_up = p->ats_utilization_up; | ||
590 | slt->bandwidth_in = p->bandwidth_in; | ||
591 | slt->bandwidth_out = p->bandwidth_out; | ||
592 | |||
593 | /* Total application level rtt */ | ||
594 | if (NULL == prev_log_mlt) | 527 | if (NULL == prev_log_mlt) |
595 | { | 528 | { |
596 | if (0 != slt->total_messages_sent) | 529 | /* Get difference to start */ |
597 | app_rtt = slt->total_app_rtt / slt->total_messages_sent; | 530 | delta = GNUNET_TIME_absolute_get_difference(lp[c_m].start, mlt->timestamp); |
598 | else | 531 | } |
599 | app_rtt = 0; | ||
600 | } | ||
601 | else | 532 | else |
602 | { | 533 | { |
603 | prev_log_slt = &prev_log_mlt->slaves_log[c_s]; | 534 | /* Get difference to last timestep */ |
604 | if ((slt->total_messages_sent - prev_log_slt->total_messages_sent) > 0) | 535 | delta = GNUNET_TIME_absolute_get_difference(mlt->prev->timestamp, mlt->timestamp); |
605 | app_rtt = (slt->total_app_rtt - prev_log_slt->total_app_rtt) / | 536 | } |
606 | (slt->total_messages_sent - prev_log_slt->total_messages_sent); | 537 | |
607 | else | 538 | /* Multiplication factor for throughput calculation */ |
608 | app_rtt = prev_log_slt->app_rtt; /* No messages were */ | 539 | mult = (1.0 * 1000 * 1000) / (delta.rel_value_us); |
609 | } | 540 | |
610 | slt->app_rtt = app_rtt; | 541 | /* Total throughput */ |
611 | |||
612 | /* Partner throughput */ | ||
613 | if (NULL != prev_log_mlt) | 542 | if (NULL != prev_log_mlt) |
614 | { | 543 | { |
615 | prev_log_slt = &prev_log_mlt->slaves_log[c_s]; | 544 | if (mlt->total_bytes_sent - mlt->prev->total_bytes_sent > 0) |
616 | if (slt->total_bytes_sent - prev_log_slt->total_bytes_sent > 0) | 545 | mlt->total_throughput_send = mult * (mlt->total_bytes_sent - mlt->prev->total_bytes_sent); |
617 | slt->throughput_sent = mult * (slt->total_bytes_sent - prev_log_slt->total_bytes_sent); | 546 | else |
618 | else | 547 | mlt->total_throughput_send = prev_log_mlt->total_throughput_send; /* no msgs send */ |
619 | slt->throughput_sent = prev_log_slt->throughput_sent; /* no msgs send */ | 548 | |
620 | 549 | if (mlt->total_bytes_received - mlt->prev->total_bytes_received > 0) | |
621 | if (slt->total_bytes_received - prev_log_slt->total_bytes_received > 0) | 550 | mlt->total_throughput_recv = mult * (mlt->total_bytes_received - mlt->prev->total_bytes_received); |
622 | slt->throughput_recv = mult * (slt->total_bytes_received - prev_log_slt->total_bytes_received); | 551 | else |
623 | else | 552 | mlt->total_throughput_recv = prev_log_mlt->total_throughput_recv; /* no msgs received */ |
624 | slt->throughput_recv = prev_log_slt->throughput_recv; /* no msgs received */ | 553 | } |
625 | } | ||
626 | else | 554 | else |
627 | { | 555 | { |
628 | slt->throughput_sent = mult * slt->total_bytes_sent; | 556 | mlt->total_throughput_send = mult * mlt->total_bytes_sent; |
629 | slt->throughput_sent = mult * slt->total_bytes_received; | 557 | mlt->total_throughput_send = mult * mlt->total_bytes_received; |
630 | } | 558 | } |
631 | 559 | ||
632 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 560 | mlt->slaves_log = GNUNET_malloc(bp->peer->num_partners * |
633 | "Master [%u]: slave [%u]\n", | 561 | sizeof(struct PartnerLoggingTimestep)); |
634 | bp->peer->no, p->dest->no); | 562 | |
563 | for (c_s = 0; c_s < bp->peer->num_partners; c_s++) | ||
564 | { | ||
565 | p = &bp->peer->partners[c_s]; | ||
566 | slt = &mlt->slaves_log[c_s]; | ||
567 | |||
568 | slt->slave = p->dest; | ||
569 | /* Bytes sent from master to this slave */ | ||
570 | slt->total_bytes_sent = p->bytes_sent; | ||
571 | /* Messages sent from master to this slave */ | ||
572 | slt->total_messages_sent = p->messages_sent; | ||
573 | /* Bytes master received from this slave */ | ||
574 | slt->total_bytes_received = p->bytes_received; | ||
575 | /* Messages master received from this slave */ | ||
576 | slt->total_messages_received = p->messages_received; | ||
577 | slt->total_app_rtt = p->total_app_rtt; | ||
578 | /* ats performance information */ | ||
579 | slt->ats_cost_lan = p->ats_cost_lan; | ||
580 | slt->ats_cost_wan = p->ats_cost_wan; | ||
581 | slt->ats_cost_wlan = p->ats_cost_wlan; | ||
582 | slt->ats_delay = p->ats_delay; | ||
583 | slt->ats_distance = p->ats_distance; | ||
584 | slt->ats_network_type = p->ats_network_type; | ||
585 | slt->ats_utilization_down = p->ats_utilization_down; | ||
586 | slt->ats_utilization_up = p->ats_utilization_up; | ||
587 | slt->bandwidth_in = p->bandwidth_in; | ||
588 | slt->bandwidth_out = p->bandwidth_out; | ||
589 | |||
590 | /* Total application level rtt */ | ||
591 | if (NULL == prev_log_mlt) | ||
592 | { | ||
593 | if (0 != slt->total_messages_sent) | ||
594 | app_rtt = slt->total_app_rtt / slt->total_messages_sent; | ||
595 | else | ||
596 | app_rtt = 0; | ||
597 | } | ||
598 | else | ||
599 | { | ||
600 | prev_log_slt = &prev_log_mlt->slaves_log[c_s]; | ||
601 | if ((slt->total_messages_sent - prev_log_slt->total_messages_sent) > 0) | ||
602 | app_rtt = (slt->total_app_rtt - prev_log_slt->total_app_rtt) / | ||
603 | (slt->total_messages_sent - prev_log_slt->total_messages_sent); | ||
604 | else | ||
605 | app_rtt = prev_log_slt->app_rtt; /* No messages were */ | ||
606 | } | ||
607 | slt->app_rtt = app_rtt; | ||
608 | |||
609 | /* Partner throughput */ | ||
610 | if (NULL != prev_log_mlt) | ||
611 | { | ||
612 | prev_log_slt = &prev_log_mlt->slaves_log[c_s]; | ||
613 | if (slt->total_bytes_sent - prev_log_slt->total_bytes_sent > 0) | ||
614 | slt->throughput_sent = mult * (slt->total_bytes_sent - prev_log_slt->total_bytes_sent); | ||
615 | else | ||
616 | slt->throughput_sent = prev_log_slt->throughput_sent; /* no msgs send */ | ||
617 | |||
618 | if (slt->total_bytes_received - prev_log_slt->total_bytes_received > 0) | ||
619 | slt->throughput_recv = mult * (slt->total_bytes_received - prev_log_slt->total_bytes_received); | ||
620 | else | ||
621 | slt->throughput_recv = prev_log_slt->throughput_recv; /* no msgs received */ | ||
622 | } | ||
623 | else | ||
624 | { | ||
625 | slt->throughput_sent = mult * slt->total_bytes_sent; | ||
626 | slt->throughput_sent = mult * slt->total_bytes_received; | ||
627 | } | ||
628 | |||
629 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | ||
630 | "Master [%u]: slave [%u]\n", | ||
631 | bp->peer->no, p->dest->no); | ||
632 | } | ||
635 | } | 633 | } |
636 | } | ||
637 | } | 634 | } |
638 | 635 | ||
639 | static void | 636 | static void |
640 | collect_log_task (void *cls) | 637 | collect_log_task(void *cls) |
641 | { | 638 | { |
642 | log_task = NULL; | 639 | log_task = NULL; |
643 | collect_log_now (); | 640 | collect_log_now(); |
644 | log_task = GNUNET_SCHEDULER_add_delayed (frequency, | 641 | log_task = GNUNET_SCHEDULER_add_delayed(frequency, |
645 | &collect_log_task, NULL); | 642 | &collect_log_task, NULL); |
646 | } | 643 | } |
647 | 644 | ||
648 | 645 | ||
649 | void | 646 | void |
650 | perf_logging_stop () | 647 | perf_logging_stop() |
651 | { | 648 | { |
652 | int c_m; | 649 | int c_m; |
653 | struct PeerLoggingTimestep *cur; | 650 | struct PeerLoggingTimestep *cur; |
@@ -656,53 +653,54 @@ perf_logging_stop () | |||
656 | return; | 653 | return; |
657 | 654 | ||
658 | if (NULL != log_task) | 655 | if (NULL != log_task) |
659 | { | 656 | { |
660 | GNUNET_SCHEDULER_cancel (log_task); | 657 | GNUNET_SCHEDULER_cancel(log_task); |
661 | log_task = NULL; | 658 | log_task = NULL; |
662 | } | 659 | } |
663 | collect_log_task (NULL); | 660 | collect_log_task(NULL); |
664 | 661 | ||
665 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, | 662 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, |
666 | _("Stop logging\n")); | 663 | _("Stop logging\n")); |
667 | 664 | ||
668 | write_to_file (); | 665 | write_to_file(); |
669 | 666 | ||
670 | for (c_m = 0; c_m < num_peers; c_m++) | 667 | for (c_m = 0; c_m < num_peers; c_m++) |
671 | { | ||
672 | while (NULL != (cur = lp[c_m].head)) | ||
673 | { | 668 | { |
674 | GNUNET_CONTAINER_DLL_remove (lp[c_m].head, lp[c_m].tail, cur); | 669 | while (NULL != (cur = lp[c_m].head)) |
675 | GNUNET_free (cur->slaves_log); | 670 | { |
676 | GNUNET_free (cur); | 671 | GNUNET_CONTAINER_DLL_remove(lp[c_m].head, lp[c_m].tail, cur); |
672 | GNUNET_free(cur->slaves_log); | ||
673 | GNUNET_free(cur); | ||
674 | } | ||
677 | } | 675 | } |
678 | } | ||
679 | 676 | ||
680 | GNUNET_free (lp); | 677 | GNUNET_free(lp); |
681 | } | 678 | } |
682 | 679 | ||
683 | 680 | ||
684 | void | 681 | void |
685 | perf_logging_start (struct GNUNET_TIME_Relative log_frequency, | 682 | perf_logging_start(struct GNUNET_TIME_Relative log_frequency, |
686 | char * testname, struct BenchmarkPeer *masters, int num_masters) | 683 | char * testname, struct BenchmarkPeer *masters, int num_masters) |
687 | { | 684 | { |
688 | int c_m; | 685 | int c_m; |
686 | |||
689 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, | 687 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, |
690 | _("Start logging `%s'\n"), testname); | 688 | _("Start logging `%s'\n"), testname); |
691 | 689 | ||
692 | num_peers = num_masters; | 690 | num_peers = num_masters; |
693 | name = testname; | 691 | name = testname; |
694 | frequency = log_frequency; | 692 | frequency = log_frequency; |
695 | 693 | ||
696 | lp = GNUNET_malloc (num_masters * sizeof (struct LoggingPeer)); | 694 | lp = GNUNET_malloc(num_masters * sizeof(struct LoggingPeer)); |
697 | 695 | ||
698 | for (c_m = 0; c_m < num_masters; c_m ++) | 696 | for (c_m = 0; c_m < num_masters; c_m++) |
699 | { | 697 | { |
700 | lp[c_m].peer = &masters[c_m]; | 698 | lp[c_m].peer = &masters[c_m]; |
701 | lp[c_m].start = GNUNET_TIME_absolute_get(); | 699 | lp[c_m].start = GNUNET_TIME_absolute_get(); |
702 | } | 700 | } |
703 | 701 | ||
704 | /* Schedule logging task */ | 702 | /* Schedule logging task */ |
705 | log_task = GNUNET_SCHEDULER_add_now (&collect_log_task, NULL); | 703 | log_task = GNUNET_SCHEDULER_add_now(&collect_log_task, NULL); |
706 | running = GNUNET_YES; | 704 | running = GNUNET_YES; |
707 | } | 705 | } |
708 | /* end of file perf_ats_logging.c */ | 706 | /* end of file perf_ats_logging.c */ |