aboutsummaryrefslogtreecommitdiff
path: root/src/ats/gnunet-ats-solver-eval.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ats/gnunet-ats-solver-eval.c')
-rw-r--r--src/ats/gnunet-ats-solver-eval.c3826
1 files changed, 1950 insertions, 1876 deletions
diff --git a/src/ats/gnunet-ats-solver-eval.c b/src/ats/gnunet-ats-solver-eval.c
index 833cb9ded..4068cffce 100644
--- a/src/ats/gnunet-ats-solver-eval.c
+++ b/src/ats/gnunet-ats-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 */
@@ -85,32 +85,38 @@ static int opt_disable_normalization;
85static int res; 85static int res;
86 86
87static void 87static void
88end_now (); 88end_now();
89 89
90 90
91static char * 91static char *
92print_generator_type (enum GeneratorType g) 92print_generator_type(enum GeneratorType g)
93{ 93{
94 switch (g) { 94 switch (g)
95 {
95 case GNUNET_ATS_TEST_TG_CONSTANT: 96 case GNUNET_ATS_TEST_TG_CONSTANT:
96 return "CONSTANT"; 97 return "CONSTANT";
98
97 case GNUNET_ATS_TEST_TG_LINEAR: 99 case GNUNET_ATS_TEST_TG_LINEAR:
98 return "LINEAR"; 100 return "LINEAR";
101
99 case GNUNET_ATS_TEST_TG_RANDOM: 102 case GNUNET_ATS_TEST_TG_RANDOM:
100 return "RANDOM"; 103 return "RANDOM";
104
101 case GNUNET_ATS_TEST_TG_SINUS: 105 case GNUNET_ATS_TEST_TG_SINUS:
102 return "SINUS"; 106 return "SINUS";
107
103 default: 108 default:
104 return "INVALID"; 109 return "INVALID";
105 break; 110 break;
106 } 111 }
107} 112}
108 113
109 114
110static struct TestPeer * 115static struct TestPeer *
111find_peer_by_id (int id) 116find_peer_by_id(int id)
112{ 117{
113 struct TestPeer *cur; 118 struct TestPeer *cur;
119
114 for (cur = peer_head; NULL != cur; cur = cur->next) 120 for (cur = peer_head; NULL != cur; cur = cur->next)
115 if (cur->id == id) 121 if (cur->id == id)
116 return cur; 122 return cur;
@@ -118,19 +124,21 @@ find_peer_by_id (int id)
118} 124}
119 125
120static struct TestPeer * 126static struct TestPeer *
121find_peer_by_pid (const struct GNUNET_PeerIdentity *pid) 127find_peer_by_pid(const struct GNUNET_PeerIdentity *pid)
122{ 128{
123 struct TestPeer *cur; 129 struct TestPeer *cur;
130
124 for (cur = peer_head; NULL != cur; cur = cur->next) 131 for (cur = peer_head; NULL != cur; cur = cur->next)
125 if (0 == GNUNET_memcmp (&cur->peer_id, pid)) 132 if (0 == GNUNET_memcmp(&cur->peer_id, pid))
126 return cur; 133 return cur;
127 return NULL; 134 return NULL;
128} 135}
129 136
130static struct TestAddress * 137static struct TestAddress *
131find_address_by_id (struct TestPeer *peer, int aid) 138find_address_by_id(struct TestPeer *peer, int aid)
132{ 139{
133 struct TestAddress *cur; 140 struct TestAddress *cur;
141
134 for (cur = peer->addr_head; NULL != cur; cur = cur->next) 142 for (cur = peer->addr_head; NULL != cur; cur = cur->next)
135 if (cur->aid == aid) 143 if (cur->aid == aid)
136 return cur; 144 return cur;
@@ -142,7 +150,7 @@ find_address_by_id (struct TestPeer *peer, int aid)
142 * Logging 150 * Logging
143 */ 151 */
144void 152void
145GNUNET_ATS_solver_logging_now (struct LoggingHandle *l) 153GNUNET_ATS_solver_logging_now(struct LoggingHandle *l)
146{ 154{
147 struct LoggingTimeStep *lts; 155 struct LoggingTimeStep *lts;
148 struct TestPeer *cur; 156 struct TestPeer *cur;
@@ -151,7 +159,7 @@ GNUNET_ATS_solver_logging_now (struct LoggingHandle *l)
151 struct LoggingAddress *log_a; 159 struct LoggingAddress *log_a;
152 int c; 160 int c;
153 161
154 lts = GNUNET_new (struct LoggingTimeStep); 162 lts = GNUNET_new(struct LoggingTimeStep);
155 GNUNET_CONTAINER_DLL_insert_tail(l->head, l->tail, lts); 163 GNUNET_CONTAINER_DLL_insert_tail(l->head, l->tail, lts);
156 lts->timestamp = GNUNET_TIME_absolute_get(); 164 lts->timestamp = GNUNET_TIME_absolute_get();
157 if (NULL == lts->prev) 165 if (NULL == lts->prev)
@@ -159,102 +167,103 @@ GNUNET_ATS_solver_logging_now (struct LoggingHandle *l)
159 else 167 else
160 lts->delta = GNUNET_TIME_absolute_get_duration(lts->prev->timestamp); 168 lts->delta = GNUNET_TIME_absolute_get_duration(lts->prev->timestamp);
161 169
162 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Logging %llu, delta %llu\n", 170 GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Logging %llu, delta %llu\n",
163 lts->timestamp.abs_value_us, lts->delta.rel_value_us); 171 lts->timestamp.abs_value_us, lts->delta.rel_value_us);
164 172
165 173
166 /* Store logging data here */ 174 /* Store logging data here */
167 for (cur = peer_head; NULL != cur; cur = cur->next) 175 for (cur = peer_head; NULL != cur; cur = cur->next)
168 { 176 {
169 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 177 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
170 "Logging peer id %llu\n", cur->id); 178 "Logging peer id %llu\n", cur->id);
171 179
172 log_p = GNUNET_new (struct LoggingPeer); 180 log_p = GNUNET_new(struct LoggingPeer);
173 log_p->id = cur->id; 181 log_p->id = cur->id;
174 log_p->peer_id = cur->peer_id; 182 log_p->peer_id = cur->peer_id;
175 log_p->is_requested = cur->is_requested; 183 log_p->is_requested = cur->is_requested;
176 for (c = 0; c < GNUNET_ATS_PreferenceCount; c++) 184 for (c = 0; c < GNUNET_ATS_PreferenceCount; c++)
177 { 185 {
178 log_p->pref_abs[c] = cur->pref_abs[c]; 186 log_p->pref_abs[c] = cur->pref_abs[c];
179 log_p->pref_norm[c] = cur->pref_norm[c]; 187 log_p->pref_norm[c] = cur->pref_norm[c];
180 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 188 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
181 "\t %s = %.2f %.2f [abs/rel]\n", 189 "\t %s = %.2f %.2f [abs/rel]\n",
182 GNUNET_ATS_print_preference_type(c), 190 GNUNET_ATS_print_preference_type(c),
183 log_p->pref_abs[c], log_p->pref_norm[c]); 191 log_p->pref_abs[c], log_p->pref_norm[c]);
184 } 192 }
185 GNUNET_CONTAINER_DLL_insert_tail(lts->head, lts->tail, log_p); 193 GNUNET_CONTAINER_DLL_insert_tail(lts->head, lts->tail, log_p);
186
187 for (cur_addr = cur->addr_head; NULL != cur_addr; cur_addr = cur_addr->next)
188 {
189 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
190 "Logging peer id %llu address %llu\n",
191 cur->id, cur_addr->aid);
192 log_a = GNUNET_new (struct LoggingAddress);
193 log_a->aid = cur_addr->aid;
194 log_a->active = cur_addr->ats_addr->active;
195 log_a->network = cur_addr->network;
196 log_a->assigned_bw_in = cur_addr->ats_addr->assigned_bw_in;
197 log_a->assigned_bw_out = cur_addr->ats_addr->assigned_bw_out;
198 for (c = 0; c < GNUNET_ATS_PropertyCount; c++)
199 {
200 log_a->prop_abs[c] = cur_addr->prop_abs[c];
201 log_a->prop_norm[c] = cur_addr->prop_norm[c];
202 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
203 "\t %s = %.2f %.2f [abs/rel]\n",
204 GNUNET_ATS_print_property_type(c),
205 log_a->prop_abs[c],
206 log_a->prop_norm[c]);
207 }
208 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "\t Active = %i\n", log_a->active);
209 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "\t BW in = %llu\n", log_a->assigned_bw_in);
210 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "\t BW out = %llu\n", log_a->assigned_bw_out);
211 194
212 GNUNET_CONTAINER_DLL_insert_tail (log_p->addr_head, log_p->addr_tail, log_a); 195 for (cur_addr = cur->addr_head; NULL != cur_addr; cur_addr = cur_addr->next)
196 {
197 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
198 "Logging peer id %llu address %llu\n",
199 cur->id, cur_addr->aid);
200 log_a = GNUNET_new(struct LoggingAddress);
201 log_a->aid = cur_addr->aid;
202 log_a->active = cur_addr->ats_addr->active;
203 log_a->network = cur_addr->network;
204 log_a->assigned_bw_in = cur_addr->ats_addr->assigned_bw_in;
205 log_a->assigned_bw_out = cur_addr->ats_addr->assigned_bw_out;
206 for (c = 0; c < GNUNET_ATS_PropertyCount; c++)
207 {
208 log_a->prop_abs[c] = cur_addr->prop_abs[c];
209 log_a->prop_norm[c] = cur_addr->prop_norm[c];
210 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
211 "\t %s = %.2f %.2f [abs/rel]\n",
212 GNUNET_ATS_print_property_type(c),
213 log_a->prop_abs[c],
214 log_a->prop_norm[c]);
215 }
216 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "\t Active = %i\n", log_a->active);
217 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "\t BW in = %llu\n", log_a->assigned_bw_in);
218 GNUNET_log(GNUNET_ERROR_TYPE_INFO, "\t BW out = %llu\n", log_a->assigned_bw_out);
219
220 GNUNET_CONTAINER_DLL_insert_tail(log_p->addr_head, log_p->addr_tail, log_a);
221 }
213 } 222 }
214 }
215} 223}
216 224
217 225
218static void 226static void
219logging_task (void *cls) 227logging_task(void *cls)
220{ 228{
221 struct LoggingHandle *l = cls; 229 struct LoggingHandle *l = cls;
222 230
223 l->logging_task = NULL; 231 l->logging_task = NULL;
224 GNUNET_ATS_solver_logging_now (l); 232 GNUNET_ATS_solver_logging_now(l);
225 l->logging_task = GNUNET_SCHEDULER_add_delayed (l->log_freq, 233 l->logging_task = GNUNET_SCHEDULER_add_delayed(l->log_freq,
226 &logging_task, 234 &logging_task,
227 l); 235 l);
228} 236}
229 237
230struct LoggingHandle * 238struct LoggingHandle *
231GNUNET_ATS_solver_logging_start (struct GNUNET_TIME_Relative freq) 239GNUNET_ATS_solver_logging_start(struct GNUNET_TIME_Relative freq)
232{ 240{
233 struct LoggingHandle *l; 241 struct LoggingHandle *l;
234 l = GNUNET_new (struct LoggingHandle);
235 242
236 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Start logging every %s\n", 243 l = GNUNET_new(struct LoggingHandle);
237 GNUNET_STRINGS_relative_time_to_string(freq, GNUNET_NO)); 244
245 GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Start logging every %s\n",
246 GNUNET_STRINGS_relative_time_to_string(freq, GNUNET_NO));
238 l->log_freq = freq; 247 l->log_freq = freq;
239 l->logging_task = GNUNET_SCHEDULER_add_now (&logging_task, l); 248 l->logging_task = GNUNET_SCHEDULER_add_now(&logging_task, l);
240 return l; 249 return l;
241} 250}
242 251
243void 252void
244GNUNET_ATS_solver_logging_stop (struct LoggingHandle *l) 253GNUNET_ATS_solver_logging_stop(struct LoggingHandle *l)
245{ 254{
246 if (NULL != l->logging_task) 255 if (NULL != l->logging_task)
247 GNUNET_SCHEDULER_cancel (l->logging_task); 256 GNUNET_SCHEDULER_cancel(l->logging_task);
248 257
249 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Stop logging\n"); 258 GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Stop logging\n");
250 259
251 l->logging_task = NULL; 260 l->logging_task = NULL;
252} 261}
253 262
254static struct LoggingFileHandle * 263static struct LoggingFileHandle *
255find_logging_file_handle (struct LoggingFileHandle *lf_head, 264find_logging_file_handle(struct LoggingFileHandle *lf_head,
256 struct LoggingFileHandle *lf_tail, 265 struct LoggingFileHandle *lf_tail,
257 int peer_id, int address_id) 266 int peer_id, int address_id)
258{ 267{
259 struct LoggingFileHandle *res; 268 struct LoggingFileHandle *res;
260 269
@@ -262,12 +271,11 @@ find_logging_file_handle (struct LoggingFileHandle *lf_head,
262 if ((res->pid == peer_id) && (res->aid == address_id)) 271 if ((res->pid == peer_id) && (res->aid == address_id))
263 return res; 272 return res;
264 return NULL; 273 return NULL;
265
266} 274}
267 275
268void 276void
269GNUNET_ATS_solver_logging_write_to_disk (struct LoggingHandle *l, int add_time_stamp, 277GNUNET_ATS_solver_logging_write_to_disk(struct LoggingHandle *l, int add_time_stamp,
270 char *output_dir) 278 char *output_dir)
271{ 279{
272 struct LoggingTimeStep *lts; 280 struct LoggingTimeStep *lts;
273 struct LoggingPeer *log_p; 281 struct LoggingPeer *log_p;
@@ -287,157 +295,153 @@ GNUNET_ATS_solver_logging_write_to_disk (struct LoggingHandle *l, int add_time_s
287 295
288 use_dir = GNUNET_NO; 296 use_dir = GNUNET_NO;
289 if (NULL != output_dir) 297 if (NULL != output_dir)
290 {
291 if (GNUNET_OK != GNUNET_DISK_directory_create_for_file (output_dir))
292 {
293 fprintf (stderr, "Failed to create directory `%s'\n", output_dir);
294 return;
295 }
296 else
297 { 298 {
298 fprintf (stderr, "Created directory `%s'\n", output_dir); 299 if (GNUNET_OK != GNUNET_DISK_directory_create_for_file(output_dir))
299 use_dir = GNUNET_YES; 300 {
301 fprintf(stderr, "Failed to create directory `%s'\n", output_dir);
302 return;
303 }
304 else
305 {
306 fprintf(stderr, "Created directory `%s'\n", output_dir);
307 use_dir = GNUNET_YES;
308 }
300 } 309 }
301 }
302 310
303 lf_head = NULL; 311 lf_head = NULL;
304 lf_tail = NULL; 312 lf_tail = NULL;
305 313
306 for (lts = l->head; NULL != lts; lts = lts->next) 314 for (lts = l->head; NULL != lts; lts = lts->next)
307 {
308
309 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Writing log step %llu\n",
310 (long long unsigned int) lts->timestamp.abs_value_us);
311
312 for (log_p = lts->head; NULL != log_p; log_p = log_p->next)
313 { 315 {
314 for (log_a = log_p->addr_head; NULL != log_a; log_a = log_a->next) 316 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Writing log step %llu\n",
315 { 317 (long long unsigned int)lts->timestamp.abs_value_us);
316
317 cur = find_logging_file_handle (lf_head, lf_tail, log_p->id,
318 log_a->aid);
319 if (NULL == cur)
320 {
321 cur = GNUNET_new (struct LoggingFileHandle);
322 cur->aid = log_a->aid;
323 cur->pid = log_p->id;
324
325 if (GNUNET_YES == add_time_stamp)
326 GNUNET_asprintf (&filename, "%s%s%s_%s_p%u_a%u_%llu.log",
327 (GNUNET_YES == use_dir) ? output_dir : "",
328 (GNUNET_YES == use_dir) ? DIR_SEPARATOR_STR : "",
329 e->log_prefix,
330 opt_solver,
331 cur->pid,
332 cur->aid,
333 l->head->timestamp.abs_value_us);
334 else
335 GNUNET_asprintf (&filename, "%s%s%s_%s_p%u_a%u.log",
336 (GNUNET_YES == use_dir) ? output_dir : "",
337 (GNUNET_YES == use_dir) ? DIR_SEPARATOR_STR : "",
338 e->log_prefix,
339 opt_solver,
340 cur->pid,
341 cur->aid);
342
343 fprintf (stderr, "Add writing log data for peer %llu address %llu to file `%s'\n",
344 cur->pid, cur->aid, filename);
345
346
347 cur->f_hd = GNUNET_DISK_file_open (filename,
348 GNUNET_DISK_OPEN_READWRITE |
349 GNUNET_DISK_OPEN_CREATE |
350 GNUNET_DISK_OPEN_TRUNCATE,
351 GNUNET_DISK_PERM_USER_READ |
352 GNUNET_DISK_PERM_USER_WRITE |
353 GNUNET_DISK_PERM_GROUP_READ |
354 GNUNET_DISK_PERM_OTHER_READ);
355 if (NULL == cur->f_hd)
356 {
357 fprintf (stderr, "Cannot open `%s' to write log data!\n", filename);
358 GNUNET_free (filename);
359 GNUNET_free (cur);
360 goto cleanup;
361 }
362 GNUNET_free (filename);
363 GNUNET_CONTAINER_DLL_insert (lf_head, lf_tail, cur);
364
365 GNUNET_asprintf(&datastring,"#time delta;log duration;peer_requested;addr net; addr_active; bw in; bw out; " \
366 "UTILIZATION_UP [abs/rel]; UTILIZATION_UP; UTILIZATION_DOWN; UTILIZATION_DOWN; " \
367 "UTILIZATION_PAYLOAD_UP; UTILIZATION_PAYLOAD_UP; UTILIZATION_PAYLOAD_DOWN; UTILIZATION_PAYLOAD_DOWN;"\
368 "DELAY; DELAY; " \
369 "DISTANCE ;DISTANCE ; COST_WAN; COST_WAN; COST_LAN; COST_LAN; " \
370 "COST_WLAN; COST_WLAN;COST_BT; COST_BT; PREF BW abs; PREF BW rel; PREF LATENCY abs; PREF LATENCY rel;\n");
371 GNUNET_DISK_file_write (cur->f_hd, datastring, strlen(datastring));
372 GNUNET_free (datastring);
373
374 }
375 318
376 prefstring = GNUNET_strdup(""); 319 for (log_p = lts->head; NULL != log_p; log_p = log_p->next)
377 for (c = 1; c < GNUNET_ATS_PreferenceCount; c++)
378 { 320 {
379 /* 321 for (log_a = log_p->addr_head; NULL != log_a; log_a = log_a->next)
380 fprintf(stderr,"\t %s = %.2f %.2f [abs/rel]\n", 322 {
381 GNUNET_ATS_print_preference_type(c), 323 cur = find_logging_file_handle(lf_head, lf_tail, log_p->id,
382 log_p->pref_abs[c], log_p->pref_norm[c]); 324 log_a->aid);
383 */ 325 if (NULL == cur)
384 GNUNET_asprintf(&prefstring_tmp,"%s;%.3f;%.3f", 326 {
385 prefstring, log_p->pref_abs[c], log_p->pref_norm[c]); 327 cur = GNUNET_new(struct LoggingFileHandle);
386 328 cur->aid = log_a->aid;
387 329 cur->pid = log_p->id;
388 GNUNET_free (prefstring); 330
389 prefstring = GNUNET_strdup(prefstring_tmp); 331 if (GNUNET_YES == add_time_stamp)
390 GNUNET_free (prefstring_tmp); 332 GNUNET_asprintf(&filename, "%s%s%s_%s_p%u_a%u_%llu.log",
333 (GNUNET_YES == use_dir) ? output_dir : "",
334 (GNUNET_YES == use_dir) ? DIR_SEPARATOR_STR : "",
335 e->log_prefix,
336 opt_solver,
337 cur->pid,
338 cur->aid,
339 l->head->timestamp.abs_value_us);
340 else
341 GNUNET_asprintf(&filename, "%s%s%s_%s_p%u_a%u.log",
342 (GNUNET_YES == use_dir) ? output_dir : "",
343 (GNUNET_YES == use_dir) ? DIR_SEPARATOR_STR : "",
344 e->log_prefix,
345 opt_solver,
346 cur->pid,
347 cur->aid);
348
349 fprintf(stderr, "Add writing log data for peer %llu address %llu to file `%s'\n",
350 cur->pid, cur->aid, filename);
351
352
353 cur->f_hd = GNUNET_DISK_file_open(filename,
354 GNUNET_DISK_OPEN_READWRITE |
355 GNUNET_DISK_OPEN_CREATE |
356 GNUNET_DISK_OPEN_TRUNCATE,
357 GNUNET_DISK_PERM_USER_READ |
358 GNUNET_DISK_PERM_USER_WRITE |
359 GNUNET_DISK_PERM_GROUP_READ |
360 GNUNET_DISK_PERM_OTHER_READ);
361 if (NULL == cur->f_hd)
362 {
363 fprintf(stderr, "Cannot open `%s' to write log data!\n", filename);
364 GNUNET_free(filename);
365 GNUNET_free(cur);
366 goto cleanup;
367 }
368 GNUNET_free(filename);
369 GNUNET_CONTAINER_DLL_insert(lf_head, lf_tail, cur);
370
371 GNUNET_asprintf(&datastring, "#time delta;log duration;peer_requested;addr net; addr_active; bw in; bw out; " \
372 "UTILIZATION_UP [abs/rel]; UTILIZATION_UP; UTILIZATION_DOWN; UTILIZATION_DOWN; " \
373 "UTILIZATION_PAYLOAD_UP; UTILIZATION_PAYLOAD_UP; UTILIZATION_PAYLOAD_DOWN; UTILIZATION_PAYLOAD_DOWN;" \
374 "DELAY; DELAY; " \
375 "DISTANCE ;DISTANCE ; COST_WAN; COST_WAN; COST_LAN; COST_LAN; " \
376 "COST_WLAN; COST_WLAN;COST_BT; COST_BT; PREF BW abs; PREF BW rel; PREF LATENCY abs; PREF LATENCY rel;\n");
377 GNUNET_DISK_file_write(cur->f_hd, datastring, strlen(datastring));
378 GNUNET_free(datastring);
379 }
380
381 prefstring = GNUNET_strdup("");
382 for (c = 1; c < GNUNET_ATS_PreferenceCount; c++)
383 {
384 /*
385 fprintf(stderr,"\t %s = %.2f %.2f [abs/rel]\n",
386 GNUNET_ATS_print_preference_type(c),
387 log_p->pref_abs[c], log_p->pref_norm[c]);
388 */
389 GNUNET_asprintf(&prefstring_tmp, "%s;%.3f;%.3f",
390 prefstring, log_p->pref_abs[c], log_p->pref_norm[c]);
391
392
393 GNUNET_free(prefstring);
394 prefstring = GNUNET_strdup(prefstring_tmp);
395 GNUNET_free(prefstring_tmp);
396 }
397
398
399 propstring = GNUNET_strdup("");
400 for (c = 1; c < GNUNET_ATS_PropertyCount; c++)
401 {
402 if (GNUNET_ATS_NETWORK_TYPE == c)
403 continue;
404 /*
405 fprintf(stderr, "\t %s = %.2f %.2f [abs/rel]\n",
406 GNUNET_ATS_print_property_type(c),
407 log_a->prop_abs[c], log_a->prop_norm[c]);*/
408 GNUNET_asprintf(&propstring_tmp, "%s%.3f;%.3f;",
409 propstring,
410 log_a->prop_abs[c],
411 log_a->prop_norm[c]);
412 GNUNET_free(propstring);
413 propstring = GNUNET_strdup(propstring_tmp);
414 GNUNET_free(propstring_tmp);
415 }
416 GNUNET_asprintf(&datastring, "%llu;%llu;%u;%u;%i;%u;%u;%s;%s\n",
417 GNUNET_TIME_absolute_get_difference(l->head->timestamp,
418 lts->timestamp).rel_value_us / 1000, lts->delta,
419 log_p->is_requested, log_a->network, log_a->active,
420 log_a->assigned_bw_in, log_a->assigned_bw_out, propstring,
421 prefstring);
422
423 GNUNET_DISK_file_write(cur->f_hd, datastring, strlen(datastring));
424 GNUNET_free(datastring);
425 GNUNET_free(prefstring);
426 GNUNET_free(propstring);
427 }
391 } 428 }
392
393
394 propstring = GNUNET_strdup("");
395 for (c = 1; c < GNUNET_ATS_PropertyCount; c++)
396 {
397 if (GNUNET_ATS_NETWORK_TYPE == c)
398 continue;
399 /*
400 fprintf(stderr, "\t %s = %.2f %.2f [abs/rel]\n",
401 GNUNET_ATS_print_property_type(c),
402 log_a->prop_abs[c], log_a->prop_norm[c]);*/
403 GNUNET_asprintf(&propstring_tmp,"%s%.3f;%.3f;",
404 propstring,
405 log_a->prop_abs[c],
406 log_a->prop_norm[c]);
407 GNUNET_free (propstring);
408 propstring = GNUNET_strdup(propstring_tmp);
409 GNUNET_free (propstring_tmp);
410 }
411 GNUNET_asprintf (&datastring, "%llu;%llu;%u;%u;%i;%u;%u;%s;%s\n",
412 GNUNET_TIME_absolute_get_difference (l->head->timestamp,
413 lts->timestamp).rel_value_us / 1000, lts->delta,
414 log_p->is_requested, log_a->network, log_a->active,
415 log_a->assigned_bw_in, log_a->assigned_bw_out, propstring,
416 prefstring);
417
418 GNUNET_DISK_file_write (cur->f_hd, datastring, strlen(datastring));
419 GNUNET_free (datastring);
420 GNUNET_free (prefstring);
421 GNUNET_free (propstring);
422 }
423 } 429 }
424 }
425 430
426cleanup: 431cleanup:
427 next = lf_head; 432 next = lf_head;
428 for (cur = next; NULL != cur; cur = next) 433 for (cur = next; NULL != cur; cur = next)
429 { 434 {
430 next = cur->next; 435 next = cur->next;
431 GNUNET_CONTAINER_DLL_remove (lf_head, lf_tail, cur); 436 GNUNET_CONTAINER_DLL_remove(lf_head, lf_tail, cur);
432 if (NULL != cur->f_hd) 437 if (NULL != cur->f_hd)
433 GNUNET_DISK_file_close (cur->f_hd); 438 GNUNET_DISK_file_close(cur->f_hd);
434 GNUNET_free (cur); 439 GNUNET_free(cur);
435 } 440 }
436
437} 441}
438 442
439void 443void
440GNUNET_ATS_solver_logging_eval (struct LoggingHandle *l) 444GNUNET_ATS_solver_logging_eval(struct LoggingHandle *l)
441{ 445{
442 struct LoggingTimeStep *lts; 446 struct LoggingTimeStep *lts;
443 struct LoggingPeer *log_p; 447 struct LoggingPeer *log_p;
@@ -445,43 +449,43 @@ GNUNET_ATS_solver_logging_eval (struct LoggingHandle *l)
445 int c; 449 int c;
446 450
447 for (lts = l->head; NULL != lts; lts = lts->next) 451 for (lts = l->head; NULL != lts; lts = lts->next)
448 {
449 fprintf (stderr, "Log step %llu %llu: \n",
450 (long long unsigned int) lts->timestamp.abs_value_us,
451 (long long unsigned int) lts->delta.rel_value_us);
452
453 for (log_p = lts->head; NULL != log_p; log_p = log_p->next)
454 { 452 {
455 fprintf (stderr,"\tLogging peer pid %llu\n", log_p->id); 453 fprintf(stderr, "Log step %llu %llu: \n",
456 for (c = 1; c < GNUNET_ATS_PreferenceCount; c++) 454 (long long unsigned int)lts->timestamp.abs_value_us,
457 { 455 (long long unsigned int)lts->delta.rel_value_us);
458 fprintf(stderr,"\t %s = %.2f %.2f [abs/rel]\n",
459 GNUNET_ATS_print_preference_type(c),
460 log_p->pref_abs[c], log_p->pref_norm[c]);
461 }
462
463 for (log_a = log_p->addr_head; NULL != log_a; log_a = log_a->next)
464 {
465 fprintf (stderr, "\tPeer pid %llu address %llu: %u %u %u\n",
466 log_p->id, log_a->aid, log_a->active,
467 log_a->assigned_bw_in,
468 log_a->assigned_bw_out);
469 456
470 for (c = 1; c < GNUNET_ATS_PropertyCount; c++) 457 for (log_p = lts->head; NULL != log_p; log_p = log_p->next)
471 { 458 {
472 if (GNUNET_ATS_NETWORK_TYPE == c) 459 fprintf(stderr, "\tLogging peer pid %llu\n", log_p->id);
473 continue; 460 for (c = 1; c < GNUNET_ATS_PreferenceCount; c++)
474 fprintf(stderr, "\t %s = %.2f %.2f [abs/rel]\n", 461 {
475 GNUNET_ATS_print_property_type(c), 462 fprintf(stderr, "\t %s = %.2f %.2f [abs/rel]\n",
476 log_a->prop_abs[c], log_a->prop_norm[c]); 463 GNUNET_ATS_print_preference_type(c),
464 log_p->pref_abs[c], log_p->pref_norm[c]);
465 }
466
467 for (log_a = log_p->addr_head; NULL != log_a; log_a = log_a->next)
468 {
469 fprintf(stderr, "\tPeer pid %llu address %llu: %u %u %u\n",
470 log_p->id, log_a->aid, log_a->active,
471 log_a->assigned_bw_in,
472 log_a->assigned_bw_out);
473
474 for (c = 1; c < GNUNET_ATS_PropertyCount; c++)
475 {
476 if (GNUNET_ATS_NETWORK_TYPE == c)
477 continue;
478 fprintf(stderr, "\t %s = %.2f %.2f [abs/rel]\n",
479 GNUNET_ATS_print_property_type(c),
480 log_a->prop_abs[c], log_a->prop_norm[c]);
481 }
482 }
477 } 483 }
478 }
479 } 484 }
480 }
481} 485}
482 486
483void 487void
484GNUNET_ATS_solver_logging_free (struct LoggingHandle *l) 488GNUNET_ATS_solver_logging_free(struct LoggingHandle *l)
485{ 489{
486 struct LoggingTimeStep *lts_cur; 490 struct LoggingTimeStep *lts_cur;
487 struct LoggingTimeStep *lts_next; 491 struct LoggingTimeStep *lts_next;
@@ -491,37 +495,37 @@ GNUNET_ATS_solver_logging_free (struct LoggingHandle *l)
491 struct LoggingAddress *log_a_next; 495 struct LoggingAddress *log_a_next;
492 496
493 if (NULL != l->logging_task) 497 if (NULL != l->logging_task)
494 GNUNET_SCHEDULER_cancel (l->logging_task); 498 GNUNET_SCHEDULER_cancel(l->logging_task);
495 l->logging_task = NULL; 499 l->logging_task = NULL;
496 500
497 lts_next = l->head; 501 lts_next = l->head;
498 while (NULL != (lts_cur = lts_next)) 502 while (NULL != (lts_cur = lts_next))
499 {
500 lts_next = lts_cur->next;
501
502 log_p_next = lts_cur->head;
503 while (NULL != (log_p_cur = log_p_next))
504 { 503 {
505 log_p_next = log_p_cur->next; 504 lts_next = lts_cur->next;
506 505
507 log_a_next = log_p_cur->addr_head; 506 log_p_next = lts_cur->head;
508 while (NULL != (log_a_cur = log_a_next)) 507 while (NULL != (log_p_cur = log_p_next))
509 { 508 {
510 log_a_next = log_a_cur->next; 509 log_p_next = log_p_cur->next;
511 510
512 GNUNET_CONTAINER_DLL_remove (log_p_cur->addr_head, log_p_cur->addr_tail, log_a_cur); 511 log_a_next = log_p_cur->addr_head;
513 GNUNET_free (log_a_cur); 512 while (NULL != (log_a_cur = log_a_next))
514 } 513 {
514 log_a_next = log_a_cur->next;
515 515
516 GNUNET_CONTAINER_DLL_remove (lts_cur->head, lts_cur->tail, log_p_cur); 516 GNUNET_CONTAINER_DLL_remove(log_p_cur->addr_head, log_p_cur->addr_tail, log_a_cur);
517 GNUNET_free (log_p_cur); 517 GNUNET_free(log_a_cur);
518 } 518 }
519 519
520 GNUNET_CONTAINER_DLL_remove (l->head, l->tail, lts_cur); 520 GNUNET_CONTAINER_DLL_remove(lts_cur->head, lts_cur->tail, log_p_cur);
521 GNUNET_free (lts_cur); 521 GNUNET_free(log_p_cur);
522 } 522 }
523 523
524 GNUNET_free (l); 524 GNUNET_CONTAINER_DLL_remove(l->head, l->tail, lts_cur);
525 GNUNET_free(lts_cur);
526 }
527
528 GNUNET_free(l);
525} 529}
526 530
527/** 531/**
@@ -532,65 +536,70 @@ static struct PropertyGenerator *prop_gen_tail;
532 536
533 537
534static double 538static double
535get_property (struct PropertyGenerator *pg) 539get_property(struct PropertyGenerator *pg)
536{ 540{
537 struct GNUNET_TIME_Relative time_delta; 541 struct GNUNET_TIME_Relative time_delta;
538 double delta_value; 542 double delta_value;
539 double pref_value; 543 double pref_value;
540 544
541 /* Calculate the current preference value */ 545 /* Calculate the current preference value */
542 switch (pg->type) { 546 switch (pg->type)
547 {
543 case GNUNET_ATS_TEST_TG_CONSTANT: 548 case GNUNET_ATS_TEST_TG_CONSTANT:
544 pref_value = pg->base_value; 549 pref_value = pg->base_value;
545 break; 550 break;
551
546 case GNUNET_ATS_TEST_TG_LINEAR: 552 case GNUNET_ATS_TEST_TG_LINEAR:
547 time_delta = GNUNET_TIME_absolute_get_duration(pg->time_start); 553 time_delta = GNUNET_TIME_absolute_get_duration(pg->time_start);
548 /* Calculate point of time in the current period */ 554 /* Calculate point of time in the current period */
549 time_delta.rel_value_us = time_delta.rel_value_us % 555 time_delta.rel_value_us = time_delta.rel_value_us %
550 pg->duration_period.rel_value_us; 556 pg->duration_period.rel_value_us;
551 delta_value = ((double) time_delta.rel_value_us / 557 delta_value = ((double)time_delta.rel_value_us /
552 pg->duration_period.rel_value_us) * (pg->max_value - pg->base_value); 558 pg->duration_period.rel_value_us) * (pg->max_value - pg->base_value);
553 if ((pg->max_value < pg->base_value) && 559 if ((pg->max_value < pg->base_value) &&
554 ((pg->max_value - pg->base_value) > pg->base_value)) 560 ((pg->max_value - pg->base_value) > pg->base_value))
555 { 561 {
556 /* This will cause an underflow */ 562 /* This will cause an underflow */
557 GNUNET_break (0); 563 GNUNET_break(0);
558 } 564 }
559 pref_value = pg->base_value + delta_value; 565 pref_value = pg->base_value + delta_value;
560 break; 566 break;
567
561 case GNUNET_ATS_TEST_TG_RANDOM: 568 case GNUNET_ATS_TEST_TG_RANDOM:
562 delta_value = (double) GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 569 delta_value = (double)GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_WEAK,
563 10000 * (pg->max_value - pg->base_value)) / 10000; 570 10000 * (pg->max_value - pg->base_value)) / 10000;
564 pref_value = pg->base_value + delta_value; 571 pref_value = pg->base_value + delta_value;
565 break; 572 break;
573
566 case GNUNET_ATS_TEST_TG_SINUS: 574 case GNUNET_ATS_TEST_TG_SINUS:
567 time_delta = GNUNET_TIME_absolute_get_duration(pg->time_start); 575 time_delta = GNUNET_TIME_absolute_get_duration(pg->time_start);
568 /* Calculate point of time in the current period */ 576 /* Calculate point of time in the current period */
569 time_delta.rel_value_us = time_delta.rel_value_us % 577 time_delta.rel_value_us = time_delta.rel_value_us %
570 pg->duration_period.rel_value_us; 578 pg->duration_period.rel_value_us;
571 if ((pg->max_value - pg->base_value) > pg->base_value) 579 if ((pg->max_value - pg->base_value) > pg->base_value)
572 { 580 {
573 /* This will cause an underflow for second half of sinus period, 581 /* This will cause an underflow for second half of sinus period,
574 * will be detected in general when experiments are loaded */ 582 * will be detected in general when experiments are loaded */
575 GNUNET_break (0); 583 GNUNET_break(0);
576 } 584 }
577 delta_value = (pg->max_value - pg->base_value) * 585 delta_value = (pg->max_value - pg->base_value) *
578 sin ( (2 * M_PI) / ((double) pg->duration_period.rel_value_us) * 586 sin((2 * M_PI) / ((double)pg->duration_period.rel_value_us) *
579 time_delta.rel_value_us); 587 time_delta.rel_value_us);
580 pref_value = pg->base_value + delta_value; 588 pref_value = pg->base_value + delta_value;
581 break; 589 break;
590
582 default: 591 default:
583 pref_value = 0.0; 592 pref_value = 0.0;
584 break; 593 break;
585 } 594 }
586 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Current property value is %f\n", 595 GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Current property value is %f\n",
587 pref_value); 596 pref_value);
588 return pref_value; 597 return pref_value;
589} 598}
590 599
591 600
592static void 601static void
593set_prop_task (void *cls) 602set_prop_task(void *cls)
594{ 603{
595 struct PropertyGenerator *pg = cls; 604 struct PropertyGenerator *pg = cls;
596 struct TestPeer *p; 605 struct TestPeer *p;
@@ -600,58 +609,58 @@ set_prop_task (void *cls)
600 609
601 pg->set_task = NULL; 610 pg->set_task = NULL;
602 611
603 if (GNUNET_NO == GNUNET_CONTAINER_multipeermap_contains_value (sh->addresses, 612 if (GNUNET_NO == GNUNET_CONTAINER_multipeermap_contains_value(sh->addresses,
604 &pg->test_peer->peer_id, pg->test_address->ats_addr)) 613 &pg->test_peer->peer_id, pg->test_address->ats_addr))
605 { 614 {
606 GNUNET_break (0); 615 GNUNET_break(0);
607 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 616 GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
608 "Setting property generation for unknown address [%u:%u]\n", 617 "Setting property generation for unknown address [%u:%u]\n",
609 pg->peer, pg->address_id); 618 pg->peer, pg->address_id);
610 return; 619 return;
611 } 620 }
612 if (NULL == (p = find_peer_by_id (pg->peer))) 621 if (NULL == (p = find_peer_by_id(pg->peer)))
613 { 622 {
614 GNUNET_break (0); 623 GNUNET_break(0);
615 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 624 GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
616 "Setting property generation for unknown peer %u\n", 625 "Setting property generation for unknown peer %u\n",
617 pg->peer); 626 pg->peer);
618 return; 627 return;
619 } 628 }
620 if (NULL == (a = find_address_by_id (p, pg->address_id))) 629 if (NULL == (a = find_address_by_id(p, pg->address_id)))
621 { 630 {
622 GNUNET_break (0); 631 GNUNET_break(0);
623 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 632 GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
624 "Setting property generation for unknown peer %u\n", 633 "Setting property generation for unknown peer %u\n",
625 pg->peer); 634 pg->peer);
626 return; 635 return;
627 } 636 }
628 637
629 prop_value = get_property (pg); 638 prop_value = get_property(pg);
630 a->prop_abs[pg->ats_property] = prop_value; 639 a->prop_abs[pg->ats_property] = prop_value;
631 640
632 GNUNET_log(GNUNET_ERROR_TYPE_INFO, 641 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
633 "Setting property for peer [%u] address [%u] for %s to %f\n", 642 "Setting property for peer [%u] address [%u] for %s to %f\n",
634 pg->peer, pg->address_id, 643 pg->peer, pg->address_id,
635 GNUNET_ATS_print_property_type (pg->ats_property), prop_value); 644 GNUNET_ATS_print_property_type(pg->ats_property), prop_value);
636 645
637 atsi.type = htonl (pg->ats_property); 646 atsi.type = htonl(pg->ats_property);
638 atsi.value = htonl ((uint32_t) prop_value); 647 atsi.value = htonl((uint32_t)prop_value);
639 648
640 /* set performance here! */ 649 /* set performance here! */
641 sh->sf->s_bulk_start (sh->sf->cls); 650 sh->sf->s_bulk_start(sh->sf->cls);
642 if (GNUNET_YES == opt_disable_normalization) 651 if (GNUNET_YES == opt_disable_normalization)
643 { 652 {
644 a->prop_abs[pg->ats_property] = prop_value; 653 a->prop_abs[pg->ats_property] = prop_value;
645 a->prop_norm[pg->ats_property] = prop_value; 654 a->prop_norm[pg->ats_property] = prop_value;
646 sh->sf->s_address_update_property (sh->sf->cls, a->ats_addr, 655 sh->sf->s_address_update_property(sh->sf->cls, a->ats_addr,
647 pg->ats_property, prop_value, prop_value); 656 pg->ats_property, prop_value, prop_value);
648 } 657 }
649 else 658 else
650 GAS_normalization_update_property (pg->test_address->ats_addr, &atsi, 1); 659 GAS_normalization_update_property(pg->test_address->ats_addr, &atsi, 1);
651 sh->sf->s_bulk_stop (sh->sf->cls); 660 sh->sf->s_bulk_stop(sh->sf->cls);
652 661
653 pg->set_task = GNUNET_SCHEDULER_add_delayed (pg->frequency, 662 pg->set_task = GNUNET_SCHEDULER_add_delayed(pg->frequency,
654 &set_prop_task, pg); 663 &set_prop_task, pg);
655} 664}
656 665
657 666
@@ -659,35 +668,36 @@ set_prop_task (void *cls)
659 * Set ats_property to 0 to find all pgs 668 * Set ats_property to 0 to find all pgs
660 */ 669 */
661static struct PropertyGenerator * 670static struct PropertyGenerator *
662find_prop_gen (unsigned int peer, unsigned int address, 671find_prop_gen(unsigned int peer, unsigned int address,
663 uint32_t ats_property) 672 uint32_t ats_property)
664{ 673{
665 struct PropertyGenerator *cur; 674 struct PropertyGenerator *cur;
675
666 for (cur = prop_gen_head; NULL != cur; cur = cur->next) 676 for (cur = prop_gen_head; NULL != cur; cur = cur->next)
667 if ((cur->peer == peer) && (cur->address_id == address)) 677 if ((cur->peer == peer) && (cur->address_id == address))
668 { 678 {
669 if ((cur->ats_property == ats_property) || (0 == ats_property)) 679 if ((cur->ats_property == ats_property) || (0 == ats_property))
670 return cur; 680 return cur;
671 } 681 }
672 return NULL; 682 return NULL;
673} 683}
674 684
675void 685void
676GNUNET_ATS_solver_generate_property_stop (struct PropertyGenerator *pg) 686GNUNET_ATS_solver_generate_property_stop(struct PropertyGenerator *pg)
677{ 687{
678 GNUNET_CONTAINER_DLL_remove (prop_gen_head, prop_gen_tail, pg); 688 GNUNET_CONTAINER_DLL_remove(prop_gen_head, prop_gen_tail, pg);
679 689
680 if (NULL != pg->set_task) 690 if (NULL != pg->set_task)
681 { 691 {
682 GNUNET_SCHEDULER_cancel (pg->set_task); 692 GNUNET_SCHEDULER_cancel(pg->set_task);
683 pg->set_task = NULL; 693 pg->set_task = NULL;
684 } 694 }
685 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 695 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
686 "Removing old up preference generator peer [%u] address [%u] `%s'\n", 696 "Removing old up preference generator peer [%u] address [%u] `%s'\n",
687 pg->peer, pg->address_id, 697 pg->peer, pg->address_id,
688 GNUNET_ATS_print_property_type(pg->ats_property)); 698 GNUNET_ATS_print_property_type(pg->ats_property));
689 699
690 GNUNET_free (pg); 700 GNUNET_free(pg);
691} 701}
692 702
693 703
@@ -708,21 +718,21 @@ GNUNET_ATS_solver_generate_property_stop (struct PropertyGenerator *pg)
708 * @return the property generator 718 * @return the property generator
709 */ 719 */
710struct PropertyGenerator * 720struct PropertyGenerator *
711GNUNET_ATS_solver_generate_property_start (unsigned int peer, 721GNUNET_ATS_solver_generate_property_start(unsigned int peer,
712 unsigned int address_id, 722 unsigned int address_id,
713 struct TestPeer *test_peer, 723 struct TestPeer *test_peer,
714 struct TestAddress *test_address, 724 struct TestAddress *test_address,
715 enum GeneratorType type, 725 enum GeneratorType type,
716 long int base_value, 726 long int base_value,
717 long int value_rate, 727 long int value_rate,
718 struct GNUNET_TIME_Relative period, 728 struct GNUNET_TIME_Relative period,
719 struct GNUNET_TIME_Relative frequency, 729 struct GNUNET_TIME_Relative frequency,
720 uint32_t ats_property) 730 uint32_t ats_property)
721{ 731{
722 struct PropertyGenerator *pg; 732 struct PropertyGenerator *pg;
723 733
724 pg = GNUNET_new (struct PropertyGenerator); 734 pg = GNUNET_new(struct PropertyGenerator);
725 GNUNET_CONTAINER_DLL_insert (prop_gen_head, prop_gen_tail, pg); 735 GNUNET_CONTAINER_DLL_insert(prop_gen_head, prop_gen_tail, pg);
726 pg->type = type; 736 pg->type = type;
727 pg->peer = peer; 737 pg->peer = peer;
728 pg->test_address = test_address; 738 pg->test_address = test_address;
@@ -735,44 +745,49 @@ GNUNET_ATS_solver_generate_property_start (unsigned int peer,
735 pg->frequency = frequency; 745 pg->frequency = frequency;
736 pg->time_start = GNUNET_TIME_absolute_get(); 746 pg->time_start = GNUNET_TIME_absolute_get();
737 747
738 switch (type) { 748 switch (type)
749 {
739 case GNUNET_ATS_TEST_TG_CONSTANT: 750 case GNUNET_ATS_TEST_TG_CONSTANT:
740 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 751 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
741 "Setting up %s property generator peer [%u] address [%u] `%s'"\ 752 "Setting up %s property generator peer [%u] address [%u] `%s'" \
742 "max %u Bips\n", 753 "max %u Bips\n",
743 print_generator_type(type), pg->peer, pg->address_id, 754 print_generator_type(type), pg->peer, pg->address_id,
744 GNUNET_ATS_print_property_type (ats_property), 755 GNUNET_ATS_print_property_type(ats_property),
745 base_value); 756 base_value);
746 break; 757 break;
758
747 case GNUNET_ATS_TEST_TG_LINEAR: 759 case GNUNET_ATS_TEST_TG_LINEAR:
748 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 760 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
749 "Setting up %s property generator peer [%u] address [%u] `%s' " \ 761 "Setting up %s property generator peer [%u] address [%u] `%s' " \
750 "min %u Bips max %u Bips\n", 762 "min %u Bips max %u Bips\n",
751 print_generator_type(type), pg->peer, pg->address_id, 763 print_generator_type(type), pg->peer, pg->address_id,
752 GNUNET_ATS_print_property_type(ats_property), 764 GNUNET_ATS_print_property_type(ats_property),
753 base_value, value_rate); 765 base_value, value_rate);
754 break; 766 break;
767
755 case GNUNET_ATS_TEST_TG_SINUS: 768 case GNUNET_ATS_TEST_TG_SINUS:
756 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 769 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
757 "Setting up %s property generator peer [%u] address [%u] `%s' "\ 770 "Setting up %s property generator peer [%u] address [%u] `%s' " \
758 "baserate %u Bips, amplitude %u Bps\n", 771 "baserate %u Bips, amplitude %u Bps\n",
759 print_generator_type(type), pg->peer, pg->address_id, 772 print_generator_type(type), pg->peer, pg->address_id,
760 GNUNET_ATS_print_property_type(ats_property), 773 GNUNET_ATS_print_property_type(ats_property),
761 base_value, value_rate); 774 base_value, value_rate);
762 break; 775 break;
776
763 case GNUNET_ATS_TEST_TG_RANDOM: 777 case GNUNET_ATS_TEST_TG_RANDOM:
764 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 778 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
765 "Setting up %s property generator peer [%u] address [%u] `%s' "\ 779 "Setting up %s property generator peer [%u] address [%u] `%s' " \
766 "min %u Bips max %u Bps\n", 780 "min %u Bips max %u Bps\n",
767 print_generator_type(type), pg->peer, pg->address_id, 781 print_generator_type(type), pg->peer, pg->address_id,
768 GNUNET_ATS_print_property_type(ats_property), 782 GNUNET_ATS_print_property_type(ats_property),
769 base_value, value_rate); 783 base_value, value_rate);
770 break; 784 break;
785
771 default: 786 default:
772 break; 787 break;
773 } 788 }
774 789
775 pg->set_task = GNUNET_SCHEDULER_add_now (&set_prop_task, pg); 790 pg->set_task = GNUNET_SCHEDULER_add_now(&set_prop_task, pg);
776 return pg; 791 return pg;
777} 792}
778 793
@@ -781,16 +796,17 @@ GNUNET_ATS_solver_generate_property_start (unsigned int peer,
781 * Stop all preferences generators 796 * Stop all preferences generators
782 */ 797 */
783void 798void
784GNUNET_ATS_solver_generate_property_stop_all () 799GNUNET_ATS_solver_generate_property_stop_all()
785{ 800{
786 struct PropertyGenerator *cur; 801 struct PropertyGenerator *cur;
787 struct PropertyGenerator *next; 802 struct PropertyGenerator *next;
803
788 next = prop_gen_head; 804 next = prop_gen_head;
789 for (cur = next; NULL != cur; cur = next) 805 for (cur = next; NULL != cur; cur = next)
790 { 806 {
791 next = cur->next; 807 next = cur->next;
792 GNUNET_ATS_solver_generate_property_stop (cur); 808 GNUNET_ATS_solver_generate_property_stop(cur);
793 } 809 }
794} 810}
795 811
796 812
@@ -802,65 +818,70 @@ static struct PreferenceGenerator *pref_gen_tail;
802 818
803 819
804static double 820static double
805get_preference (struct PreferenceGenerator *pg) 821get_preference(struct PreferenceGenerator *pg)
806{ 822{
807 struct GNUNET_TIME_Relative time_delta; 823 struct GNUNET_TIME_Relative time_delta;
808 double delta_value; 824 double delta_value;
809 double pref_value; 825 double pref_value;
810 826
811 /* Calculate the current preference value */ 827 /* Calculate the current preference value */
812 switch (pg->type) { 828 switch (pg->type)
829 {
813 case GNUNET_ATS_TEST_TG_CONSTANT: 830 case GNUNET_ATS_TEST_TG_CONSTANT:
814 pref_value = pg->base_value; 831 pref_value = pg->base_value;
815 break; 832 break;
833
816 case GNUNET_ATS_TEST_TG_LINEAR: 834 case GNUNET_ATS_TEST_TG_LINEAR:
817 time_delta = GNUNET_TIME_absolute_get_duration(pg->time_start); 835 time_delta = GNUNET_TIME_absolute_get_duration(pg->time_start);
818 /* Calculate point of time in the current period */ 836 /* Calculate point of time in the current period */
819 time_delta.rel_value_us = time_delta.rel_value_us % 837 time_delta.rel_value_us = time_delta.rel_value_us %
820 pg->duration_period.rel_value_us; 838 pg->duration_period.rel_value_us;
821 delta_value = ((double) time_delta.rel_value_us / 839 delta_value = ((double)time_delta.rel_value_us /
822 pg->duration_period.rel_value_us) * (pg->max_value - pg->base_value); 840 pg->duration_period.rel_value_us) * (pg->max_value - pg->base_value);
823 if ((pg->max_value < pg->base_value) && 841 if ((pg->max_value < pg->base_value) &&
824 ((pg->max_value - pg->base_value) > pg->base_value)) 842 ((pg->max_value - pg->base_value) > pg->base_value))
825 { 843 {
826 /* This will cause an underflow */ 844 /* This will cause an underflow */
827 GNUNET_break (0); 845 GNUNET_break(0);
828 } 846 }
829 pref_value = pg->base_value + delta_value; 847 pref_value = pg->base_value + delta_value;
830 break; 848 break;
849
831 case GNUNET_ATS_TEST_TG_RANDOM: 850 case GNUNET_ATS_TEST_TG_RANDOM:
832 delta_value = (double) GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 851 delta_value = (double)GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_WEAK,
833 10000 * (pg->max_value - pg->base_value)) / 10000; 852 10000 * (pg->max_value - pg->base_value)) / 10000;
834 pref_value = pg->base_value + delta_value; 853 pref_value = pg->base_value + delta_value;
835 break; 854 break;
855
836 case GNUNET_ATS_TEST_TG_SINUS: 856 case GNUNET_ATS_TEST_TG_SINUS:
837 time_delta = GNUNET_TIME_absolute_get_duration(pg->time_start); 857 time_delta = GNUNET_TIME_absolute_get_duration(pg->time_start);
838 /* Calculate point of time in the current period */ 858 /* Calculate point of time in the current period */
839 time_delta.rel_value_us = time_delta.rel_value_us % 859 time_delta.rel_value_us = time_delta.rel_value_us %
840 pg->duration_period.rel_value_us; 860 pg->duration_period.rel_value_us;
841 if ((pg->max_value - pg->base_value) > pg->base_value) 861 if ((pg->max_value - pg->base_value) > pg->base_value)
842 { 862 {
843 /* This will cause an underflow for second half of sinus period, 863 /* This will cause an underflow for second half of sinus period,
844 * will be detected in general when experiments are loaded */ 864 * will be detected in general when experiments are loaded */
845 GNUNET_break (0); 865 GNUNET_break(0);
846 } 866 }
847 delta_value = (pg->max_value - pg->base_value) * 867 delta_value = (pg->max_value - pg->base_value) *
848 sin ( (2 * M_PI) / ((double) pg->duration_period.rel_value_us) * 868 sin((2 * M_PI) / ((double)pg->duration_period.rel_value_us) *
849 time_delta.rel_value_us); 869 time_delta.rel_value_us);
850 pref_value = pg->base_value + delta_value; 870 pref_value = pg->base_value + delta_value;
851 break; 871 break;
872
852 default: 873 default:
853 pref_value = 0.0; 874 pref_value = 0.0;
854 break; 875 break;
855 } 876 }
856 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Current preference value is %f\n", 877 GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Current preference value is %f\n",
857 pref_value); 878 pref_value);
858 return pref_value; 879 return pref_value;
859} 880}
860 881
861 882
862static void 883static void
863set_feedback_task (void *cls) 884set_feedback_task(void *cls)
864{ 885{
865 struct PreferenceGenerator *pg = cls; 886 struct PreferenceGenerator *pg = cls;
866 struct TestPeer *p; 887 struct TestPeer *p;
@@ -873,50 +894,52 @@ set_feedback_task (void *cls)
873 894
874 pg->feedback_task = NULL; 895 pg->feedback_task = NULL;
875 896
876 if (NULL == (p = find_peer_by_id (pg->peer))) 897 if (NULL == (p = find_peer_by_id(pg->peer)))
877 { 898 {
878 GNUNET_break (0); 899 GNUNET_break(0);
879 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 900 GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
880 "Setting feedback for unknown peer %u\n", pg->peer); 901 "Setting feedback for unknown peer %u\n", pg->peer);
881 return; 902 return;
882 } 903 }
883 904
884 switch (pg->kind) 905 switch (pg->kind)
885 { 906 {
886 case GNUNET_ATS_PREFERENCE_BANDWIDTH: 907 case GNUNET_ATS_PREFERENCE_BANDWIDTH:
887 dur = GNUNET_TIME_absolute_get_duration(pg->feedback_last_bw_update); 908 dur = GNUNET_TIME_absolute_get_duration(pg->feedback_last_bw_update);
888 bw_acc_in = dur.rel_value_us *pg->last_assigned_bw_in + pg->feedback_bw_in_acc; 909 bw_acc_in = dur.rel_value_us * pg->last_assigned_bw_in + pg->feedback_bw_in_acc;
889 pg->feedback_bw_in_acc = 0; 910 pg->feedback_bw_in_acc = 0;
890 911
891 bw_acc_out = dur.rel_value_us *pg->last_assigned_bw_out + pg->feedback_bw_out_acc; 912 bw_acc_out = dur.rel_value_us * pg->last_assigned_bw_out + pg->feedback_bw_out_acc;
892 p_new = get_preference (pg); 913 p_new = get_preference(pg);
893 feedback = (p_new / pg->pref_bw_old) * (bw_acc_in + bw_acc_out) / 914 feedback = (p_new / pg->pref_bw_old) * (bw_acc_in + bw_acc_out) /
894 (2 *GNUNET_TIME_absolute_get_duration(pg->feedback_last).rel_value_us); 915 (2 * GNUNET_TIME_absolute_get_duration(pg->feedback_last).rel_value_us);
895 916
896 break; 917 break;
918
897 case GNUNET_ATS_PREFERENCE_LATENCY: 919 case GNUNET_ATS_PREFERENCE_LATENCY:
898 dur = GNUNET_TIME_absolute_get_duration(pg->feedback_last_delay_update); 920 dur = GNUNET_TIME_absolute_get_duration(pg->feedback_last_delay_update);
899 delay_acc_in =dur.rel_value_us *pg->last_delay_value + pg->feedback_delay_acc; 921 delay_acc_in = dur.rel_value_us * pg->last_delay_value + pg->feedback_delay_acc;
900 pg->feedback_delay_acc = 0; 922 pg->feedback_delay_acc = 0;
901 923
902 p_new = get_preference (pg); 924 p_new = get_preference(pg);
903 feedback = (p_new / pg->pref_latency_old) * (delay_acc_in) / 925 feedback = (p_new / pg->pref_latency_old) * (delay_acc_in) /
904 (GNUNET_TIME_absolute_get_duration(pg->feedback_last).rel_value_us); 926 (GNUNET_TIME_absolute_get_duration(pg->feedback_last).rel_value_us);
905 927
906 break; 928 break;
929
907 default: 930 default:
908 GNUNET_break (0); 931 GNUNET_break(0);
909 feedback = 0.0; 932 feedback = 0.0;
910 break; 933 break;
911 } 934 }
912 GNUNET_log(GNUNET_ERROR_TYPE_INFO, 935 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
913 "Giving feedback for peer [%u] for client %p pref %s of %.3f\n", 936 "Giving feedback for peer [%u] for client %p pref %s of %.3f\n",
914 pg->peer, NULL + (pg->client_id), 937 pg->peer, NULL + (pg->client_id),
915 GNUNET_ATS_print_preference_type (pg->kind), 938 GNUNET_ATS_print_preference_type(pg->kind),
916 feedback); 939 feedback);
917 940
918 sh->sf->s_feedback (sh->sf->cls, NULL + (pg->client_id), &p->peer_id, 941 sh->sf->s_feedback(sh->sf->cls, NULL + (pg->client_id), &p->peer_id,
919 pg->feedback_frequency, pg->kind, feedback); 942 pg->feedback_frequency, pg->kind, feedback);
920 pg->feedback_last = GNUNET_TIME_absolute_get(); 943 pg->feedback_last = GNUNET_TIME_absolute_get();
921 944
922 945
@@ -928,105 +951,111 @@ set_feedback_task (void *cls)
928 pg->feedback_last_delay_update = GNUNET_TIME_absolute_get(); 951 pg->feedback_last_delay_update = GNUNET_TIME_absolute_get();
929 952
930 953
931 pg->feedback_task = GNUNET_SCHEDULER_add_delayed (pg->feedback_frequency, 954 pg->feedback_task = GNUNET_SCHEDULER_add_delayed(pg->feedback_frequency,
932 &set_feedback_task, pg); 955 &set_feedback_task, pg);
933} 956}
934 957
935 958
936static void 959static void
937set_pref_task (void *cls) 960set_pref_task(void *cls)
938{ 961{
939 struct PreferenceGenerator *pg = cls; 962 struct PreferenceGenerator *pg = cls;
940 struct TestPeer *p; 963 struct TestPeer *p;
941 double pref_value; 964 double pref_value;
965
942 pg->set_task = NULL; 966 pg->set_task = NULL;
943 967
944 if (NULL == (p = find_peer_by_id (pg->peer))) 968 if (NULL == (p = find_peer_by_id(pg->peer)))
945 { 969 {
946 GNUNET_break (0); 970 GNUNET_break(0);
947 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 971 GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
948 "Setting preference for unknown peer %u\n", pg->peer); 972 "Setting preference for unknown peer %u\n", pg->peer);
949 return; 973 return;
950 } 974 }
951 975
952 pref_value = get_preference (pg); 976 pref_value = get_preference(pg);
953 switch (pg->kind) { 977 switch (pg->kind)
978 {
954 case GNUNET_ATS_PREFERENCE_BANDWIDTH: 979 case GNUNET_ATS_PREFERENCE_BANDWIDTH:
955 pg->pref_bw_old = pref_value; 980 pg->pref_bw_old = pref_value;
956 break; 981 break;
982
957 case GNUNET_ATS_PREFERENCE_LATENCY: 983 case GNUNET_ATS_PREFERENCE_LATENCY:
958 pg->pref_latency_old = pref_value; 984 pg->pref_latency_old = pref_value;
959 break; 985 break;
986
960 default: 987 default:
961 break; 988 break;
962 } 989 }
963 990
964 p->pref_abs[pg->kind] = pref_value; 991 p->pref_abs[pg->kind] = pref_value;
965 992
966 GNUNET_log(GNUNET_ERROR_TYPE_INFO, 993 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
967 "Setting preference for peer [%u] for client %p pref %s to %f\n", 994 "Setting preference for peer [%u] for client %p pref %s to %f\n",
968 pg->peer, NULL + (pg->client_id), 995 pg->peer, NULL + (pg->client_id),
969 GNUNET_ATS_print_preference_type (pg->kind), pref_value); 996 GNUNET_ATS_print_preference_type(pg->kind), pref_value);
970 997
971 if (GNUNET_YES == opt_disable_normalization) 998 if (GNUNET_YES == opt_disable_normalization)
972 { 999 {
973 p->pref_abs[pg->kind] = pref_value; 1000 p->pref_abs[pg->kind] = pref_value;
974 p->pref_norm[pg->kind] = pref_value; 1001 p->pref_norm[pg->kind] = pref_value;
975 sh->sf->s_pref (sh->sf->cls, &p->peer_id, pg->kind, pref_value); 1002 sh->sf->s_pref(sh->sf->cls, &p->peer_id, pg->kind, pref_value);
976 } 1003 }
977 else 1004 else
978 update_preference (NULL + (pg->client_id), 1005 update_preference(NULL + (pg->client_id),
979 &p->peer_id, 1006 &p->peer_id,
980 pg->kind, 1007 pg->kind,
981 pref_value); 1008 pref_value);
982 1009
983 pg->set_task = GNUNET_SCHEDULER_add_delayed (pg->frequency, 1010 pg->set_task = GNUNET_SCHEDULER_add_delayed(pg->frequency,
984 &set_pref_task, 1011 &set_pref_task,
985 pg); 1012 pg);
986} 1013}
987 1014
988 1015
989static struct PreferenceGenerator * 1016static struct PreferenceGenerator *
990find_pref_gen (unsigned int peer, enum GNUNET_ATS_PreferenceKind kind) 1017find_pref_gen(unsigned int peer, enum GNUNET_ATS_PreferenceKind kind)
991{ 1018{
992 struct PreferenceGenerator *cur; 1019 struct PreferenceGenerator *cur;
1020
993 for (cur = pref_gen_head; NULL != cur; cur = cur->next) 1021 for (cur = pref_gen_head; NULL != cur; cur = cur->next)
994 if (cur->peer == peer) 1022 if (cur->peer == peer)
995 { 1023 {
996 if ((cur->kind == kind) || (GNUNET_ATS_PREFERENCE_END == kind)) 1024 if ((cur->kind == kind) || (GNUNET_ATS_PREFERENCE_END == kind))
997 return cur; 1025 return cur;
998 } 1026 }
999 return NULL; 1027 return NULL;
1000} 1028}
1001 1029
1002void 1030void
1003GNUNET_ATS_solver_generate_preferences_stop (struct PreferenceGenerator *pg) 1031GNUNET_ATS_solver_generate_preferences_stop(struct PreferenceGenerator *pg)
1004{ 1032{
1005 GNUNET_CONTAINER_DLL_remove (pref_gen_head, pref_gen_tail, pg); 1033 GNUNET_CONTAINER_DLL_remove(pref_gen_head, pref_gen_tail, pg);
1006 1034
1007 if (NULL != pg->feedback_task) 1035 if (NULL != pg->feedback_task)
1008 { 1036 {
1009 GNUNET_SCHEDULER_cancel (pg->feedback_task); 1037 GNUNET_SCHEDULER_cancel(pg->feedback_task);
1010 pg->feedback_task = NULL; 1038 pg->feedback_task = NULL;
1011 } 1039 }
1012 1040
1013 if (NULL != pg->set_task) 1041 if (NULL != pg->set_task)
1014 { 1042 {
1015 GNUNET_SCHEDULER_cancel (pg->set_task); 1043 GNUNET_SCHEDULER_cancel(pg->set_task);
1016 pg->set_task = NULL; 1044 pg->set_task = NULL;
1017 } 1045 }
1018 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 1046 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
1019 "Removing old up preference generator peer [%u] `%s'\n", 1047 "Removing old up preference generator peer [%u] `%s'\n",
1020 pg->peer, GNUNET_ATS_print_preference_type(pg->kind)); 1048 pg->peer, GNUNET_ATS_print_preference_type(pg->kind));
1021 1049
1022 GNUNET_free (pg); 1050 GNUNET_free(pg);
1023} 1051}
1024 1052
1025 1053
1026static struct TestAddress* 1054static struct TestAddress*
1027find_active_address (struct TestPeer *p) 1055find_active_address(struct TestPeer *p)
1028{ 1056{
1029 struct TestAddress *cur; 1057 struct TestAddress *cur;
1058
1030 for (cur = p->addr_head; NULL != cur; cur = cur->next) 1059 for (cur = p->addr_head; NULL != cur; cur = cur->next)
1031 if (GNUNET_YES == cur->ats_addr->active) 1060 if (GNUNET_YES == cur->ats_addr->active)
1032 return cur; 1061 return cur;
@@ -1051,30 +1080,30 @@ find_active_address (struct TestPeer *p)
1051 * @return the preference generator 1080 * @return the preference generator
1052 */ 1081 */
1053struct PreferenceGenerator * 1082struct PreferenceGenerator *
1054GNUNET_ATS_solver_generate_preferences_start (unsigned int peer, 1083GNUNET_ATS_solver_generate_preferences_start(unsigned int peer,
1055 unsigned int address_id, 1084 unsigned int address_id,
1056 unsigned int client_id, 1085 unsigned int client_id,
1057 enum GeneratorType type, 1086 enum GeneratorType type,
1058 long int base_value, 1087 long int base_value,
1059 long int value_rate, 1088 long int value_rate,
1060 struct GNUNET_TIME_Relative period, 1089 struct GNUNET_TIME_Relative period,
1061 struct GNUNET_TIME_Relative frequency, 1090 struct GNUNET_TIME_Relative frequency,
1062 enum GNUNET_ATS_PreferenceKind kind, 1091 enum GNUNET_ATS_PreferenceKind kind,
1063 struct GNUNET_TIME_Relative feedback_frequency) 1092 struct GNUNET_TIME_Relative feedback_frequency)
1064{ 1093{
1065 struct PreferenceGenerator *pg; 1094 struct PreferenceGenerator *pg;
1066 struct TestPeer *p; 1095 struct TestPeer *p;
1067 1096
1068 if (NULL == (p = find_peer_by_id (peer))) 1097 if (NULL == (p = find_peer_by_id(peer)))
1069 { 1098 {
1070 GNUNET_break (0); 1099 GNUNET_break(0);
1071 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 1100 GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
1072 "Starting preference for unknown peer %u\n", peer); 1101 "Starting preference for unknown peer %u\n", peer);
1073 return NULL; 1102 return NULL;
1074 } 1103 }
1075 1104
1076 pg = GNUNET_new (struct PreferenceGenerator); 1105 pg = GNUNET_new(struct PreferenceGenerator);
1077 GNUNET_CONTAINER_DLL_insert (pref_gen_head, pref_gen_tail, pg); 1106 GNUNET_CONTAINER_DLL_insert(pref_gen_head, pref_gen_tail, pg);
1078 pg->type = type; 1107 pg->type = type;
1079 pg->peer = peer; 1108 pg->peer = peer;
1080 pg->client_id = client_id; 1109 pg->client_id = client_id;
@@ -1086,54 +1115,59 @@ GNUNET_ATS_solver_generate_preferences_start (unsigned int peer,
1086 pg->time_start = GNUNET_TIME_absolute_get(); 1115 pg->time_start = GNUNET_TIME_absolute_get();
1087 pg->feedback_frequency = feedback_frequency; 1116 pg->feedback_frequency = feedback_frequency;
1088 1117
1089 switch (type) { 1118 switch (type)
1119 {
1090 case GNUNET_ATS_TEST_TG_CONSTANT: 1120 case GNUNET_ATS_TEST_TG_CONSTANT:
1091 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 1121 GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
1092 "Setting up %s preference generator peer [%u] `%s' max %u Bips\n", 1122 "Setting up %s preference generator peer [%u] `%s' max %u Bips\n",
1093 print_generator_type (type), pg->peer, 1123 print_generator_type(type), pg->peer,
1094 GNUNET_ATS_print_preference_type(kind), 1124 GNUNET_ATS_print_preference_type(kind),
1095 base_value); 1125 base_value);
1096 break; 1126 break;
1127
1097 case GNUNET_ATS_TEST_TG_LINEAR: 1128 case GNUNET_ATS_TEST_TG_LINEAR:
1098 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 1129 GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
1099 "Setting up %s preference generator peer [%u] `%s' min %u Bips max %u Bips\n", 1130 "Setting up %s preference generator peer [%u] `%s' min %u Bips max %u Bips\n",
1100 print_generator_type (type), pg->peer, GNUNET_ATS_print_preference_type(kind), 1131 print_generator_type(type), pg->peer, GNUNET_ATS_print_preference_type(kind),
1101 base_value, value_rate); 1132 base_value, value_rate);
1102 break; 1133 break;
1134
1103 case GNUNET_ATS_TEST_TG_SINUS: 1135 case GNUNET_ATS_TEST_TG_SINUS:
1104 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 1136 GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
1105 "Setting up %s preference generator peer [%u] `%s' baserate %u Bips, amplitude %u Bps\n", 1137 "Setting up %s preference generator peer [%u] `%s' baserate %u Bips, amplitude %u Bps\n",
1106 print_generator_type (type), pg->peer, GNUNET_ATS_print_preference_type(kind), 1138 print_generator_type(type), pg->peer, GNUNET_ATS_print_preference_type(kind),
1107 base_value, value_rate); 1139 base_value, value_rate);
1108 break; 1140 break;
1141
1109 case GNUNET_ATS_TEST_TG_RANDOM: 1142 case GNUNET_ATS_TEST_TG_RANDOM:
1110 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 1143 GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
1111 "Setting up %s preference generator peer [%u] `%s' min %u Bips max %u Bps\n", 1144 "Setting up %s preference generator peer [%u] `%s' min %u Bips max %u Bps\n",
1112 print_generator_type (type), pg->peer, GNUNET_ATS_print_preference_type(kind), 1145 print_generator_type(type), pg->peer, GNUNET_ATS_print_preference_type(kind),
1113 base_value, value_rate); 1146 base_value, value_rate);
1114 break; 1147 break;
1148
1115 default: 1149 default:
1116 break; 1150 break;
1117 } 1151 }
1118 1152
1119 pg->set_task = GNUNET_SCHEDULER_add_now (&set_pref_task, pg); 1153 pg->set_task = GNUNET_SCHEDULER_add_now(&set_pref_task, pg);
1120 if (GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us != feedback_frequency.rel_value_us) 1154 if (GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us != feedback_frequency.rel_value_us)
1121 { 1155 {
1122 struct TestAddress * addr = find_active_address(p); 1156 struct TestAddress * addr = find_active_address(p);
1123 1157
1124 pg->last_assigned_bw_in = p->assigned_bw_in; 1158 pg->last_assigned_bw_in = p->assigned_bw_in;
1125 pg->last_assigned_bw_out = p->assigned_bw_out; 1159 pg->last_assigned_bw_out = p->assigned_bw_out;
1126 pg->feedback_bw_in_acc = 0; 1160 pg->feedback_bw_in_acc = 0;
1127 pg->feedback_bw_out_acc = 0; 1161 pg->feedback_bw_out_acc = 0;
1128 pg->last_delay_value = addr->prop_norm[GNUNET_ATS_QUALITY_NET_DELAY]; 1162 pg->last_delay_value = addr->prop_norm[GNUNET_ATS_QUALITY_NET_DELAY];
1129 pg->feedback_delay_acc = 0; 1163 pg->feedback_delay_acc = 0;
1130 1164
1131 pg->feedback_last_bw_update = GNUNET_TIME_absolute_get(); 1165 pg->feedback_last_bw_update = GNUNET_TIME_absolute_get();
1132 pg->feedback_last_delay_update = GNUNET_TIME_absolute_get(); 1166 pg->feedback_last_delay_update = GNUNET_TIME_absolute_get();
1133 pg->feedback_last = GNUNET_TIME_absolute_get(); 1167 pg->feedback_last = GNUNET_TIME_absolute_get();
1134 pg->feedback_task = GNUNET_SCHEDULER_add_delayed (feedback_frequency, 1168 pg->feedback_task = GNUNET_SCHEDULER_add_delayed(feedback_frequency,
1135 &set_feedback_task, pg); 1169 &set_feedback_task, pg);
1136 } 1170 }
1137 1171
1138 return pg; 1172 return pg;
1139} 1173}
@@ -1144,16 +1178,17 @@ GNUNET_ATS_solver_generate_preferences_start (unsigned int peer,
1144 * Stop all preferences generators 1178 * Stop all preferences generators
1145 */ 1179 */
1146void 1180void
1147GNUNET_ATS_solver_generate_preferences_stop_all () 1181GNUNET_ATS_solver_generate_preferences_stop_all()
1148{ 1182{
1149 struct PreferenceGenerator *cur; 1183 struct PreferenceGenerator *cur;
1150 struct PreferenceGenerator *next; 1184 struct PreferenceGenerator *next;
1185
1151 next = pref_gen_head; 1186 next = pref_gen_head;
1152 for (cur = next; NULL != cur; cur = next) 1187 for (cur = next; NULL != cur; cur = next)
1153 { 1188 {
1154 next = cur->next; 1189 next = cur->next;
1155 GNUNET_ATS_solver_generate_preferences_stop(cur); 1190 GNUNET_ATS_solver_generate_preferences_stop(cur);
1156 } 1191 }
1157} 1192}
1158 1193
1159 1194
@@ -1162,37 +1197,47 @@ GNUNET_ATS_solver_generate_preferences_stop_all ()
1162 * Experiments 1197 * Experiments
1163 */ 1198 */
1164static const char * 1199static const char *
1165print_op (enum OperationType op) 1200print_op(enum OperationType op)
1166{ 1201{
1167 switch (op) { 1202 switch (op)
1203 {
1168 case SOLVER_OP_ADD_ADDRESS: 1204 case SOLVER_OP_ADD_ADDRESS:
1169 return "ADD_ADDRESS"; 1205 return "ADD_ADDRESS";
1206
1170 case SOLVER_OP_DEL_ADDRESS: 1207 case SOLVER_OP_DEL_ADDRESS:
1171 return "DEL_ADDRESS"; 1208 return "DEL_ADDRESS";
1209
1172 case SOLVER_OP_START_SET_PREFERENCE: 1210 case SOLVER_OP_START_SET_PREFERENCE:
1173 return "START_SET_PREFERENCE"; 1211 return "START_SET_PREFERENCE";
1212
1174 case SOLVER_OP_STOP_SET_PREFERENCE: 1213 case SOLVER_OP_STOP_SET_PREFERENCE:
1175 return "STOP_STOP_PREFERENCE"; 1214 return "STOP_STOP_PREFERENCE";
1215
1176 case SOLVER_OP_START_SET_PROPERTY: 1216 case SOLVER_OP_START_SET_PROPERTY:
1177 return "START_SET_PROPERTY"; 1217 return "START_SET_PROPERTY";
1218
1178 case SOLVER_OP_STOP_SET_PROPERTY: 1219 case SOLVER_OP_STOP_SET_PROPERTY:
1179 return "STOP_SET_PROPERTY"; 1220 return "STOP_SET_PROPERTY";
1221
1180 case SOLVER_OP_START_REQUEST: 1222 case SOLVER_OP_START_REQUEST:
1181 return "START_REQUEST"; 1223 return "START_REQUEST";
1224
1182 case SOLVER_OP_STOP_REQUEST: 1225 case SOLVER_OP_STOP_REQUEST:
1183 return "STOP_REQUEST"; 1226 return "STOP_REQUEST";
1227
1184 default: 1228 default:
1185 break; 1229 break;
1186 } 1230 }
1187 return ""; 1231 return "";
1188} 1232}
1189 1233
1190 1234
1191static struct Experiment * 1235static struct Experiment *
1192create_experiment () 1236create_experiment()
1193{ 1237{
1194 struct Experiment *e; 1238 struct Experiment *e;
1195 e = GNUNET_new (struct Experiment); 1239
1240 e = GNUNET_new(struct Experiment);
1196 e->name = NULL; 1241 e->name = NULL;
1197 e->start = NULL; 1242 e->start = NULL;
1198 e->total_duration = GNUNET_TIME_UNIT_ZERO; 1243 e->total_duration = GNUNET_TIME_UNIT_ZERO;
@@ -1201,7 +1246,7 @@ create_experiment ()
1201 1246
1202 1247
1203static void 1248static void
1204free_experiment (struct Experiment *e) 1249free_experiment(struct Experiment *e)
1205{ 1250{
1206 struct Episode *cur; 1251 struct Episode *cur;
1207 struct Episode *next; 1252 struct Episode *next;
@@ -1210,237 +1255,238 @@ free_experiment (struct Experiment *e)
1210 1255
1211 next = e->start; 1256 next = e->start;
1212 for (cur = next; NULL != cur; cur = next) 1257 for (cur = next; NULL != cur; cur = next)
1213 {
1214 next = cur->next;
1215
1216 next_o = cur->head;
1217 for (cur_o = next_o; NULL != cur_o; cur_o = next_o)
1218 { 1258 {
1219 next_o = cur_o->next; 1259 next = cur->next;
1220 GNUNET_free_non_null (cur_o->address); 1260
1221 GNUNET_free_non_null (cur_o->plugin); 1261 next_o = cur->head;
1222 GNUNET_free (cur_o); 1262 for (cur_o = next_o; NULL != cur_o; cur_o = next_o)
1263 {
1264 next_o = cur_o->next;
1265 GNUNET_free_non_null(cur_o->address);
1266 GNUNET_free_non_null(cur_o->plugin);
1267 GNUNET_free(cur_o);
1268 }
1269 GNUNET_free(cur);
1223 } 1270 }
1224 GNUNET_free (cur);
1225 }
1226 1271
1227 GNUNET_free_non_null (e->name); 1272 GNUNET_free_non_null(e->name);
1228 GNUNET_free_non_null (e->log_prefix); 1273 GNUNET_free_non_null(e->log_prefix);
1229 GNUNET_free_non_null (e->log_output_dir); 1274 GNUNET_free_non_null(e->log_output_dir);
1230 GNUNET_free_non_null (e->cfg_file); 1275 GNUNET_free_non_null(e->cfg_file);
1231 GNUNET_free (e); 1276 GNUNET_free(e);
1232} 1277}
1233 1278
1234 1279
1235static int 1280static int
1236load_op_add_address (struct GNUNET_ATS_TEST_Operation *o, 1281load_op_add_address(struct GNUNET_ATS_TEST_Operation *o,
1237 struct Episode *e, 1282 struct Episode *e,
1238 int op_counter, 1283 int op_counter,
1239 char *sec_name, 1284 char *sec_name,
1240 const struct GNUNET_CONFIGURATION_Handle *cfg) 1285 const struct GNUNET_CONFIGURATION_Handle *cfg)
1241{ 1286{
1242 char *op_name; 1287 char *op_name;
1243 char *op_network; 1288 char *op_network;
1244 1289
1245 /* peer pid */ 1290 /* peer pid */
1246 GNUNET_asprintf(&op_name, "op-%u-peer-id", op_counter); 1291 GNUNET_asprintf(&op_name, "op-%u-peer-id", op_counter);
1247 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (cfg, 1292 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number(cfg,
1248 sec_name, op_name, &o->peer_id)) 1293 sec_name, op_name, &o->peer_id))
1249 { 1294 {
1250 fprintf (stderr, "Missing peer-id in operation %u `%s' in episode `%s'\n", 1295 fprintf(stderr, "Missing peer-id in operation %u `%s' in episode `%s'\n",
1251 op_counter, "ADD_ADDRESS", op_name); 1296 op_counter, "ADD_ADDRESS", op_name);
1252 GNUNET_free (op_name); 1297 GNUNET_free(op_name);
1253 return GNUNET_SYSERR; 1298 return GNUNET_SYSERR;
1254 } 1299 }
1255 GNUNET_free (op_name); 1300 GNUNET_free(op_name);
1256 1301
1257 /* address pid */ 1302 /* address pid */
1258 GNUNET_asprintf(&op_name, "op-%u-address-id", op_counter); 1303 GNUNET_asprintf(&op_name, "op-%u-address-id", op_counter);
1259 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (cfg, 1304 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number(cfg,
1260 sec_name, op_name, &o->address_id)) 1305 sec_name, op_name, &o->address_id))
1261 { 1306 {
1262 fprintf (stderr, "Missing address-id in operation %u `%s' in episode `%s'\n", 1307 fprintf(stderr, "Missing address-id in operation %u `%s' in episode `%s'\n",
1263 op_counter, "ADD_ADDRESS", op_name); 1308 op_counter, "ADD_ADDRESS", op_name);
1264 GNUNET_free (op_name); 1309 GNUNET_free(op_name);
1265 return GNUNET_SYSERR; 1310 return GNUNET_SYSERR;
1266 } 1311 }
1267 GNUNET_free (op_name); 1312 GNUNET_free(op_name);
1268 1313
1269 /* plugin */ 1314 /* plugin */
1270 GNUNET_asprintf(&op_name, "op-%u-plugin", op_counter); 1315 GNUNET_asprintf(&op_name, "op-%u-plugin", op_counter);
1271 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string (cfg, 1316 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string(cfg,
1272 sec_name, op_name, &o->plugin)) 1317 sec_name, op_name, &o->plugin))
1273 { 1318 {
1274 fprintf (stderr, "Missing plugin in operation %u `%s' in episode `%s'\n", 1319 fprintf(stderr, "Missing plugin in operation %u `%s' in episode `%s'\n",
1275 op_counter, "ADD_ADDRESS", op_name); 1320 op_counter, "ADD_ADDRESS", op_name);
1276 GNUNET_free (op_name); 1321 GNUNET_free(op_name);
1277 return GNUNET_SYSERR; 1322 return GNUNET_SYSERR;
1278 } 1323 }
1279 GNUNET_free (op_name); 1324 GNUNET_free(op_name);
1280 1325
1281 /* address */ 1326 /* address */
1282 GNUNET_asprintf(&op_name, "op-%u-address", op_counter); 1327 GNUNET_asprintf(&op_name, "op-%u-address", op_counter);
1283 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string (cfg, 1328 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string(cfg,
1284 sec_name, op_name, &o->address)) 1329 sec_name, op_name, &o->address))
1285 { 1330 {
1286 fprintf (stderr, "Missing address in operation %u `%s' in episode `%s'\n", 1331 fprintf(stderr, "Missing address in operation %u `%s' in episode `%s'\n",
1287 op_counter, "ADD_ADDRESS", op_name); 1332 op_counter, "ADD_ADDRESS", op_name);
1288 GNUNET_free (op_name); 1333 GNUNET_free(op_name);
1289 return GNUNET_SYSERR; 1334 return GNUNET_SYSERR;
1290 } 1335 }
1291 GNUNET_free (op_name); 1336 GNUNET_free(op_name);
1292 1337
1293 /* session */ 1338 /* session */
1294 GNUNET_asprintf(&op_name, "op-%u-address-session", op_counter); 1339 GNUNET_asprintf(&op_name, "op-%u-address-session", op_counter);
1295 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (cfg, 1340 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number(cfg,
1296 sec_name, op_name, &o->address_session)) 1341 sec_name, op_name, &o->address_session))
1297 { 1342 {
1298 fprintf (stderr, "Missing address-session in operation %u `%s' in episode `%s'\n", 1343 fprintf(stderr, "Missing address-session in operation %u `%s' in episode `%s'\n",
1299 op_counter, "ADD_ADDRESS", op_name); 1344 op_counter, "ADD_ADDRESS", op_name);
1300 GNUNET_free (op_name); 1345 GNUNET_free(op_name);
1301 return GNUNET_SYSERR; 1346 return GNUNET_SYSERR;
1302 } 1347 }
1303 GNUNET_free (op_name); 1348 GNUNET_free(op_name);
1304 1349
1305 /* network */ 1350 /* network */
1306 GNUNET_asprintf(&op_name, "op-%u-address-network", op_counter); 1351 GNUNET_asprintf(&op_name, "op-%u-address-network", op_counter);
1307 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string (cfg, 1352 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string(cfg,
1308 sec_name, op_name, &op_network)) 1353 sec_name, op_name, &op_network))
1309 {
1310 fprintf (stderr, "Missing address-network in operation %u `%s' in episode `%s'\n",
1311 op_counter, "ADD_ADDRESS", op_name);
1312 GNUNET_free (op_name);
1313 return GNUNET_SYSERR;
1314 }
1315 else
1316 {
1317 GNUNET_STRINGS_utf8_toupper (op_network,op_network);
1318 if (0 == strcmp(op_network, "UNSPECIFIED"))
1319 {
1320 o->address_network = GNUNET_NT_UNSPECIFIED;
1321 }
1322 else if (0 == strcmp(op_network, "LOOPBACK"))
1323 { 1354 {
1324 o->address_network = GNUNET_NT_LOOPBACK; 1355 fprintf(stderr, "Missing address-network in operation %u `%s' in episode `%s'\n",
1325 } 1356 op_counter, "ADD_ADDRESS", op_name);
1326 else if (0 == strcmp(op_network, "LAN")) 1357 GNUNET_free(op_name);
1327 { 1358 return GNUNET_SYSERR;
1328 o->address_network = GNUNET_NT_LAN;
1329 }
1330 else if (0 == strcmp(op_network, "WAN"))
1331 {
1332 o->address_network = GNUNET_NT_WAN;
1333 }
1334 else if (0 == strcmp(op_network, "WLAN"))
1335 {
1336 o->address_network = GNUNET_NT_WLAN;
1337 }
1338 else if (0 == strcmp(op_network, "BT"))
1339 {
1340 o->address_network = GNUNET_NT_BT;
1341 } 1359 }
1342 else 1360 else
1343 { 1361 {
1344 fprintf (stderr, "Invalid address-network in operation %u `%s' in episode `%s': `%s'\n", 1362 GNUNET_STRINGS_utf8_toupper(op_network, op_network);
1345 op_counter, "ADD_ADDRESS", op_name, op_network); 1363 if (0 == strcmp(op_network, "UNSPECIFIED"))
1346 GNUNET_free (op_network); 1364 {
1347 GNUNET_free (op_name); 1365 o->address_network = GNUNET_NT_UNSPECIFIED;
1348 return GNUNET_SYSERR; 1366 }
1367 else if (0 == strcmp(op_network, "LOOPBACK"))
1368 {
1369 o->address_network = GNUNET_NT_LOOPBACK;
1370 }
1371 else if (0 == strcmp(op_network, "LAN"))
1372 {
1373 o->address_network = GNUNET_NT_LAN;
1374 }
1375 else if (0 == strcmp(op_network, "WAN"))
1376 {
1377 o->address_network = GNUNET_NT_WAN;
1378 }
1379 else if (0 == strcmp(op_network, "WLAN"))
1380 {
1381 o->address_network = GNUNET_NT_WLAN;
1382 }
1383 else if (0 == strcmp(op_network, "BT"))
1384 {
1385 o->address_network = GNUNET_NT_BT;
1386 }
1387 else
1388 {
1389 fprintf(stderr, "Invalid address-network in operation %u `%s' in episode `%s': `%s'\n",
1390 op_counter, "ADD_ADDRESS", op_name, op_network);
1391 GNUNET_free(op_network);
1392 GNUNET_free(op_name);
1393 return GNUNET_SYSERR;
1394 }
1349 } 1395 }
1350 } 1396 GNUNET_free(op_network);
1351 GNUNET_free (op_network); 1397 GNUNET_free(op_name);
1352 GNUNET_free (op_name);
1353 1398
1354 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 1399 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
1355 "Found operation %s: [%llu:%llu] address `%s' plugin `%s' \n", 1400 "Found operation %s: [%llu:%llu] address `%s' plugin `%s' \n",
1356 "ADD_ADDRESS", o->peer_id, o->address_id, o->address, o->plugin); 1401 "ADD_ADDRESS", o->peer_id, o->address_id, o->address, o->plugin);
1357 1402
1358 return GNUNET_OK; 1403 return GNUNET_OK;
1359} 1404}
1360 1405
1361 1406
1362static int 1407static int
1363load_op_del_address (struct GNUNET_ATS_TEST_Operation *o, 1408load_op_del_address(struct GNUNET_ATS_TEST_Operation *o,
1364 struct Episode *e, 1409 struct Episode *e,
1365 int op_counter, 1410 int op_counter,
1366 char *sec_name, 1411 char *sec_name,
1367 const struct GNUNET_CONFIGURATION_Handle *cfg) 1412 const struct GNUNET_CONFIGURATION_Handle *cfg)
1368{ 1413{
1369 char *op_name; 1414 char *op_name;
1415
1370 //char *op_network; 1416 //char *op_network;
1371 1417
1372 /* peer pid */ 1418 /* peer pid */
1373 GNUNET_asprintf(&op_name, "op-%u-peer-id", op_counter); 1419 GNUNET_asprintf(&op_name, "op-%u-peer-id", op_counter);
1374 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (cfg, 1420 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number(cfg,
1375 sec_name, op_name, &o->peer_id)) 1421 sec_name, op_name, &o->peer_id))
1376 { 1422 {
1377 fprintf (stderr, "Missing peer-id in operation %u `%s' in episode `%s'\n", 1423 fprintf(stderr, "Missing peer-id in operation %u `%s' in episode `%s'\n",
1378 op_counter, "DEL_ADDRESS", op_name); 1424 op_counter, "DEL_ADDRESS", op_name);
1379 GNUNET_free (op_name); 1425 GNUNET_free(op_name);
1380 return GNUNET_SYSERR; 1426 return GNUNET_SYSERR;
1381 } 1427 }
1382 GNUNET_free (op_name); 1428 GNUNET_free(op_name);
1383 1429
1384 /* address pid */ 1430 /* address pid */
1385 GNUNET_asprintf(&op_name, "op-%u-address-id", op_counter); 1431 GNUNET_asprintf(&op_name, "op-%u-address-id", op_counter);
1386 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (cfg, 1432 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number(cfg,
1387 sec_name, op_name, &o->address_id)) 1433 sec_name, op_name, &o->address_id))
1388 { 1434 {
1389 fprintf (stderr, "Missing address-id in operation %u `%s' in episode `%s'\n", 1435 fprintf(stderr, "Missing address-id in operation %u `%s' in episode `%s'\n",
1390 op_counter, "DEL_ADDRESS", op_name); 1436 op_counter, "DEL_ADDRESS", op_name);
1391 GNUNET_free (op_name); 1437 GNUNET_free(op_name);
1392 return GNUNET_SYSERR; 1438 return GNUNET_SYSERR;
1393 } 1439 }
1394 GNUNET_free (op_name); 1440 GNUNET_free(op_name);
1395 1441
1396#if 0 1442#if 0
1397 /* plugin */ 1443 /* plugin */
1398 GNUNET_asprintf(&op_name, "op-%u-plugin", op_counter); 1444 GNUNET_asprintf(&op_name, "op-%u-plugin", op_counter);
1399 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string (cfg, 1445 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string(cfg,
1400 sec_name, op_name, &o->plugin)) 1446 sec_name, op_name, &o->plugin))
1401 { 1447 {
1402 fprintf (stderr, "Missing plugin in operation %u `%s' in episode `%s'\n", 1448 fprintf(stderr, "Missing plugin in operation %u `%s' in episode `%s'\n",
1403 op_counter, "DEL_ADDRESS", op_name); 1449 op_counter, "DEL_ADDRESS", op_name);
1404 GNUNET_free (op_name); 1450 GNUNET_free(op_name);
1405 return GNUNET_SYSERR; 1451 return GNUNET_SYSERR;
1406 } 1452 }
1407 GNUNET_free (op_name); 1453 GNUNET_free(op_name);
1408 1454
1409 /* address */ 1455 /* address */
1410 GNUNET_asprintf(&op_name, "op-%u-address", op_counter); 1456 GNUNET_asprintf(&op_name, "op-%u-address", op_counter);
1411 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string (cfg, 1457 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string(cfg,
1412 sec_name, op_name, &o->address)) 1458 sec_name, op_name, &o->address))
1413 { 1459 {
1414 fprintf (stderr, "Missing address in operation %u `%s' in episode `%s'\n", 1460 fprintf(stderr, "Missing address in operation %u `%s' in episode `%s'\n",
1415 op_counter, "DEL_ADDRESS", op_name); 1461 op_counter, "DEL_ADDRESS", op_name);
1416 GNUNET_free (op_name); 1462 GNUNET_free(op_name);
1417 return GNUNET_SYSERR; 1463 return GNUNET_SYSERR;
1418 } 1464 }
1419 GNUNET_free (op_name); 1465 GNUNET_free(op_name);
1420 1466
1421 /* session */ 1467 /* session */
1422 GNUNET_asprintf(&op_name, "op-%u-address-session", op_counter); 1468 GNUNET_asprintf(&op_name, "op-%u-address-session", op_counter);
1423 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (cfg, 1469 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number(cfg,
1424 sec_name, op_name, &o->address_session)) 1470 sec_name, op_name, &o->address_session))
1425 { 1471 {
1426 fprintf (stderr, "Missing address-session in operation %u `%s' in episode `%s'\n", 1472 fprintf(stderr, "Missing address-session in operation %u `%s' in episode `%s'\n",
1427 op_counter, "DEL_ADDRESS", op_name); 1473 op_counter, "DEL_ADDRESS", op_name);
1428 GNUNET_free (op_name); 1474 GNUNET_free(op_name);
1429 return GNUNET_SYSERR; 1475 return GNUNET_SYSERR;
1430 } 1476 }
1431 GNUNET_free (op_name); 1477 GNUNET_free(op_name);
1432#endif 1478#endif
1433 1479
1434 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 1480 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
1435 "Found operation %s: [%llu:%llu] address `%s' plugin `%s' \n", 1481 "Found operation %s: [%llu:%llu] address `%s' plugin `%s' \n",
1436 "DEL_ADDRESS", o->peer_id, o->address_id, o->address, o->plugin); 1482 "DEL_ADDRESS", o->peer_id, o->address_id, o->address, o->plugin);
1437 1483
1438 return GNUNET_OK; 1484 return GNUNET_OK;
1439} 1485}
1440 1486
1441 1487
1442static enum GNUNET_ATS_Property 1488static enum GNUNET_ATS_Property
1443parse_preference_string (const char * str) 1489parse_preference_string(const char * str)
1444{ 1490{
1445 int c = 0; 1491 int c = 0;
1446 char *props[GNUNET_ATS_PreferenceCount] = GNUNET_ATS_PreferenceTypeString; 1492 char *props[GNUNET_ATS_PreferenceCount] = GNUNET_ATS_PreferenceTypeString;
@@ -1453,11 +1499,11 @@ parse_preference_string (const char * str)
1453 1499
1454 1500
1455static int 1501static int
1456load_op_start_set_preference (struct GNUNET_ATS_TEST_Operation *o, 1502load_op_start_set_preference(struct GNUNET_ATS_TEST_Operation *o,
1457 struct Episode *e, 1503 struct Episode *e,
1458 int op_counter, 1504 int op_counter,
1459 char *sec_name, 1505 char *sec_name,
1460 const struct GNUNET_CONFIGURATION_Handle *cfg) 1506 const struct GNUNET_CONFIGURATION_Handle *cfg)
1461{ 1507{
1462 char *op_name; 1508 char *op_name;
1463 char *type; 1509 char *type;
@@ -1465,235 +1511,235 @@ load_op_start_set_preference (struct GNUNET_ATS_TEST_Operation *o,
1465 1511
1466 /* peer pid */ 1512 /* peer pid */
1467 GNUNET_asprintf(&op_name, "op-%u-peer-id", op_counter); 1513 GNUNET_asprintf(&op_name, "op-%u-peer-id", op_counter);
1468 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (cfg, 1514 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number(cfg,
1469 sec_name, op_name, &o->peer_id)) 1515 sec_name, op_name, &o->peer_id))
1470 { 1516 {
1471 fprintf (stderr, "Missing peer-id in operation %u `%s' in episode `%s'\n", 1517 fprintf(stderr, "Missing peer-id in operation %u `%s' in episode `%s'\n",
1472 op_counter, "START_SET_PREFERENCE", op_name); 1518 op_counter, "START_SET_PREFERENCE", op_name);
1473 GNUNET_free (op_name); 1519 GNUNET_free(op_name);
1474 return GNUNET_SYSERR; 1520 return GNUNET_SYSERR;
1475 } 1521 }
1476 GNUNET_free (op_name); 1522 GNUNET_free(op_name);
1477 1523
1478 /* address pid */ 1524 /* address pid */
1479 GNUNET_asprintf(&op_name, "op-%u-client-id", op_counter); 1525 GNUNET_asprintf(&op_name, "op-%u-client-id", op_counter);
1480 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (cfg, 1526 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number(cfg,
1481 sec_name, op_name, &o->client_id)) 1527 sec_name, op_name, &o->client_id))
1482 { 1528 {
1483 fprintf (stderr, "Missing client-id in operation %u `%s' in episode `%s'\n", 1529 fprintf(stderr, "Missing client-id in operation %u `%s' in episode `%s'\n",
1484 op_counter, "START_SET_PREFERENCE", op_name); 1530 op_counter, "START_SET_PREFERENCE", op_name);
1485 GNUNET_free (op_name); 1531 GNUNET_free(op_name);
1486 return GNUNET_SYSERR; 1532 return GNUNET_SYSERR;
1487 } 1533 }
1488 GNUNET_free (op_name); 1534 GNUNET_free(op_name);
1489 1535
1490 /* generator */ 1536 /* generator */
1491 GNUNET_asprintf(&op_name, "op-%u-gen-type", op_counter); 1537 GNUNET_asprintf(&op_name, "op-%u-gen-type", op_counter);
1492 if ( (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string(cfg, 1538 if ((GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string(cfg,
1493 sec_name, op_name, &type)) ) 1539 sec_name, op_name, &type)))
1494 { 1540 {
1495 fprintf (stderr, "Missing type in operation %u `%s' in episode `%s'\n", 1541 fprintf(stderr, "Missing type in operation %u `%s' in episode `%s'\n",
1496 op_counter, "START_SET_PREFERENCE", op_name); 1542 op_counter, "START_SET_PREFERENCE", op_name);
1497 GNUNET_free (op_name); 1543 GNUNET_free(op_name);
1498 return GNUNET_SYSERR; 1544 return GNUNET_SYSERR;
1499 } 1545 }
1500 1546
1501 /* Load arguments for set_rate, start_send, set_preference */ 1547 /* Load arguments for set_rate, start_send, set_preference */
1502 if (0 == strcmp (type, "constant")) 1548 if (0 == strcmp(type, "constant"))
1503 { 1549 {
1504 o->gen_type = GNUNET_ATS_TEST_TG_CONSTANT; 1550 o->gen_type = GNUNET_ATS_TEST_TG_CONSTANT;
1505 } 1551 }
1506 else if (0 == strcmp (type, "linear")) 1552 else if (0 == strcmp(type, "linear"))
1507 { 1553 {
1508 o->gen_type = GNUNET_ATS_TEST_TG_LINEAR; 1554 o->gen_type = GNUNET_ATS_TEST_TG_LINEAR;
1509 } 1555 }
1510 else if (0 == strcmp (type, "sinus")) 1556 else if (0 == strcmp(type, "sinus"))
1511 { 1557 {
1512 o->gen_type = GNUNET_ATS_TEST_TG_SINUS; 1558 o->gen_type = GNUNET_ATS_TEST_TG_SINUS;
1513 } 1559 }
1514 else if (0 == strcmp (type, "random")) 1560 else if (0 == strcmp(type, "random"))
1515 { 1561 {
1516 o->gen_type = GNUNET_ATS_TEST_TG_RANDOM; 1562 o->gen_type = GNUNET_ATS_TEST_TG_RANDOM;
1517 } 1563 }
1518 else 1564 else
1519 { 1565 {
1520 fprintf (stderr, "Invalid generator type %u `%s' in episode %u\n", 1566 fprintf(stderr, "Invalid generator type %u `%s' in episode %u\n",
1521 op_counter, op_name, e->id); 1567 op_counter, op_name, e->id);
1522 GNUNET_free (type); 1568 GNUNET_free(type);
1523 GNUNET_free (op_name); 1569 GNUNET_free(op_name);
1524 return GNUNET_SYSERR; 1570 return GNUNET_SYSERR;
1525 } 1571 }
1526 GNUNET_free (type); 1572 GNUNET_free(type);
1527 GNUNET_free (op_name); 1573 GNUNET_free(op_name);
1528 1574
1529 1575
1530 /* Get base rate */ 1576 /* Get base rate */
1531 GNUNET_asprintf(&op_name, "op-%u-base-rate", op_counter); 1577 GNUNET_asprintf(&op_name, "op-%u-base-rate", op_counter);
1532 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (cfg, 1578 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number(cfg,
1533 sec_name, op_name, &o->base_rate)) 1579 sec_name, op_name, &o->base_rate))
1534 { 1580 {
1535 fprintf (stderr, "Missing base rate in operation %u `%s' in episode %u\n", 1581 fprintf(stderr, "Missing base rate in operation %u `%s' in episode %u\n",
1536 op_counter, op_name, e->id); 1582 op_counter, op_name, e->id);
1537 GNUNET_free (op_name); 1583 GNUNET_free(op_name);
1538 return GNUNET_SYSERR; 1584 return GNUNET_SYSERR;
1539 } 1585 }
1540 GNUNET_free (op_name); 1586 GNUNET_free(op_name);
1541 1587
1542 1588
1543 /* Get max rate */ 1589 /* Get max rate */
1544 GNUNET_asprintf(&op_name, "op-%u-max-rate", op_counter); 1590 GNUNET_asprintf(&op_name, "op-%u-max-rate", op_counter);
1545 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (cfg, 1591 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number(cfg,
1546 sec_name, op_name, &o->max_rate)) 1592 sec_name, op_name, &o->max_rate))
1547 {
1548 if ((GNUNET_ATS_TEST_TG_LINEAR == o->gen_type) ||
1549 (GNUNET_ATS_TEST_TG_RANDOM == o->gen_type) ||
1550 (GNUNET_ATS_TEST_TG_SINUS == o->gen_type))
1551 { 1593 {
1552 fprintf (stderr, "Missing max rate in operation %u `%s' in episode %u\n", 1594 if ((GNUNET_ATS_TEST_TG_LINEAR == o->gen_type) ||
1553 op_counter, op_name, e->id); 1595 (GNUNET_ATS_TEST_TG_RANDOM == o->gen_type) ||
1554 GNUNET_free (op_name); 1596 (GNUNET_ATS_TEST_TG_SINUS == o->gen_type))
1555 return GNUNET_SYSERR; 1597 {
1598 fprintf(stderr, "Missing max rate in operation %u `%s' in episode %u\n",
1599 op_counter, op_name, e->id);
1600 GNUNET_free(op_name);
1601 return GNUNET_SYSERR;
1602 }
1556 } 1603 }
1557 } 1604 GNUNET_free(op_name);
1558 GNUNET_free (op_name);
1559 1605
1560 /* Get period */ 1606 /* Get period */
1561 GNUNET_asprintf(&op_name, "op-%u-period", op_counter); 1607 GNUNET_asprintf(&op_name, "op-%u-period", op_counter);
1562 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_time (cfg, 1608 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_time(cfg,
1563 sec_name, op_name, &o->period)) 1609 sec_name, op_name, &o->period))
1564 { 1610 {
1565 o->period = e->duration; 1611 o->period = e->duration;
1566 } 1612 }
1567 GNUNET_free (op_name); 1613 GNUNET_free(op_name);
1568 1614
1569 /* Get frequency */ 1615 /* Get frequency */
1570 GNUNET_asprintf(&op_name, "op-%u-frequency", op_counter); 1616 GNUNET_asprintf(&op_name, "op-%u-frequency", op_counter);
1571 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_time (cfg, 1617 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_time(cfg,
1572 sec_name, op_name, &o->frequency)) 1618 sec_name, op_name, &o->frequency))
1573 { 1619 {
1574 fprintf (stderr, "Missing frequency in operation %u `%s' in episode %u\n", 1620 fprintf(stderr, "Missing frequency in operation %u `%s' in episode %u\n",
1575 op_counter, op_name, e->id); 1621 op_counter, op_name, e->id);
1576 GNUNET_free (op_name); 1622 GNUNET_free(op_name);
1577 return GNUNET_SYSERR; 1623 return GNUNET_SYSERR;
1578 } 1624 }
1579 GNUNET_free (op_name); 1625 GNUNET_free(op_name);
1580 1626
1581 /* Get preference */ 1627 /* Get preference */
1582 GNUNET_asprintf(&op_name, "op-%u-pref", op_counter); 1628 GNUNET_asprintf(&op_name, "op-%u-pref", op_counter);
1583 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string (cfg, 1629 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string(cfg,
1584 sec_name, op_name, &pref)) 1630 sec_name, op_name, &pref))
1585 { 1631 {
1586 fprintf (stderr, "Missing preference in operation %u `%s' in episode %u\n", 1632 fprintf(stderr, "Missing preference in operation %u `%s' in episode %u\n",
1587 op_counter, op_name, e->id); 1633 op_counter, op_name, e->id);
1588 GNUNET_free (op_name); 1634 GNUNET_free(op_name);
1589 return GNUNET_SYSERR; 1635 return GNUNET_SYSERR;
1590 } 1636 }
1591 1637
1592 if (0 == (o->pref_type = parse_preference_string(pref))) 1638 if (0 == (o->pref_type = parse_preference_string(pref)))
1593 { 1639 {
1594 fprintf (stderr, "Invalid preference in operation %u `%s' in episode %u\n", 1640 fprintf(stderr, "Invalid preference in operation %u `%s' in episode %u\n",
1595 op_counter, op_name, e->id); 1641 op_counter, op_name, e->id);
1596 GNUNET_free (op_name); 1642 GNUNET_free(op_name);
1597 GNUNET_free (pref); 1643 GNUNET_free(pref);
1598 return GNUNET_SYSERR; 1644 return GNUNET_SYSERR;
1599 } 1645 }
1600 GNUNET_free (pref); 1646 GNUNET_free(pref);
1601 GNUNET_free (op_name); 1647 GNUNET_free(op_name);
1602 1648
1603 /* Get feedback delay */ 1649 /* Get feedback delay */
1604 GNUNET_asprintf(&op_name, "op-%u-feedback_delay", op_counter); 1650 GNUNET_asprintf(&op_name, "op-%u-feedback_delay", op_counter);
1605 if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_time (cfg, 1651 if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_time(cfg,
1606 sec_name, op_name, &o->feedback_delay)) 1652 sec_name, op_name, &o->feedback_delay))
1607 { 1653 {
1608 fprintf (stderr, "Using feedback delay %llu in operation %u `%s' in episode %u\n", 1654 fprintf(stderr, "Using feedback delay %llu in operation %u `%s' in episode %u\n",
1609 (long long unsigned int) o->feedback_delay.rel_value_us, 1655 (long long unsigned int)o->feedback_delay.rel_value_us,
1610 op_counter, op_name, e->id); 1656 op_counter, op_name, e->id);
1611 } 1657 }
1612 else 1658 else
1613 o->feedback_delay = GNUNET_TIME_UNIT_FOREVER_REL; 1659 o->feedback_delay = GNUNET_TIME_UNIT_FOREVER_REL;
1614 GNUNET_free (op_name); 1660 GNUNET_free(op_name);
1615 1661
1616 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 1662 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
1617 "Found operation %s: [%llu:%llu]: %s = %llu\n", 1663 "Found operation %s: [%llu:%llu]: %s = %llu\n",
1618 "START_SET_PREFERENCE", o->peer_id, o->address_id, 1664 "START_SET_PREFERENCE", o->peer_id, o->address_id,
1619 GNUNET_ATS_print_preference_type(o->pref_type), o->base_rate); 1665 GNUNET_ATS_print_preference_type(o->pref_type), o->base_rate);
1620 1666
1621 return GNUNET_OK; 1667 return GNUNET_OK;
1622} 1668}
1623 1669
1624 1670
1625static int 1671static int
1626load_op_stop_set_preference (struct GNUNET_ATS_TEST_Operation *o, 1672load_op_stop_set_preference(struct GNUNET_ATS_TEST_Operation *o,
1627 struct Episode *e, 1673 struct Episode *e,
1628 int op_counter, 1674 int op_counter,
1629 char *sec_name, 1675 char *sec_name,
1630 const struct GNUNET_CONFIGURATION_Handle *cfg) 1676 const struct GNUNET_CONFIGURATION_Handle *cfg)
1631{ 1677{
1632 char *op_name; 1678 char *op_name;
1633 char *pref; 1679 char *pref;
1634 1680
1635 /* peer pid */ 1681 /* peer pid */
1636 GNUNET_asprintf(&op_name, "op-%u-peer-id", op_counter); 1682 GNUNET_asprintf(&op_name, "op-%u-peer-id", op_counter);
1637 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (cfg, 1683 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number(cfg,
1638 sec_name, op_name, &o->peer_id)) 1684 sec_name, op_name, &o->peer_id))
1639 { 1685 {
1640 fprintf (stderr, "Missing peer-id in operation %u `%s' in episode `%s'\n", 1686 fprintf(stderr, "Missing peer-id in operation %u `%s' in episode `%s'\n",
1641 op_counter, "STOP_SET_PREFERENCE", op_name); 1687 op_counter, "STOP_SET_PREFERENCE", op_name);
1642 GNUNET_free (op_name); 1688 GNUNET_free(op_name);
1643 return GNUNET_SYSERR; 1689 return GNUNET_SYSERR;
1644 } 1690 }
1645 GNUNET_free (op_name); 1691 GNUNET_free(op_name);
1646 1692
1647 /* address pid */ 1693 /* address pid */
1648 GNUNET_asprintf(&op_name, "op-%u-address-id", op_counter); 1694 GNUNET_asprintf(&op_name, "op-%u-address-id", op_counter);
1649 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (cfg, 1695 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number(cfg,
1650 sec_name, op_name, &o->address_id)) 1696 sec_name, op_name, &o->address_id))
1651 { 1697 {
1652 fprintf (stderr, "Missing address-id in operation %u `%s' in episode `%s'\n", 1698 fprintf(stderr, "Missing address-id in operation %u `%s' in episode `%s'\n",
1653 op_counter, "STOP_SET_PREFERENCE", op_name); 1699 op_counter, "STOP_SET_PREFERENCE", op_name);
1654 GNUNET_free (op_name); 1700 GNUNET_free(op_name);
1655 return GNUNET_SYSERR; 1701 return GNUNET_SYSERR;
1656 } 1702 }
1657 GNUNET_free (op_name); 1703 GNUNET_free(op_name);
1658 1704
1659 /* Get preference */ 1705 /* Get preference */
1660 GNUNET_asprintf(&op_name, "op-%u-pref", op_counter); 1706 GNUNET_asprintf(&op_name, "op-%u-pref", op_counter);
1661 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string (cfg, 1707 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string(cfg,
1662 sec_name, op_name, &pref)) 1708 sec_name, op_name, &pref))
1663 { 1709 {
1664 fprintf (stderr, "Missing preference in operation %u `%s' in episode `%s'\n", 1710 fprintf(stderr, "Missing preference in operation %u `%s' in episode `%s'\n",
1665 op_counter, "STOP_SET_PREFERENCE", op_name); 1711 op_counter, "STOP_SET_PREFERENCE", op_name);
1666 GNUNET_free (op_name); 1712 GNUNET_free(op_name);
1667 return GNUNET_SYSERR; 1713 return GNUNET_SYSERR;
1668 } 1714 }
1669 1715
1670 if (0 == (o->pref_type = parse_preference_string(pref))) 1716 if (0 == (o->pref_type = parse_preference_string(pref)))
1671 { 1717 {
1672 fprintf (stderr, "Invalid preference in operation %u `%s' in episode %u\n", 1718 fprintf(stderr, "Invalid preference in operation %u `%s' in episode %u\n",
1673 op_counter, op_name, e->id); 1719 op_counter, op_name, e->id);
1674 GNUNET_free (op_name); 1720 GNUNET_free(op_name);
1675 GNUNET_free (pref); 1721 GNUNET_free(pref);
1676 return GNUNET_SYSERR; 1722 return GNUNET_SYSERR;
1677 } 1723 }
1678 GNUNET_free (pref); 1724 GNUNET_free(pref);
1679 GNUNET_free (op_name); 1725 GNUNET_free(op_name);
1680 1726
1681 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 1727 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
1682 "Found operation %s: [%llu:%llu]: %s\n", 1728 "Found operation %s: [%llu:%llu]: %s\n",
1683 "STOP_SET_PREFERENCE", o->peer_id, o->address_id, 1729 "STOP_SET_PREFERENCE", o->peer_id, o->address_id,
1684 GNUNET_ATS_print_preference_type(o->pref_type)); 1730 GNUNET_ATS_print_preference_type(o->pref_type));
1685 return GNUNET_OK; 1731 return GNUNET_OK;
1686} 1732}
1687 1733
1688 1734
1689static enum GNUNET_ATS_Property 1735static enum GNUNET_ATS_Property
1690parse_property_string (const char *str) 1736parse_property_string(const char *str)
1691{ 1737{
1692 enum GNUNET_ATS_Property c; 1738 enum GNUNET_ATS_Property c;
1693 1739
1694 for (c = 0; c < GNUNET_ATS_PropertyCount; c++) 1740 for (c = 0; c < GNUNET_ATS_PropertyCount; c++)
1695 if (0 == strcmp(str, 1741 if (0 == strcmp(str,
1696 GNUNET_ATS_print_property_type (c))) 1742 GNUNET_ATS_print_property_type(c)))
1697 return c; 1743 return c;
1698 return 0; 1744 return 0;
1699} 1745}
@@ -1701,10 +1747,10 @@ parse_property_string (const char *str)
1701 1747
1702static int 1748static int
1703load_op_start_set_property(struct GNUNET_ATS_TEST_Operation *o, 1749load_op_start_set_property(struct GNUNET_ATS_TEST_Operation *o,
1704 struct Episode *e, 1750 struct Episode *e,
1705 int op_counter, 1751 int op_counter,
1706 char *sec_name, 1752 char *sec_name,
1707 const struct GNUNET_CONFIGURATION_Handle *cfg) 1753 const struct GNUNET_CONFIGURATION_Handle *cfg)
1708{ 1754{
1709 char *op_name; 1755 char *op_name;
1710 char *type; 1756 char *type;
@@ -1712,268 +1758,268 @@ load_op_start_set_property(struct GNUNET_ATS_TEST_Operation *o,
1712 1758
1713 /* peer pid */ 1759 /* peer pid */
1714 GNUNET_asprintf(&op_name, "op-%u-peer-id", op_counter); 1760 GNUNET_asprintf(&op_name, "op-%u-peer-id", op_counter);
1715 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (cfg, 1761 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number(cfg,
1716 sec_name, op_name, &o->peer_id)) 1762 sec_name, op_name, &o->peer_id))
1717 { 1763 {
1718 fprintf (stderr, "Missing peer-id in operation %u `%s' in episode `%s'\n", 1764 fprintf(stderr, "Missing peer-id in operation %u `%s' in episode `%s'\n",
1719 op_counter, "START_SET_PROPERTY", op_name); 1765 op_counter, "START_SET_PROPERTY", op_name);
1720 GNUNET_free (op_name); 1766 GNUNET_free(op_name);
1721 return GNUNET_SYSERR; 1767 return GNUNET_SYSERR;
1722 } 1768 }
1723 GNUNET_free (op_name); 1769 GNUNET_free(op_name);
1724 1770
1725 /* address pid */ 1771 /* address pid */
1726 GNUNET_asprintf(&op_name, "op-%u-address-id", op_counter); 1772 GNUNET_asprintf(&op_name, "op-%u-address-id", op_counter);
1727 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (cfg, 1773 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number(cfg,
1728 sec_name, op_name, &o->address_id)) 1774 sec_name, op_name, &o->address_id))
1729 { 1775 {
1730 fprintf (stderr, "Missing address-id in operation %u `%s' in episode `%s'\n", 1776 fprintf(stderr, "Missing address-id in operation %u `%s' in episode `%s'\n",
1731 op_counter, "START_SET_PROPERTY", op_name); 1777 op_counter, "START_SET_PROPERTY", op_name);
1732 GNUNET_free (op_name); 1778 GNUNET_free(op_name);
1733 return GNUNET_SYSERR; 1779 return GNUNET_SYSERR;
1734 } 1780 }
1735 GNUNET_free (op_name); 1781 GNUNET_free(op_name);
1736 1782
1737 /* generator */ 1783 /* generator */
1738 GNUNET_asprintf(&op_name, "op-%u-gen-type", op_counter); 1784 GNUNET_asprintf(&op_name, "op-%u-gen-type", op_counter);
1739 if ( (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string(cfg, 1785 if ((GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string(cfg,
1740 sec_name, op_name, &type)) ) 1786 sec_name, op_name, &type)))
1741 { 1787 {
1742 fprintf (stderr, "Missing type in operation %u `%s' in episode `%s'\n", 1788 fprintf(stderr, "Missing type in operation %u `%s' in episode `%s'\n",
1743 op_counter, "START_SET_PROPERTY", op_name); 1789 op_counter, "START_SET_PROPERTY", op_name);
1744 GNUNET_free (op_name); 1790 GNUNET_free(op_name);
1745 return GNUNET_SYSERR; 1791 return GNUNET_SYSERR;
1746 } 1792 }
1747 1793
1748 /* Load arguments for set_rate, start_send, set_preference */ 1794 /* Load arguments for set_rate, start_send, set_preference */
1749 if (0 == strcmp (type, "constant")) 1795 if (0 == strcmp(type, "constant"))
1750 { 1796 {
1751 o->gen_type = GNUNET_ATS_TEST_TG_CONSTANT; 1797 o->gen_type = GNUNET_ATS_TEST_TG_CONSTANT;
1752 } 1798 }
1753 else if (0 == strcmp (type, "linear")) 1799 else if (0 == strcmp(type, "linear"))
1754 { 1800 {
1755 o->gen_type = GNUNET_ATS_TEST_TG_LINEAR; 1801 o->gen_type = GNUNET_ATS_TEST_TG_LINEAR;
1756 } 1802 }
1757 else if (0 == strcmp (type, "sinus")) 1803 else if (0 == strcmp(type, "sinus"))
1758 { 1804 {
1759 o->gen_type = GNUNET_ATS_TEST_TG_SINUS; 1805 o->gen_type = GNUNET_ATS_TEST_TG_SINUS;
1760 } 1806 }
1761 else if (0 == strcmp (type, "random")) 1807 else if (0 == strcmp(type, "random"))
1762 { 1808 {
1763 o->gen_type = GNUNET_ATS_TEST_TG_RANDOM; 1809 o->gen_type = GNUNET_ATS_TEST_TG_RANDOM;
1764 } 1810 }
1765 else 1811 else
1766 { 1812 {
1767 fprintf (stderr, "Invalid generator type %u `%s' in episode %u\n", 1813 fprintf(stderr, "Invalid generator type %u `%s' in episode %u\n",
1768 op_counter, op_name, e->id); 1814 op_counter, op_name, e->id);
1769 GNUNET_free (type); 1815 GNUNET_free(type);
1770 GNUNET_free (op_name); 1816 GNUNET_free(op_name);
1771 return GNUNET_SYSERR; 1817 return GNUNET_SYSERR;
1772 } 1818 }
1773 GNUNET_free (type); 1819 GNUNET_free(type);
1774 GNUNET_free (op_name); 1820 GNUNET_free(op_name);
1775 1821
1776 1822
1777 /* Get base rate */ 1823 /* Get base rate */
1778 GNUNET_asprintf(&op_name, "op-%u-base-rate", op_counter); 1824 GNUNET_asprintf(&op_name, "op-%u-base-rate", op_counter);
1779 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (cfg, 1825 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number(cfg,
1780 sec_name, op_name, &o->base_rate)) 1826 sec_name, op_name, &o->base_rate))
1781 { 1827 {
1782 fprintf (stderr, "Missing base rate in operation %u `%s' in episode %u\n", 1828 fprintf(stderr, "Missing base rate in operation %u `%s' in episode %u\n",
1783 op_counter, op_name, e->id); 1829 op_counter, op_name, e->id);
1784 GNUNET_free (op_name); 1830 GNUNET_free(op_name);
1785 return GNUNET_SYSERR; 1831 return GNUNET_SYSERR;
1786 } 1832 }
1787 GNUNET_free (op_name); 1833 GNUNET_free(op_name);
1788 1834
1789 1835
1790 /* Get max rate */ 1836 /* Get max rate */
1791 GNUNET_asprintf(&op_name, "op-%u-max-rate", op_counter); 1837 GNUNET_asprintf(&op_name, "op-%u-max-rate", op_counter);
1792 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (cfg, 1838 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number(cfg,
1793 sec_name, op_name, &o->max_rate)) 1839 sec_name, op_name, &o->max_rate))
1794 {
1795 if ((GNUNET_ATS_TEST_TG_LINEAR == o->gen_type) ||
1796 (GNUNET_ATS_TEST_TG_RANDOM == o->gen_type) ||
1797 (GNUNET_ATS_TEST_TG_SINUS == o->gen_type))
1798 { 1840 {
1799 fprintf (stderr, "Missing max rate in operation %u `%s' in episode %u\n", 1841 if ((GNUNET_ATS_TEST_TG_LINEAR == o->gen_type) ||
1800 op_counter, op_name, e->id); 1842 (GNUNET_ATS_TEST_TG_RANDOM == o->gen_type) ||
1801 GNUNET_free (op_name); 1843 (GNUNET_ATS_TEST_TG_SINUS == o->gen_type))
1802 return GNUNET_SYSERR; 1844 {
1845 fprintf(stderr, "Missing max rate in operation %u `%s' in episode %u\n",
1846 op_counter, op_name, e->id);
1847 GNUNET_free(op_name);
1848 return GNUNET_SYSERR;
1849 }
1803 } 1850 }
1804 } 1851 GNUNET_free(op_name);
1805 GNUNET_free (op_name);
1806 1852
1807 /* Get period */ 1853 /* Get period */
1808 GNUNET_asprintf(&op_name, "op-%u-period", op_counter); 1854 GNUNET_asprintf(&op_name, "op-%u-period", op_counter);
1809 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_time (cfg, 1855 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_time(cfg,
1810 sec_name, op_name, &o->period)) 1856 sec_name, op_name, &o->period))
1811 { 1857 {
1812 o->period = e->duration; 1858 o->period = e->duration;
1813 } 1859 }
1814 GNUNET_free (op_name); 1860 GNUNET_free(op_name);
1815 1861
1816 /* Get frequency */ 1862 /* Get frequency */
1817 GNUNET_asprintf(&op_name, "op-%u-frequency", op_counter); 1863 GNUNET_asprintf(&op_name, "op-%u-frequency", op_counter);
1818 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_time (cfg, 1864 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_time(cfg,
1819 sec_name, op_name, &o->frequency)) 1865 sec_name, op_name, &o->frequency))
1820 { 1866 {
1821 fprintf (stderr, "Missing frequency in operation %u `%s' in episode %u\n", 1867 fprintf(stderr, "Missing frequency in operation %u `%s' in episode %u\n",
1822 op_counter, op_name, e->id); 1868 op_counter, op_name, e->id);
1823 GNUNET_free (op_name); 1869 GNUNET_free(op_name);
1824 return GNUNET_SYSERR; 1870 return GNUNET_SYSERR;
1825 } 1871 }
1826 GNUNET_free (op_name); 1872 GNUNET_free(op_name);
1827 1873
1828 /* Get preference */ 1874 /* Get preference */
1829 GNUNET_asprintf(&op_name, "op-%u-property", op_counter); 1875 GNUNET_asprintf(&op_name, "op-%u-property", op_counter);
1830 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string (cfg, 1876 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string(cfg,
1831 sec_name, op_name, &prop)) 1877 sec_name, op_name, &prop))
1832 { 1878 {
1833 fprintf (stderr, "Missing property in operation %u `%s' in episode %u\n", 1879 fprintf(stderr, "Missing property in operation %u `%s' in episode %u\n",
1834 op_counter, op_name, e->id); 1880 op_counter, op_name, e->id);
1835 GNUNET_free (op_name); 1881 GNUNET_free(op_name);
1836 GNUNET_free_non_null (prop); 1882 GNUNET_free_non_null(prop);
1837 return GNUNET_SYSERR; 1883 return GNUNET_SYSERR;
1838 } 1884 }
1839 1885
1840 if (0 == (o->prop_type = parse_property_string(prop))) 1886 if (0 == (o->prop_type = parse_property_string(prop)))
1841 { 1887 {
1842 fprintf (stderr, "Invalid property in operation %u `%s' in episode %u\n", 1888 fprintf(stderr, "Invalid property in operation %u `%s' in episode %u\n",
1843 op_counter, op_name, e->id); 1889 op_counter, op_name, e->id);
1844 GNUNET_free (op_name); 1890 GNUNET_free(op_name);
1845 GNUNET_free (prop); 1891 GNUNET_free(prop);
1846 return GNUNET_SYSERR; 1892 return GNUNET_SYSERR;
1847 } 1893 }
1848 1894
1849 GNUNET_free (prop); 1895 GNUNET_free(prop);
1850 GNUNET_free (op_name); 1896 GNUNET_free(op_name);
1851 1897
1852 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 1898 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
1853 "Found operation %s: [%llu:%llu] %s = %llu\n", 1899 "Found operation %s: [%llu:%llu] %s = %llu\n",
1854 "START_SET_PROPERTY", o->peer_id, o->address_id, 1900 "START_SET_PROPERTY", o->peer_id, o->address_id,
1855 GNUNET_ATS_print_property_type (o->prop_type), o->base_rate); 1901 GNUNET_ATS_print_property_type(o->prop_type), o->base_rate);
1856 1902
1857 return GNUNET_OK; 1903 return GNUNET_OK;
1858} 1904}
1859 1905
1860static int 1906static int
1861load_op_stop_set_property (struct GNUNET_ATS_TEST_Operation *o, 1907load_op_stop_set_property(struct GNUNET_ATS_TEST_Operation *o,
1862 struct Episode *e, 1908 struct Episode *e,
1863 int op_counter, 1909 int op_counter,
1864 char *sec_name, 1910 char *sec_name,
1865 const struct GNUNET_CONFIGURATION_Handle *cfg) 1911 const struct GNUNET_CONFIGURATION_Handle *cfg)
1866{ 1912{
1867 char *op_name; 1913 char *op_name;
1868 char *pref; 1914 char *pref;
1869 1915
1870 /* peer pid */ 1916 /* peer pid */
1871 GNUNET_asprintf(&op_name, "op-%u-peer-id", op_counter); 1917 GNUNET_asprintf(&op_name, "op-%u-peer-id", op_counter);
1872 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (cfg, 1918 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number(cfg,
1873 sec_name, op_name, &o->peer_id)) 1919 sec_name, op_name, &o->peer_id))
1874 { 1920 {
1875 fprintf (stderr, "Missing peer-id in operation %u `%s' in episode `%s'\n", 1921 fprintf(stderr, "Missing peer-id in operation %u `%s' in episode `%s'\n",
1876 op_counter, "STOP_SET_PROPERTY", op_name); 1922 op_counter, "STOP_SET_PROPERTY", op_name);
1877 GNUNET_free (op_name); 1923 GNUNET_free(op_name);
1878 return GNUNET_SYSERR; 1924 return GNUNET_SYSERR;
1879 } 1925 }
1880 GNUNET_free (op_name); 1926 GNUNET_free(op_name);
1881 1927
1882 /* address pid */ 1928 /* address pid */
1883 GNUNET_asprintf(&op_name, "op-%u-address-id", op_counter); 1929 GNUNET_asprintf(&op_name, "op-%u-address-id", op_counter);
1884 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (cfg, 1930 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number(cfg,
1885 sec_name, op_name, &o->address_id)) 1931 sec_name, op_name, &o->address_id))
1886 { 1932 {
1887 fprintf (stderr, "Missing address-id in operation %u `%s' in episode `%s'\n", 1933 fprintf(stderr, "Missing address-id in operation %u `%s' in episode `%s'\n",
1888 op_counter, "STOP_SET_PROPERTY", op_name); 1934 op_counter, "STOP_SET_PROPERTY", op_name);
1889 GNUNET_free (op_name); 1935 GNUNET_free(op_name);
1890 return GNUNET_SYSERR; 1936 return GNUNET_SYSERR;
1891 } 1937 }
1892 GNUNET_free (op_name); 1938 GNUNET_free(op_name);
1893 1939
1894 /* Get property */ 1940 /* Get property */
1895 GNUNET_asprintf(&op_name, "op-%u-property", op_counter); 1941 GNUNET_asprintf(&op_name, "op-%u-property", op_counter);
1896 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string (cfg, 1942 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string(cfg,
1897 sec_name, op_name, &pref)) 1943 sec_name, op_name, &pref))
1898 { 1944 {
1899 fprintf (stderr, "Missing property in operation %u `%s' in episode `%s'\n", 1945 fprintf(stderr, "Missing property in operation %u `%s' in episode `%s'\n",
1900 op_counter, "STOP_SET_PROPERTY", op_name); 1946 op_counter, "STOP_SET_PROPERTY", op_name);
1901 GNUNET_free (op_name); 1947 GNUNET_free(op_name);
1902 GNUNET_free_non_null (pref); 1948 GNUNET_free_non_null(pref);
1903 return GNUNET_SYSERR; 1949 return GNUNET_SYSERR;
1904 } 1950 }
1905 1951
1906 if (0 == (o->prop_type = parse_property_string(pref))) 1952 if (0 == (o->prop_type = parse_property_string(pref)))
1907 { 1953 {
1908 fprintf (stderr, "Invalid property in operation %u `%s' in episode %u\n", 1954 fprintf(stderr, "Invalid property in operation %u `%s' in episode %u\n",
1909 op_counter, op_name, e->id); 1955 op_counter, op_name, e->id);
1910 GNUNET_free (op_name); 1956 GNUNET_free(op_name);
1911 GNUNET_free_non_null (pref); 1957 GNUNET_free_non_null(pref);
1912 return GNUNET_SYSERR; 1958 return GNUNET_SYSERR;
1913 } 1959 }
1914 1960
1915 GNUNET_free (pref); 1961 GNUNET_free(pref);
1916 GNUNET_free (op_name); 1962 GNUNET_free(op_name);
1917 1963
1918 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 1964 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
1919 "Found operation %s: [%llu:%llu] %s\n", 1965 "Found operation %s: [%llu:%llu] %s\n",
1920 "STOP_SET_PROPERTY", o->peer_id, o->address_id, 1966 "STOP_SET_PROPERTY", o->peer_id, o->address_id,
1921 GNUNET_ATS_print_property_type (o->prop_type)); 1967 GNUNET_ATS_print_property_type(o->prop_type));
1922 1968
1923 return GNUNET_OK; 1969 return GNUNET_OK;
1924} 1970}
1925 1971
1926 1972
1927static int 1973static int
1928load_op_start_request (struct GNUNET_ATS_TEST_Operation *o, 1974load_op_start_request(struct GNUNET_ATS_TEST_Operation *o,
1929 struct Episode *e, 1975 struct Episode *e,
1930 int op_counter, 1976 int op_counter,
1931 char *sec_name, 1977 char *sec_name,
1932 const struct GNUNET_CONFIGURATION_Handle *cfg) 1978 const struct GNUNET_CONFIGURATION_Handle *cfg)
1933{ 1979{
1934 char *op_name; 1980 char *op_name;
1935 1981
1936 /* peer pid */ 1982 /* peer pid */
1937 GNUNET_asprintf(&op_name, "op-%u-peer-id", op_counter); 1983 GNUNET_asprintf(&op_name, "op-%u-peer-id", op_counter);
1938 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (cfg, 1984 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number(cfg,
1939 sec_name, op_name, &o->peer_id)) 1985 sec_name, op_name, &o->peer_id))
1940 { 1986 {
1941 fprintf (stderr, "Missing peer-id in operation %u `%s' in episode `%s'\n", 1987 fprintf(stderr, "Missing peer-id in operation %u `%s' in episode `%s'\n",
1942 op_counter, "START_REQUEST", op_name); 1988 op_counter, "START_REQUEST", op_name);
1943 GNUNET_free (op_name); 1989 GNUNET_free(op_name);
1944 return GNUNET_SYSERR; 1990 return GNUNET_SYSERR;
1945 } 1991 }
1946 GNUNET_free (op_name); 1992 GNUNET_free(op_name);
1947 return GNUNET_OK; 1993 return GNUNET_OK;
1948} 1994}
1949 1995
1950static int 1996static int
1951load_op_stop_request (struct GNUNET_ATS_TEST_Operation *o, 1997load_op_stop_request(struct GNUNET_ATS_TEST_Operation *o,
1952 struct Episode *e, 1998 struct Episode *e,
1953 int op_counter, 1999 int op_counter,
1954 char *sec_name, 2000 char *sec_name,
1955 const struct GNUNET_CONFIGURATION_Handle *cfg) 2001 const struct GNUNET_CONFIGURATION_Handle *cfg)
1956{ 2002{
1957 char *op_name; 2003 char *op_name;
1958 2004
1959 /* peer pid */ 2005 /* peer pid */
1960 GNUNET_asprintf(&op_name, "op-%u-peer-id", op_counter); 2006 GNUNET_asprintf(&op_name, "op-%u-peer-id", op_counter);
1961 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (cfg, 2007 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number(cfg,
1962 sec_name, op_name, &o->peer_id)) 2008 sec_name, op_name, &o->peer_id))
1963 { 2009 {
1964 fprintf (stderr, "Missing peer-id in operation %u `%s' in episode `%s'\n", 2010 fprintf(stderr, "Missing peer-id in operation %u `%s' in episode `%s'\n",
1965 op_counter, "STOP_REQUEST", op_name); 2011 op_counter, "STOP_REQUEST", op_name);
1966 GNUNET_free (op_name); 2012 GNUNET_free(op_name);
1967 return GNUNET_SYSERR; 2013 return GNUNET_SYSERR;
1968 } 2014 }
1969 GNUNET_free (op_name); 2015 GNUNET_free(op_name);
1970 return GNUNET_OK; 2016 return GNUNET_OK;
1971} 2017}
1972 2018
1973 2019
1974static int 2020static int
1975load_episode (struct Experiment *e, struct Episode *cur, 2021load_episode(struct Experiment *e, struct Episode *cur,
1976 struct GNUNET_CONFIGURATION_Handle *cfg) 2022 struct GNUNET_CONFIGURATION_Handle *cfg)
1977{ 2023{
1978 struct GNUNET_ATS_TEST_Operation *o; 2024 struct GNUNET_ATS_TEST_Operation *o;
1979 char *sec_name; 2025 char *sec_name;
@@ -1981,98 +2027,99 @@ load_episode (struct Experiment *e, struct Episode *cur,
1981 char *op; 2027 char *op;
1982 int op_counter = 0; 2028 int op_counter = 0;
1983 int res; 2029 int res;
1984 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "=== Parsing episode %u\n",cur->id); 2030
2031 GNUNET_log(GNUNET_ERROR_TYPE_INFO, "=== Parsing episode %u\n", cur->id);
1985 GNUNET_asprintf(&sec_name, "episode-%u", cur->id); 2032 GNUNET_asprintf(&sec_name, "episode-%u", cur->id);
1986 2033
1987 while (1) 2034 while (1)
1988 {
1989 /* Load operation */
1990 GNUNET_asprintf(&op_name, "op-%u-operation", op_counter);
1991 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string(cfg,
1992 sec_name, op_name, &op))
1993 { 2035 {
1994 GNUNET_free (op_name); 2036 /* Load operation */
1995 break; 2037 GNUNET_asprintf(&op_name, "op-%u-operation", op_counter);
1996 } 2038 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string(cfg,
1997 o = GNUNET_new (struct GNUNET_ATS_TEST_Operation); 2039 sec_name, op_name, &op))
1998 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "==== Parsing operation %u: `%s'\n", 2040 {
1999 cur->id, op_name); 2041 GNUNET_free(op_name);
2042 break;
2043 }
2044 o = GNUNET_new(struct GNUNET_ATS_TEST_Operation);
2045 GNUNET_log(GNUNET_ERROR_TYPE_INFO, "==== Parsing operation %u: `%s'\n",
2046 cur->id, op_name);
2000 2047
2001 /* operations = set_rate, start_send, stop_send, set_preference */ 2048 /* operations = set_rate, start_send, stop_send, set_preference */
2002 if (0 == strcmp (op, "address_add")) 2049 if (0 == strcmp(op, "address_add"))
2003 { 2050 {
2004 o->type = SOLVER_OP_ADD_ADDRESS; 2051 o->type = SOLVER_OP_ADD_ADDRESS;
2005 res = load_op_add_address (o, cur, 2052 res = load_op_add_address(o, cur,
2006 op_counter, sec_name, cfg); 2053 op_counter, sec_name, cfg);
2007 } 2054 }
2008 else if (0 == strcmp (op, "address_del")) 2055 else if (0 == strcmp(op, "address_del"))
2009 { 2056 {
2010 o->type = SOLVER_OP_DEL_ADDRESS; 2057 o->type = SOLVER_OP_DEL_ADDRESS;
2011 res = load_op_del_address (o, cur, 2058 res = load_op_del_address(o, cur,
2012 op_counter, sec_name, cfg); 2059 op_counter, sec_name, cfg);
2013 } 2060 }
2014 else if (0 == strcmp (op, "start_set_property")) 2061 else if (0 == strcmp(op, "start_set_property"))
2015 { 2062 {
2016 o->type = SOLVER_OP_START_SET_PROPERTY; 2063 o->type = SOLVER_OP_START_SET_PROPERTY;
2017 res = load_op_start_set_property (o, cur, 2064 res = load_op_start_set_property(o, cur,
2018 op_counter, sec_name, cfg); 2065 op_counter, sec_name, cfg);
2019 } 2066 }
2020 else if (0 == strcmp (op, "stop_set_property")) 2067 else if (0 == strcmp(op, "stop_set_property"))
2021 { 2068 {
2022 o->type = SOLVER_OP_STOP_SET_PROPERTY; 2069 o->type = SOLVER_OP_STOP_SET_PROPERTY;
2023 res = load_op_stop_set_property (o, cur, 2070 res = load_op_stop_set_property(o, cur,
2024 op_counter, sec_name, cfg); 2071 op_counter, sec_name, cfg);
2025 } 2072 }
2026 else if (0 == strcmp (op, "start_set_preference")) 2073 else if (0 == strcmp(op, "start_set_preference"))
2027 { 2074 {
2028 o->type = SOLVER_OP_START_SET_PREFERENCE; 2075 o->type = SOLVER_OP_START_SET_PREFERENCE;
2029 res = load_op_start_set_preference (o, cur, 2076 res = load_op_start_set_preference(o, cur,
2030 op_counter, sec_name, cfg); 2077 op_counter, sec_name, cfg);
2031 } 2078 }
2032 else if (0 == strcmp (op, "stop_set_preference")) 2079 else if (0 == strcmp(op, "stop_set_preference"))
2033 { 2080 {
2034 o->type = SOLVER_OP_STOP_SET_PREFERENCE; 2081 o->type = SOLVER_OP_STOP_SET_PREFERENCE;
2035 res = load_op_stop_set_preference (o, cur, 2082 res = load_op_stop_set_preference(o, cur,
2036 op_counter, sec_name, cfg); 2083 op_counter, sec_name, cfg);
2037 } 2084 }
2038 else if (0 == strcmp (op, "start_request")) 2085 else if (0 == strcmp(op, "start_request"))
2039 { 2086 {
2040 o->type = SOLVER_OP_START_REQUEST; 2087 o->type = SOLVER_OP_START_REQUEST;
2041 res = load_op_start_request (o, cur, 2088 res = load_op_start_request(o, cur,
2042 op_counter, sec_name, cfg); 2089 op_counter, sec_name, cfg);
2043 } 2090 }
2044 else if (0 == strcmp (op, "stop_request")) 2091 else if (0 == strcmp(op, "stop_request"))
2045 { 2092 {
2046 o->type = SOLVER_OP_STOP_REQUEST; 2093 o->type = SOLVER_OP_STOP_REQUEST;
2047 res = load_op_stop_request(o, cur, 2094 res = load_op_stop_request(o, cur,
2048 op_counter, sec_name, cfg); 2095 op_counter, sec_name, cfg);
2049 } 2096 }
2050 else 2097 else
2051 { 2098 {
2052 fprintf (stderr, "Invalid operation %u `%s' in episode %u\n", 2099 fprintf(stderr, "Invalid operation %u `%s' in episode %u\n",
2053 op_counter, op, cur->id); 2100 op_counter, op, cur->id);
2054 res = GNUNET_SYSERR; 2101 res = GNUNET_SYSERR;
2055 } 2102 }
2056 2103
2057 GNUNET_free (op); 2104 GNUNET_free(op);
2058 GNUNET_free (op_name); 2105 GNUNET_free(op_name);
2059 2106
2060 if (GNUNET_SYSERR == res) 2107 if (GNUNET_SYSERR == res)
2061 { 2108 {
2062 GNUNET_free (o); 2109 GNUNET_free(o);
2063 GNUNET_free (sec_name); 2110 GNUNET_free(sec_name);
2064 return GNUNET_SYSERR; 2111 return GNUNET_SYSERR;
2065 } 2112 }
2066 2113
2067 GNUNET_CONTAINER_DLL_insert_tail (cur->head,cur->tail, o); 2114 GNUNET_CONTAINER_DLL_insert_tail(cur->head, cur->tail, o);
2068 op_counter++; 2115 op_counter++;
2069 } 2116 }
2070 GNUNET_free (sec_name); 2117 GNUNET_free(sec_name);
2071 return GNUNET_OK; 2118 return GNUNET_OK;
2072} 2119}
2073 2120
2074static int 2121static int
2075load_episodes (struct Experiment *e, struct GNUNET_CONFIGURATION_Handle *cfg) 2122load_episodes(struct Experiment *e, struct GNUNET_CONFIGURATION_Handle *cfg)
2076{ 2123{
2077 int e_counter = 0; 2124 int e_counter = 0;
2078 char *sec_name; 2125 char *sec_name;
@@ -2083,87 +2130,87 @@ load_episodes (struct Experiment *e, struct GNUNET_CONFIGURATION_Handle *cfg)
2083 e_counter = 0; 2130 e_counter = 0;
2084 last = NULL; 2131 last = NULL;
2085 while (1) 2132 while (1)
2086 {
2087 GNUNET_asprintf(&sec_name, "episode-%u", e_counter);
2088 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_time(cfg,
2089 sec_name, "duration", &e_duration))
2090 { 2133 {
2091 GNUNET_free (sec_name); 2134 GNUNET_asprintf(&sec_name, "episode-%u", e_counter);
2092 break; 2135 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_time(cfg,
2093 } 2136 sec_name, "duration", &e_duration))
2137 {
2138 GNUNET_free(sec_name);
2139 break;
2140 }
2094 2141
2095 cur = GNUNET_new (struct Episode); 2142 cur = GNUNET_new(struct Episode);
2096 cur->duration = e_duration; 2143 cur->duration = e_duration;
2097 cur->id = e_counter; 2144 cur->id = e_counter;
2098 2145
2099 if (GNUNET_OK != load_episode (e, cur, cfg)) 2146 if (GNUNET_OK != load_episode(e, cur, cfg))
2100 { 2147 {
2101 GNUNET_free (sec_name); 2148 GNUNET_free(sec_name);
2102 GNUNET_free (cur); 2149 GNUNET_free(cur);
2103 return GNUNET_SYSERR; 2150 return GNUNET_SYSERR;
2104 } 2151 }
2105 2152
2106 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Found episode %u with duration %s \n", 2153 GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Found episode %u with duration %s \n",
2107 e_counter, 2154 e_counter,
2108 GNUNET_STRINGS_relative_time_to_string(cur->duration, GNUNET_YES)); 2155 GNUNET_STRINGS_relative_time_to_string(cur->duration, GNUNET_YES));
2109 2156
2110 /* Update experiment */ 2157 /* Update experiment */
2111 e->num_episodes ++; 2158 e->num_episodes++;
2112 e->total_duration = GNUNET_TIME_relative_add(e->total_duration, cur->duration); 2159 e->total_duration = GNUNET_TIME_relative_add(e->total_duration, cur->duration);
2113 /* Put in linked list */ 2160 /* Put in linked list */
2114 if (NULL == last) 2161 if (NULL == last)
2115 e->start = cur; 2162 e->start = cur;
2116 else 2163 else
2117 last->next = cur; 2164 last->next = cur;
2118 2165
2119 GNUNET_free (sec_name); 2166 GNUNET_free(sec_name);
2120 e_counter ++; 2167 e_counter++;
2121 last = cur; 2168 last = cur;
2122 } 2169 }
2123 return e_counter; 2170 return e_counter;
2124} 2171}
2125 2172
2126 2173
2127static void 2174static void
2128timeout_experiment (void *cls) 2175timeout_experiment(void *cls)
2129{ 2176{
2130 struct Experiment *e = cls; 2177 struct Experiment *e = cls;
2131 2178
2132 e->experiment_timeout_task = NULL; 2179 e->experiment_timeout_task = NULL;
2133 fprintf (stderr, "Experiment timeout!\n"); 2180 fprintf(stderr, "Experiment timeout!\n");
2134 2181
2135 if (NULL != e->episode_timeout_task) 2182 if (NULL != e->episode_timeout_task)
2136 { 2183 {
2137 GNUNET_SCHEDULER_cancel (e->episode_timeout_task); 2184 GNUNET_SCHEDULER_cancel(e->episode_timeout_task);
2138 e->episode_timeout_task = NULL; 2185 e->episode_timeout_task = NULL;
2139 } 2186 }
2140 2187
2141 e->e_done_cb (e, GNUNET_TIME_absolute_get_duration(e->start_time), 2188 e->e_done_cb(e, GNUNET_TIME_absolute_get_duration(e->start_time),
2142 GNUNET_SYSERR); 2189 GNUNET_SYSERR);
2143} 2190}
2144 2191
2145struct ATS_Address * 2192struct ATS_Address *
2146create_ats_address (const struct GNUNET_PeerIdentity *peer, 2193create_ats_address(const struct GNUNET_PeerIdentity *peer,
2147 const char *plugin_name, 2194 const char *plugin_name,
2148 const void *plugin_addr, 2195 const void *plugin_addr,
2149 size_t plugin_addr_len, 2196 size_t plugin_addr_len,
2150 uint32_t session_id, 2197 uint32_t session_id,
2151 uint32_t network) 2198 uint32_t network)
2152{ 2199{
2153 struct ATS_Address *aa = NULL; 2200 struct ATS_Address *aa = NULL;
2154 2201
2155 aa = GNUNET_malloc (sizeof (struct ATS_Address) + plugin_addr_len + strlen (plugin_name) + 1); 2202 aa = GNUNET_malloc(sizeof(struct ATS_Address) + plugin_addr_len + strlen(plugin_name) + 1);
2156 aa->atsi = GNUNET_new (struct GNUNET_ATS_Information); 2203 aa->atsi = GNUNET_new(struct GNUNET_ATS_Information);
2157 aa->atsi[0].type = htonl (GNUNET_ATS_NETWORK_TYPE); 2204 aa->atsi[0].type = htonl(GNUNET_ATS_NETWORK_TYPE);
2158 aa->atsi[0].value = htonl (network); 2205 aa->atsi[0].value = htonl(network);
2159 aa->atsi_count = 1; 2206 aa->atsi_count = 1;
2160 2207
2161 aa->peer = *peer; 2208 aa->peer = *peer;
2162 aa->addr_len = plugin_addr_len; 2209 aa->addr_len = plugin_addr_len;
2163 aa->addr = &aa[1]; 2210 aa->addr = &aa[1];
2164 aa->plugin = (char *) &aa[1] + plugin_addr_len; 2211 aa->plugin = (char *)&aa[1] + plugin_addr_len;
2165 GNUNET_memcpy (&aa[1], plugin_addr, plugin_addr_len); 2212 GNUNET_memcpy(&aa[1], plugin_addr, plugin_addr_len);
2166 GNUNET_memcpy (aa->plugin, plugin_name, strlen (plugin_name) + 1); 2213 GNUNET_memcpy(aa->plugin, plugin_name, strlen(plugin_name) + 1);
2167 aa->session_id = session_id; 2214 aa->session_id = session_id;
2168 2215
2169 return aa; 2216 return aa;
@@ -2172,522 +2219,529 @@ create_ats_address (const struct GNUNET_PeerIdentity *peer,
2172 2219
2173 2220
2174static void 2221static void
2175enforce_add_address (struct GNUNET_ATS_TEST_Operation *op) 2222enforce_add_address(struct GNUNET_ATS_TEST_Operation *op)
2176{ 2223{
2177 struct TestPeer *p; 2224 struct TestPeer *p;
2178 struct TestAddress *a; 2225 struct TestAddress *a;
2179 int c; 2226 int c;
2180 2227
2181 if (NULL == (p = find_peer_by_id (op->peer_id))) 2228 if (NULL == (p = find_peer_by_id(op->peer_id)))
2182 {
2183 p = GNUNET_new (struct TestPeer);
2184 p->id = op->peer_id;
2185 p->assigned_bw_in = 0;
2186 p->assigned_bw_out = 0;
2187 memset (&p->peer_id, op->peer_id, sizeof (p->peer_id));
2188 for (c = 0; c < GNUNET_ATS_PreferenceCount; c++)
2189 { 2229 {
2190 p->pref_abs[c] = DEFAULT_ABS_PREFERENCE; 2230 p = GNUNET_new(struct TestPeer);
2191 p->pref_norm[c] = DEFAULT_REL_PREFERENCE; 2231 p->id = op->peer_id;
2192 } 2232 p->assigned_bw_in = 0;
2233 p->assigned_bw_out = 0;
2234 memset(&p->peer_id, op->peer_id, sizeof(p->peer_id));
2235 for (c = 0; c < GNUNET_ATS_PreferenceCount; c++)
2236 {
2237 p->pref_abs[c] = DEFAULT_ABS_PREFERENCE;
2238 p->pref_norm[c] = DEFAULT_REL_PREFERENCE;
2239 }
2193 2240
2194 GNUNET_CONTAINER_DLL_insert (peer_head, peer_tail, p); 2241 GNUNET_CONTAINER_DLL_insert(peer_head, peer_tail, p);
2195 } 2242 }
2196 2243
2197 if (NULL != (find_address_by_id (p, op->address_id))) 2244 if (NULL != (find_address_by_id(p, op->address_id)))
2198 { 2245 {
2199 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Duplicate address %u for peer %u\n", 2246 GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Duplicate address %u for peer %u\n",
2200 op->address_id, op->peer_id); 2247 op->address_id, op->peer_id);
2201 return; 2248 return;
2202 } 2249 }
2203 2250
2204 a = GNUNET_new (struct TestAddress); 2251 a = GNUNET_new(struct TestAddress);
2205 a->aid = op->address_id; 2252 a->aid = op->address_id;
2206 a->network = op->address_network; 2253 a->network = op->address_network;
2207 a->ats_addr = create_ats_address (&p->peer_id, op->plugin, op->address, 2254 a->ats_addr = create_ats_address(&p->peer_id, op->plugin, op->address,
2208 strlen (op->address) + 1, op->address_session, op->address_network); 2255 strlen(op->address) + 1, op->address_session, op->address_network);
2209 memset (&p->peer_id, op->peer_id, sizeof (p->peer_id)); 2256 memset(&p->peer_id, op->peer_id, sizeof(p->peer_id));
2210 GNUNET_CONTAINER_DLL_insert_tail (p->addr_head, p->addr_tail, a); 2257 GNUNET_CONTAINER_DLL_insert_tail(p->addr_head, p->addr_tail, a);
2211 2258
2212 for (c = 0; c < GNUNET_ATS_PropertyCount; c++) 2259 for (c = 0; c < GNUNET_ATS_PropertyCount; c++)
2213 a->prop_norm[c] = DEFAULT_REL_QUALITY; 2260 a->prop_norm[c] = DEFAULT_REL_QUALITY;
2214 2261
2215 GNUNET_CONTAINER_multipeermap_put (sh->addresses, &p->peer_id, a->ats_addr, 2262 GNUNET_CONTAINER_multipeermap_put(sh->addresses, &p->peer_id, a->ats_addr,
2216 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); 2263 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
2217
2218 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Adding address %u for peer %u in network `%s'\n",
2219 op->address_id, op->peer_id, GNUNET_NT_to_string(a->network));
2220 2264
2221 sh->sf->s_add (sh->sf->cls, a->ats_addr, op->address_network); 2265 GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Adding address %u for peer %u in network `%s'\n",
2266 op->address_id, op->peer_id, GNUNET_NT_to_string(a->network));
2222 2267
2268 sh->sf->s_add(sh->sf->cls, a->ats_addr, op->address_network);
2223} 2269}
2224 2270
2225 2271
2226static void 2272static void
2227enforce_del_address (struct GNUNET_ATS_TEST_Operation *op) 2273enforce_del_address(struct GNUNET_ATS_TEST_Operation *op)
2228{ 2274{
2229 struct TestPeer *p; 2275 struct TestPeer *p;
2230 struct TestAddress *a; 2276 struct TestAddress *a;
2231 struct PropertyGenerator *pg; 2277 struct PropertyGenerator *pg;
2232 2278
2233 if (NULL == (p = find_peer_by_id (op->peer_id))) 2279 if (NULL == (p = find_peer_by_id(op->peer_id)))
2234 { 2280 {
2235 GNUNET_break (0); 2281 GNUNET_break(0);
2236 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 2282 GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
2237 "Deleting address for unknown peer %u\n", op->peer_id); 2283 "Deleting address for unknown peer %u\n", op->peer_id);
2238 return; 2284 return;
2239 } 2285 }
2240 2286
2241 if (NULL == (a =find_address_by_id (p, op->address_id))) 2287 if (NULL == (a = find_address_by_id(p, op->address_id)))
2242 { 2288 {
2243 GNUNET_break (0); 2289 GNUNET_break(0);
2244 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 2290 GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
2245 "Deleting address for unknown peer %u\n", op->peer_id); 2291 "Deleting address for unknown peer %u\n", op->peer_id);
2246 return; 2292 return;
2247 } 2293 }
2248 2294
2249 while (NULL != (pg = find_prop_gen (p->id, a->aid, 0))) 2295 while (NULL != (pg = find_prop_gen(p->id, a->aid, 0)))
2250 { 2296 {
2251 GNUNET_ATS_solver_generate_property_stop (pg); 2297 GNUNET_ATS_solver_generate_property_stop(pg);
2252 } 2298 }
2253 2299
2254 GNUNET_assert (GNUNET_YES == 2300 GNUNET_assert(GNUNET_YES ==
2255 GNUNET_CONTAINER_multipeermap_remove (sh->addresses, 2301 GNUNET_CONTAINER_multipeermap_remove(sh->addresses,
2256 &p->peer_id, 2302 &p->peer_id,
2257 a->ats_addr)); 2303 a->ats_addr));
2258 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 2304 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
2259 "Removing address %u for peer %u\n", 2305 "Removing address %u for peer %u\n",
2260 op->address_id, 2306 op->address_id,
2261 op->peer_id); 2307 op->peer_id);
2262 2308
2263 sh->sf->s_del (sh->sf->cls, a->ats_addr); 2309 sh->sf->s_del(sh->sf->cls, a->ats_addr);
2264 2310
2265 if (NULL != l) 2311 if (NULL != l)
2266 { 2312 {
2267 GNUNET_ATS_solver_logging_now (l); 2313 GNUNET_ATS_solver_logging_now(l);
2268 } 2314 }
2269 GNUNET_CONTAINER_DLL_remove(p->addr_head, p->addr_tail, a); 2315 GNUNET_CONTAINER_DLL_remove(p->addr_head, p->addr_tail, a);
2270 2316
2271 GNUNET_free_non_null(a->ats_addr->atsi); 2317 GNUNET_free_non_null(a->ats_addr->atsi);
2272 GNUNET_free (a->ats_addr); 2318 GNUNET_free(a->ats_addr);
2273 GNUNET_free (a); 2319 GNUNET_free(a);
2274
2275} 2320}
2276 2321
2277static void 2322static void
2278enforce_start_property (struct GNUNET_ATS_TEST_Operation *op) 2323enforce_start_property(struct GNUNET_ATS_TEST_Operation *op)
2279{ 2324{
2280 struct PropertyGenerator *pg; 2325 struct PropertyGenerator *pg;
2281 struct TestPeer *p; 2326 struct TestPeer *p;
2282 struct TestAddress *a; 2327 struct TestAddress *a;
2283 2328
2284 if (NULL != (pg = find_prop_gen (op->peer_id, op->address_id, op->prop_type))) 2329 if (NULL != (pg = find_prop_gen(op->peer_id, op->address_id, op->prop_type)))
2285 { 2330 {
2286 GNUNET_ATS_solver_generate_property_stop (pg); 2331 GNUNET_ATS_solver_generate_property_stop(pg);
2287 GNUNET_free (pg); 2332 GNUNET_free(pg);
2288 } 2333 }
2289 2334
2290 if (NULL == (p = find_peer_by_id (op->peer_id))) 2335 if (NULL == (p = find_peer_by_id(op->peer_id)))
2291 { 2336 {
2292 GNUNET_break (0); 2337 GNUNET_break(0);
2293 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 2338 GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
2294 "Starting property generation for unknown peer %u\n", op->peer_id); 2339 "Starting property generation for unknown peer %u\n", op->peer_id);
2295 return; 2340 return;
2296 } 2341 }
2297 2342
2298 if (NULL == (a = find_address_by_id (p, op->address_id))) 2343 if (NULL == (a = find_address_by_id(p, op->address_id)))
2299 { 2344 {
2300 GNUNET_break (0); 2345 GNUNET_break(0);
2301 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 2346 GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
2302 "Setting property for unknown address %u\n", op->peer_id); 2347 "Setting property for unknown address %u\n", op->peer_id);
2303 return; 2348 return;
2304 } 2349 }
2305 2350
2306 GNUNET_ATS_solver_generate_property_start (op->peer_id, 2351 GNUNET_ATS_solver_generate_property_start(op->peer_id,
2307 op->address_id, 2352 op->address_id,
2308 p, a, 2353 p, a,
2309 op->gen_type, 2354 op->gen_type,
2310 op->base_rate, 2355 op->base_rate,
2311 op->max_rate, 2356 op->max_rate,
2312 op->period, 2357 op->period,
2313 op->frequency, 2358 op->frequency,
2314 op->prop_type); 2359 op->prop_type);
2315} 2360}
2316 2361
2317static void 2362static void
2318enforce_stop_property (struct GNUNET_ATS_TEST_Operation *op) 2363enforce_stop_property(struct GNUNET_ATS_TEST_Operation *op)
2319{ 2364{
2320 struct PropertyGenerator *pg = find_prop_gen(op->peer_id, op->address_id, 2365 struct PropertyGenerator *pg = find_prop_gen(op->peer_id, op->address_id,
2321 op->prop_type); 2366 op->prop_type);
2367
2322 if (NULL != pg) 2368 if (NULL != pg)
2323 { 2369 {
2324 GNUNET_log(GNUNET_ERROR_TYPE_INFO, 2370 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
2325 "Stopping preference generation for peer %u address %u\n", op->peer_id, 2371 "Stopping preference generation for peer %u address %u\n", op->peer_id,
2326 op->address_id); 2372 op->address_id);
2327 GNUNET_ATS_solver_generate_property_stop (pg); 2373 GNUNET_ATS_solver_generate_property_stop(pg);
2328 } 2374 }
2329 else 2375 else
2330 { 2376 {
2331 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 2377 GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
2332 "Cannot find preference generator for peer %u address %u\n", 2378 "Cannot find preference generator for peer %u address %u\n",
2333 op->peer_id, op->address_id); 2379 op->peer_id, op->address_id);
2334 GNUNET_break (0); 2380 GNUNET_break(0);
2335 } 2381 }
2336} 2382}
2337 2383
2338static void 2384static void
2339enforce_start_preference (struct GNUNET_ATS_TEST_Operation *op) 2385enforce_start_preference(struct GNUNET_ATS_TEST_Operation *op)
2340{ 2386{
2341 struct PreferenceGenerator *pg; 2387 struct PreferenceGenerator *pg;
2342 if (NULL != (pg = find_pref_gen (op->peer_id, op->pref_type)))
2343 {
2344 GNUNET_ATS_solver_generate_preferences_stop (pg);
2345 GNUNET_free (pg);
2346 }
2347 2388
2348 if (NULL == (find_peer_by_id (op->peer_id))) 2389 if (NULL != (pg = find_pref_gen(op->peer_id, op->pref_type)))
2349 { 2390 {
2350 GNUNET_break (0); 2391 GNUNET_ATS_solver_generate_preferences_stop(pg);
2351 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 2392 GNUNET_free(pg);
2352 "Starting preference generation for unknown peer %u\n", op->peer_id); 2393 }
2353 return; 2394
2354 } 2395 if (NULL == (find_peer_by_id(op->peer_id)))
2396 {
2397 GNUNET_break(0);
2398 GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
2399 "Starting preference generation for unknown peer %u\n", op->peer_id);
2400 return;
2401 }
2355 2402
2356 GNUNET_ATS_solver_generate_preferences_start (op->peer_id, 2403 GNUNET_ATS_solver_generate_preferences_start(op->peer_id,
2357 op->address_id, 2404 op->address_id,
2358 op->client_id, 2405 op->client_id,
2359 op->gen_type, 2406 op->gen_type,
2360 op->base_rate, 2407 op->base_rate,
2361 op->max_rate, 2408 op->max_rate,
2362 op->period, 2409 op->period,
2363 op->frequency, 2410 op->frequency,
2364 op->pref_type, 2411 op->pref_type,
2365 op->frequency); 2412 op->frequency);
2366} 2413}
2367 2414
2368static void 2415static void
2369enforce_stop_preference (struct GNUNET_ATS_TEST_Operation *op) 2416enforce_stop_preference(struct GNUNET_ATS_TEST_Operation *op)
2370{ 2417{
2371 struct PreferenceGenerator *pg = find_pref_gen(op->peer_id, 2418 struct PreferenceGenerator *pg = find_pref_gen(op->peer_id,
2372 op->pref_type); 2419 op->pref_type);
2420
2373 if (NULL != pg) 2421 if (NULL != pg)
2374 { 2422 {
2375 GNUNET_log(GNUNET_ERROR_TYPE_INFO, 2423 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
2376 "Stopping property generation for peer %u address %u\n", op->peer_id, 2424 "Stopping property generation for peer %u address %u\n", op->peer_id,
2377 op->address_id); 2425 op->address_id);
2378 GNUNET_ATS_solver_generate_preferences_stop (pg); 2426 GNUNET_ATS_solver_generate_preferences_stop(pg);
2379 } 2427 }
2380 else 2428 else
2381 { 2429 {
2382 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 2430 GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
2383 "Cannot find preference generator for peer %u address %u\n", 2431 "Cannot find preference generator for peer %u address %u\n",
2384 op->peer_id, op->address_id); 2432 op->peer_id, op->address_id);
2385 GNUNET_break (0); 2433 GNUNET_break(0);
2386 } 2434 }
2387} 2435}
2388 2436
2389 2437
2390static void 2438static void
2391enforce_start_request (struct GNUNET_ATS_TEST_Operation *op) 2439enforce_start_request(struct GNUNET_ATS_TEST_Operation *op)
2392{ 2440{
2393 struct TestPeer *p; 2441 struct TestPeer *p;
2394 2442
2395 if (NULL == (p = find_peer_by_id (op->peer_id))) 2443 if (NULL == (p = find_peer_by_id(op->peer_id)))
2396 { 2444 {
2397 GNUNET_break (0); 2445 GNUNET_break(0);
2398 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 2446 GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
2399 "Requesting address for unknown peer %u\n", op->peer_id); 2447 "Requesting address for unknown peer %u\n", op->peer_id);
2400 return; 2448 return;
2401 } 2449 }
2402 2450
2403 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Requesting address for peer %u\n", 2451 GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Requesting address for peer %u\n",
2404 op->peer_id); 2452 op->peer_id);
2405 p->is_requested = GNUNET_YES; 2453 p->is_requested = GNUNET_YES;
2406 2454
2407 sh->sf->s_get (sh->sf->cls, &p->peer_id); 2455 sh->sf->s_get(sh->sf->cls, &p->peer_id);
2408} 2456}
2409 2457
2410 2458
2411static void 2459static void
2412enforce_stop_request (struct GNUNET_ATS_TEST_Operation *op) 2460enforce_stop_request(struct GNUNET_ATS_TEST_Operation *op)
2413{ 2461{
2414 struct TestPeer *p; 2462 struct TestPeer *p;
2415 2463
2416 if (NULL == (p = find_peer_by_id (op->peer_id))) 2464 if (NULL == (p = find_peer_by_id(op->peer_id)))
2417 { 2465 {
2418 GNUNET_break (0); 2466 GNUNET_break(0);
2419 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 2467 GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
2420 "Requesting address for unknown peer %u\n", op->peer_id); 2468 "Requesting address for unknown peer %u\n", op->peer_id);
2421 return; 2469 return;
2422 } 2470 }
2423 2471
2424 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 2472 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
2425 "Stop requesting address for peer %u\n", 2473 "Stop requesting address for peer %u\n",
2426 op->peer_id); 2474 op->peer_id);
2427 p->is_requested = GNUNET_NO; 2475 p->is_requested = GNUNET_NO;
2428 p->assigned_bw_in = 0; 2476 p->assigned_bw_in = 0;
2429 p->assigned_bw_out = 0; 2477 p->assigned_bw_out = 0;
2430 sh->sf->s_get_stop (sh->sf->cls, &p->peer_id); 2478 sh->sf->s_get_stop(sh->sf->cls, &p->peer_id);
2431 2479
2432 if (NULL != l) 2480 if (NULL != l)
2433 { 2481 {
2434 GNUNET_ATS_solver_logging_now (l); 2482 GNUNET_ATS_solver_logging_now(l);
2435 } 2483 }
2436
2437} 2484}
2438 2485
2439static void enforce_episode (struct Episode *ep) 2486static void enforce_episode(struct Episode *ep)
2440{ 2487{
2441 struct GNUNET_ATS_TEST_Operation *cur; 2488 struct GNUNET_ATS_TEST_Operation *cur;
2489
2442 for (cur = ep->head; NULL != cur; cur = cur->next) 2490 for (cur = ep->head; NULL != cur; cur = cur->next)
2443 { 2491 {
2444 switch (cur->type) { 2492 switch (cur->type)
2445 case SOLVER_OP_ADD_ADDRESS: 2493 {
2446 fprintf (stderr, "Enforcing operation: %s [%llu:%llu]\n", 2494 case SOLVER_OP_ADD_ADDRESS:
2447 print_op (cur->type), cur->peer_id, cur->address_id); 2495 fprintf(stderr, "Enforcing operation: %s [%llu:%llu]\n",
2448 enforce_add_address (cur); 2496 print_op(cur->type), cur->peer_id, cur->address_id);
2449 break; 2497 enforce_add_address(cur);
2450 case SOLVER_OP_DEL_ADDRESS: 2498 break;
2451 fprintf (stderr, "Enforcing operation: %s [%llu:%llu]\n", 2499
2452 print_op (cur->type), cur->peer_id, cur->address_id); 2500 case SOLVER_OP_DEL_ADDRESS:
2453 enforce_del_address (cur); 2501 fprintf(stderr, "Enforcing operation: %s [%llu:%llu]\n",
2454 break; 2502 print_op(cur->type), cur->peer_id, cur->address_id);
2455 case SOLVER_OP_START_SET_PROPERTY: 2503 enforce_del_address(cur);
2456 fprintf (stderr, "Enforcing operation: %s [%llu:%llu] == %llu\n", 2504 break;
2457 print_op (cur->type), cur->peer_id, cur->address_id, cur->base_rate); 2505
2458 enforce_start_property (cur); 2506 case SOLVER_OP_START_SET_PROPERTY:
2459 break; 2507 fprintf(stderr, "Enforcing operation: %s [%llu:%llu] == %llu\n",
2460 case SOLVER_OP_STOP_SET_PROPERTY: 2508 print_op(cur->type), cur->peer_id, cur->address_id, cur->base_rate);
2461 fprintf (stderr, "Enforcing operation: %s [%llu:%llu] == %llu\n", 2509 enforce_start_property(cur);
2462 print_op (cur->type), cur->peer_id, cur->address_id, cur->base_rate); 2510 break;
2463 enforce_stop_property (cur); 2511
2464 break; 2512 case SOLVER_OP_STOP_SET_PROPERTY:
2465 case SOLVER_OP_START_SET_PREFERENCE: 2513 fprintf(stderr, "Enforcing operation: %s [%llu:%llu] == %llu\n",
2466 fprintf (stderr, "Enforcing operation: %s [%llu:%llu] == %llu\n", 2514 print_op(cur->type), cur->peer_id, cur->address_id, cur->base_rate);
2467 print_op (cur->type), cur->peer_id, cur->address_id, cur->base_rate); 2515 enforce_stop_property(cur);
2468 enforce_start_preference (cur); 2516 break;
2469 break; 2517
2470 case SOLVER_OP_STOP_SET_PREFERENCE: 2518 case SOLVER_OP_START_SET_PREFERENCE:
2471 fprintf (stderr, "Enforcing operation: %s [%llu:%llu] == %llu\n", 2519 fprintf(stderr, "Enforcing operation: %s [%llu:%llu] == %llu\n",
2472 print_op (cur->type), cur->peer_id, cur->address_id, cur->base_rate); 2520 print_op(cur->type), cur->peer_id, cur->address_id, cur->base_rate);
2473 enforce_stop_preference (cur); 2521 enforce_start_preference(cur);
2474 break; 2522 break;
2475 case SOLVER_OP_START_REQUEST: 2523
2476 fprintf (stderr, "Enforcing operation: %s [%llu]\n", 2524 case SOLVER_OP_STOP_SET_PREFERENCE:
2477 print_op (cur->type), cur->peer_id); 2525 fprintf(stderr, "Enforcing operation: %s [%llu:%llu] == %llu\n",
2478 enforce_start_request (cur); 2526 print_op(cur->type), cur->peer_id, cur->address_id, cur->base_rate);
2479 break; 2527 enforce_stop_preference(cur);
2480 case SOLVER_OP_STOP_REQUEST: 2528 break;
2481 fprintf (stderr, "Enforcing operation: %s [%llu]\n", 2529
2482 print_op (cur->type), cur->peer_id); 2530 case SOLVER_OP_START_REQUEST:
2483 enforce_stop_request (cur); 2531 fprintf(stderr, "Enforcing operation: %s [%llu]\n",
2484 break; 2532 print_op(cur->type), cur->peer_id);
2485 default: 2533 enforce_start_request(cur);
2486 break; 2534 break;
2487 } 2535
2488 } 2536 case SOLVER_OP_STOP_REQUEST:
2537 fprintf(stderr, "Enforcing operation: %s [%llu]\n",
2538 print_op(cur->type), cur->peer_id);
2539 enforce_stop_request(cur);
2540 break;
2541
2542 default:
2543 break;
2544 }
2545 }
2489} 2546}
2490 2547
2491 2548
2492static void 2549static void
2493timeout_episode (void *cls) 2550timeout_episode(void *cls)
2494{ 2551{
2495 struct Experiment *e = cls; 2552 struct Experiment *e = cls;
2496 2553
2497 e->episode_timeout_task = NULL; 2554 e->episode_timeout_task = NULL;
2498 if (NULL != e->ep_done_cb) 2555 if (NULL != e->ep_done_cb)
2499 e->ep_done_cb (e->cur); 2556 e->ep_done_cb(e->cur);
2500 2557
2501 /* Scheduling next */ 2558 /* Scheduling next */
2502 e->cur = e->cur->next; 2559 e->cur = e->cur->next;
2503 if (NULL == e->cur) 2560 if (NULL == e->cur)
2504 {
2505 /* done */
2506 fprintf (stderr, "Last episode done!\n");
2507 if (NULL != e->experiment_timeout_task)
2508 { 2561 {
2509 GNUNET_SCHEDULER_cancel (e->experiment_timeout_task); 2562 /* done */
2510 e->experiment_timeout_task = NULL; 2563 fprintf(stderr, "Last episode done!\n");
2564 if (NULL != e->experiment_timeout_task)
2565 {
2566 GNUNET_SCHEDULER_cancel(e->experiment_timeout_task);
2567 e->experiment_timeout_task = NULL;
2568 }
2569 e->e_done_cb(e, GNUNET_TIME_absolute_get_duration(e->start_time), GNUNET_OK);
2570 return;
2511 } 2571 }
2512 e->e_done_cb (e, GNUNET_TIME_absolute_get_duration(e->start_time), GNUNET_OK);
2513 return;
2514 }
2515 2572
2516 fprintf (stderr, "Running episode %u with timeout %s\n", 2573 fprintf(stderr, "Running episode %u with timeout %s\n",
2517 e->cur->id, 2574 e->cur->id,
2518 GNUNET_STRINGS_relative_time_to_string(e->cur->duration, GNUNET_YES)); 2575 GNUNET_STRINGS_relative_time_to_string(e->cur->duration, GNUNET_YES));
2519 e->episode_timeout_task = GNUNET_SCHEDULER_add_delayed (e->cur->duration, 2576 e->episode_timeout_task = GNUNET_SCHEDULER_add_delayed(e->cur->duration,
2520 &timeout_episode, e); 2577 &timeout_episode, e);
2521 enforce_episode(e->cur); 2578 enforce_episode(e->cur);
2522
2523
2524} 2579}
2525 2580
2526 2581
2527void 2582void
2528GNUNET_ATS_solvers_experimentation_run (struct Experiment *e, 2583GNUNET_ATS_solvers_experimentation_run(struct Experiment *e,
2529 GNUNET_ATS_TESTING_EpisodeDoneCallback ep_done_cb, 2584 GNUNET_ATS_TESTING_EpisodeDoneCallback ep_done_cb,
2530 GNUNET_ATS_TESTING_ExperimentDoneCallback e_done_cb) 2585 GNUNET_ATS_TESTING_ExperimentDoneCallback e_done_cb)
2531{ 2586{
2532 fprintf (stderr, "Running experiment `%s' with timeout %s\n", e->name, 2587 fprintf(stderr, "Running experiment `%s' with timeout %s\n", e->name,
2533 GNUNET_STRINGS_relative_time_to_string(e->max_duration, GNUNET_YES)); 2588 GNUNET_STRINGS_relative_time_to_string(e->max_duration, GNUNET_YES));
2534 e->e_done_cb = e_done_cb; 2589 e->e_done_cb = e_done_cb;
2535 e->ep_done_cb = ep_done_cb; 2590 e->ep_done_cb = ep_done_cb;
2536 e->start_time = GNUNET_TIME_absolute_get(); 2591 e->start_time = GNUNET_TIME_absolute_get();
2537 2592
2538 /* Start total time out */ 2593 /* Start total time out */
2539 e->experiment_timeout_task = GNUNET_SCHEDULER_add_delayed (e->max_duration, 2594 e->experiment_timeout_task = GNUNET_SCHEDULER_add_delayed(e->max_duration,
2540 &timeout_experiment, e); 2595 &timeout_experiment, e);
2541 2596
2542 /* Start */ 2597 /* Start */
2543 if (NULL == e->start) 2598 if (NULL == e->start)
2544 { 2599 {
2545 GNUNET_break (0); 2600 GNUNET_break(0);
2546 return; 2601 return;
2547 } 2602 }
2548 2603
2549 e->cur = e->start; 2604 e->cur = e->start;
2550 fprintf (stderr, "Running episode %u with timeout %s\n", 2605 fprintf(stderr, "Running episode %u with timeout %s\n",
2551 e->cur->id, 2606 e->cur->id,
2552 GNUNET_STRINGS_relative_time_to_string(e->cur->duration, GNUNET_YES)); 2607 GNUNET_STRINGS_relative_time_to_string(e->cur->duration, GNUNET_YES));
2553 e->episode_timeout_task = GNUNET_SCHEDULER_add_delayed (e->cur->duration, 2608 e->episode_timeout_task = GNUNET_SCHEDULER_add_delayed(e->cur->duration,
2554 &timeout_episode, e); 2609 &timeout_episode, e);
2555 enforce_episode(e->cur); 2610 enforce_episode(e->cur);
2556
2557} 2611}
2558 2612
2559void 2613void
2560GNUNET_ATS_solvers_experimentation_stop (struct Experiment *e) 2614GNUNET_ATS_solvers_experimentation_stop(struct Experiment *e)
2561{ 2615{
2562 if (NULL != e->experiment_timeout_task) 2616 if (NULL != e->experiment_timeout_task)
2563 { 2617 {
2564 GNUNET_SCHEDULER_cancel (e->experiment_timeout_task); 2618 GNUNET_SCHEDULER_cancel(e->experiment_timeout_task);
2565 e->experiment_timeout_task = NULL; 2619 e->experiment_timeout_task = NULL;
2566 } 2620 }
2567 if (NULL != e->episode_timeout_task) 2621 if (NULL != e->episode_timeout_task)
2568 { 2622 {
2569 GNUNET_SCHEDULER_cancel (e->episode_timeout_task); 2623 GNUNET_SCHEDULER_cancel(e->episode_timeout_task);
2570 e->episode_timeout_task = NULL; 2624 e->episode_timeout_task = NULL;
2571 } 2625 }
2572 if (NULL != e->cfg) 2626 if (NULL != e->cfg)
2573 { 2627 {
2574 GNUNET_CONFIGURATION_destroy(e->cfg); 2628 GNUNET_CONFIGURATION_destroy(e->cfg);
2575 e->cfg = NULL; 2629 e->cfg = NULL;
2576 } 2630 }
2577 free_experiment (e); 2631 free_experiment(e);
2578} 2632}
2579 2633
2580 2634
2581struct Experiment * 2635struct Experiment *
2582GNUNET_ATS_solvers_experimentation_load (char *filename) 2636GNUNET_ATS_solvers_experimentation_load(char *filename)
2583{ 2637{
2584 struct Experiment *e; 2638 struct Experiment *e;
2585 struct GNUNET_CONFIGURATION_Handle *cfg; 2639 struct GNUNET_CONFIGURATION_Handle *cfg;
2640
2586 e = NULL; 2641 e = NULL;
2587 2642
2588 cfg = GNUNET_CONFIGURATION_create(); 2643 cfg = GNUNET_CONFIGURATION_create();
2589 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_load (cfg, filename)) 2644 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_load(cfg, filename))
2590 { 2645 {
2591 fprintf (stderr, "Failed to load `%s'\n", filename); 2646 fprintf(stderr, "Failed to load `%s'\n", filename);
2592 GNUNET_CONFIGURATION_destroy (cfg); 2647 GNUNET_CONFIGURATION_destroy(cfg);
2593 return NULL; 2648 return NULL;
2594 } 2649 }
2595 2650
2596 e = create_experiment (); 2651 e = create_experiment();
2597 2652
2598 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string(cfg, "experiment", 2653 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string(cfg, "experiment",
2599 "name", &e->name)) 2654 "name", &e->name))
2600 { 2655 {
2601 fprintf (stderr, "Invalid %s \n", "name"); 2656 fprintf(stderr, "Invalid %s \n", "name");
2602 free_experiment (e); 2657 free_experiment(e);
2603 return NULL; 2658 return NULL;
2604 } 2659 }
2605 else 2660 else
2606 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Experiment name: `%s'\n", e->name); 2661 GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Experiment name: `%s'\n", e->name);
2607 2662
2608 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string(cfg, "experiment", 2663 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string(cfg, "experiment",
2609 "log_prefix", &e->log_prefix)) 2664 "log_prefix", &e->log_prefix))
2610 { 2665 {
2611 fprintf (stderr, "Invalid %s \n", "log_prefix"); 2666 fprintf(stderr, "Invalid %s \n", "log_prefix");
2612 free_experiment (e); 2667 free_experiment(e);
2613 return NULL; 2668 return NULL;
2614 } 2669 }
2615 else 2670 else
2616 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Experiment logging prefix: `%s'\n", 2671 GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Experiment logging prefix: `%s'\n",
2617 e->log_prefix); 2672 e->log_prefix);
2618 2673
2619 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_filename (cfg, "experiment", 2674 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_filename(cfg, "experiment",
2620 "log_output_dir", &e->log_output_dir)) 2675 "log_output_dir", &e->log_output_dir))
2621 { 2676 {
2622 e->log_output_dir = NULL; 2677 e->log_output_dir = NULL;
2623 } 2678 }
2624 else 2679 else
2625 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Experiment logging output directory: `%s'\n", 2680 GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Experiment logging output directory: `%s'\n",
2626 e->log_output_dir); 2681 e->log_output_dir);
2627 2682
2628 2683
2629 if (GNUNET_SYSERR == (e->log_append_time_stamp = GNUNET_CONFIGURATION_get_value_yesno(cfg, 2684 if (GNUNET_SYSERR == (e->log_append_time_stamp = GNUNET_CONFIGURATION_get_value_yesno(cfg,
2630 "experiment", "log_append_time_stamp"))) 2685 "experiment", "log_append_time_stamp")))
2631 e->log_append_time_stamp = GNUNET_YES; 2686 e->log_append_time_stamp = GNUNET_YES;
2632 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Experiment logging append timestamp: `%s'\n", 2687 GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Experiment logging append timestamp: `%s'\n",
2633 (GNUNET_YES == e->log_append_time_stamp) ? "yes" : "no"); 2688 (GNUNET_YES == e->log_append_time_stamp) ? "yes" : "no");
2634 2689
2635 2690
2636 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_filename (cfg, "experiment", 2691 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_filename(cfg, "experiment",
2637 "cfg_file", &e->cfg_file)) 2692 "cfg_file", &e->cfg_file))
2638 {
2639 fprintf (stderr, "Invalid %s \n", "cfg_file");
2640 free_experiment (e);
2641 return NULL;
2642 }
2643 else
2644 {
2645 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Experiment configuration: `%s'\n", e->cfg_file);
2646 e->cfg = GNUNET_CONFIGURATION_create();
2647 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_load (e->cfg, e->cfg_file))
2648 { 2693 {
2649 fprintf (stderr, "Invalid configuration %s \n", "cfg_file"); 2694 fprintf(stderr, "Invalid %s \n", "cfg_file");
2650 free_experiment (e); 2695 free_experiment(e);
2651 return NULL; 2696 return NULL;
2652 } 2697 }
2653 2698 else
2654 } 2699 {
2700 GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Experiment configuration: `%s'\n", e->cfg_file);
2701 e->cfg = GNUNET_CONFIGURATION_create();
2702 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_load(e->cfg, e->cfg_file))
2703 {
2704 fprintf(stderr, "Invalid configuration %s \n", "cfg_file");
2705 free_experiment(e);
2706 return NULL;
2707 }
2708 }
2655 2709
2656 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_time(cfg, "experiment", 2710 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_time(cfg, "experiment",
2657 "log_freq", &e->log_freq)) 2711 "log_freq", &e->log_freq))
2658 { 2712 {
2659 fprintf (stderr, "Invalid %s \n", "log_freq"); 2713 fprintf(stderr, "Invalid %s \n", "log_freq");
2660 free_experiment (e); 2714 free_experiment(e);
2661 return NULL; 2715 return NULL;
2662 } 2716 }
2663 else 2717 else
2664 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Experiment logging frequency: `%s'\n", 2718 GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Experiment logging frequency: `%s'\n",
2665 GNUNET_STRINGS_relative_time_to_string (e->log_freq, GNUNET_YES)); 2719 GNUNET_STRINGS_relative_time_to_string(e->log_freq, GNUNET_YES));
2666 2720
2667 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_time(cfg, "experiment", 2721 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_time(cfg, "experiment",
2668 "max_duration", &e->max_duration)) 2722 "max_duration", &e->max_duration))
2669 { 2723 {
2670 fprintf (stderr, "Invalid %s", "max_duration"); 2724 fprintf(stderr, "Invalid %s", "max_duration");
2671 free_experiment (e); 2725 free_experiment(e);
2672 return NULL; 2726 return NULL;
2673 } 2727 }
2674 else 2728 else
2675 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Experiment duration: `%s'\n", 2729 GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Experiment duration: `%s'\n",
2676 GNUNET_STRINGS_relative_time_to_string (e->max_duration, GNUNET_YES)); 2730 GNUNET_STRINGS_relative_time_to_string(e->max_duration, GNUNET_YES));
2677 2731
2678 if (GNUNET_SYSERR == load_episodes (e, cfg)) 2732 if (GNUNET_SYSERR == load_episodes(e, cfg))
2679 { 2733 {
2680 GNUNET_ATS_solvers_experimentation_stop (e); 2734 GNUNET_ATS_solvers_experimentation_stop(e);
2681 GNUNET_CONFIGURATION_destroy (cfg); 2735 GNUNET_CONFIGURATION_destroy(cfg);
2682 e = NULL; 2736 e = NULL;
2683 fprintf (stderr, "Failed to load experiment\n"); 2737 fprintf(stderr, "Failed to load experiment\n");
2684 return NULL; 2738 return NULL;
2685 } 2739 }
2686 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Loaded %u episodes with total duration %s\n", 2740 GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Loaded %u episodes with total duration %s\n",
2687 e->num_episodes, 2741 e->num_episodes,
2688 GNUNET_STRINGS_relative_time_to_string (e->total_duration, GNUNET_YES)); 2742 GNUNET_STRINGS_relative_time_to_string(e->total_duration, GNUNET_YES));
2689 2743
2690 GNUNET_CONFIGURATION_destroy (cfg); 2744 GNUNET_CONFIGURATION_destroy(cfg);
2691 return e; 2745 return e;
2692} 2746}
2693 2747
@@ -2698,33 +2752,34 @@ GNUNET_ATS_solvers_experimentation_load (char *filename)
2698 */ 2752 */
2699 2753
2700static int 2754static int
2701free_all_it (void *cls, 2755free_all_it(void *cls,
2702 const struct GNUNET_PeerIdentity *key, 2756 const struct GNUNET_PeerIdentity *key,
2703 void *value) 2757 void *value)
2704{ 2758{
2705 struct ATS_Address *address = value; 2759 struct ATS_Address *address = value;
2706 GNUNET_break (GNUNET_OK == GNUNET_CONTAINER_multipeermap_remove (sh->env.addresses, 2760
2707 key, value)); 2761 GNUNET_break(GNUNET_OK == GNUNET_CONTAINER_multipeermap_remove(sh->env.addresses,
2708 GNUNET_free (address); 2762 key, value));
2763 GNUNET_free(address);
2709 2764
2710 return GNUNET_OK; 2765 return GNUNET_OK;
2711} 2766}
2712 2767
2713void 2768void
2714GNUNET_ATS_solvers_solver_stop (struct SolverHandle *sh) 2769GNUNET_ATS_solvers_solver_stop(struct SolverHandle *sh)
2715{ 2770{
2716 GNUNET_STATISTICS_destroy ((struct GNUNET_STATISTICS_Handle *) sh->env.stats, 2771 GNUNET_STATISTICS_destroy((struct GNUNET_STATISTICS_Handle *)sh->env.stats,
2717 GNUNET_NO); 2772 GNUNET_NO);
2718 GNUNET_PLUGIN_unload (sh->plugin, sh->sf); 2773 GNUNET_PLUGIN_unload(sh->plugin, sh->sf);
2719 sh->sf = NULL; 2774 sh->sf = NULL;
2720 GAS_normalization_stop(); 2775 GAS_normalization_stop();
2721 2776
2722 GNUNET_CONTAINER_multipeermap_iterate (sh->addresses, 2777 GNUNET_CONTAINER_multipeermap_iterate(sh->addresses,
2723 &free_all_it, 2778 &free_all_it,
2724 NULL); 2779 NULL);
2725 GNUNET_CONTAINER_multipeermap_destroy(sh->addresses); 2780 GNUNET_CONTAINER_multipeermap_destroy(sh->addresses);
2726 GNUNET_free (sh->plugin); 2781 GNUNET_free(sh->plugin);
2727 GNUNET_free (sh); 2782 GNUNET_free(sh);
2728} 2783}
2729 2784
2730 2785
@@ -2738,10 +2793,10 @@ GNUNET_ATS_solvers_solver_stop (struct SolverHandle *sh)
2738 * @return number of networks loaded 2793 * @return number of networks loaded
2739 */ 2794 */
2740unsigned int 2795unsigned int
2741GNUNET_ATS_solvers_load_quotas (const struct GNUNET_CONFIGURATION_Handle *cfg, 2796GNUNET_ATS_solvers_load_quotas(const struct GNUNET_CONFIGURATION_Handle *cfg,
2742 unsigned long long *out_dest, 2797 unsigned long long *out_dest,
2743 unsigned long long *in_dest, 2798 unsigned long long *in_dest,
2744 int dest_length) 2799 int dest_length)
2745{ 2800{
2746 char * entry_in = NULL; 2801 char * entry_in = NULL;
2747 char * entry_out = NULL; 2802 char * entry_out = NULL;
@@ -2751,105 +2806,105 @@ GNUNET_ATS_solvers_load_quotas (const struct GNUNET_CONFIGURATION_Handle *cfg,
2751 int res; 2806 int res;
2752 2807
2753 for (c = 0; (c < GNUNET_NT_COUNT) && (c < dest_length); c++) 2808 for (c = 0; (c < GNUNET_NT_COUNT) && (c < dest_length); c++)
2754 {
2755 in_dest[c] = 0;
2756 out_dest[c] = 0;
2757 GNUNET_asprintf (&entry_out,
2758 "%s_QUOTA_OUT",
2759 GNUNET_NT_to_string (c));
2760 GNUNET_asprintf (&entry_in,
2761 "%s_QUOTA_IN",
2762 GNUNET_NT_to_string (c));
2763
2764 /* quota out */
2765 if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string(cfg, "ats", entry_out, &quota_out_str))
2766 {
2767 res = GNUNET_NO;
2768 if (0 == strcmp(quota_out_str, BIG_M_STRING))
2769 {
2770 out_dest[c] = GNUNET_ATS_MaxBandwidth;
2771 res = GNUNET_YES;
2772 }
2773 if ((GNUNET_NO == res) && (GNUNET_OK == GNUNET_STRINGS_fancy_size_to_bytes (quota_out_str, &out_dest[c])))
2774 res = GNUNET_YES;
2775 if ((GNUNET_NO == res) && (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (cfg, "ats", entry_out, &out_dest[c])))
2776 res = GNUNET_YES;
2777
2778 if (GNUNET_NO == res)
2779 {
2780 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
2781 _("Could not load quota for network `%s': `%s', assigning default bandwidth %llu\n"),
2782 GNUNET_NT_to_string (c),
2783 quota_out_str,
2784 GNUNET_ATS_DefaultBandwidth);
2785 out_dest[c] = GNUNET_ATS_DefaultBandwidth;
2786 }
2787 else
2788 {
2789 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2790 "Outbound quota configure for network `%s' is %llu\n",
2791 GNUNET_NT_to_string (c),
2792 out_dest[c]);
2793 }
2794 GNUNET_free (quota_out_str);
2795 }
2796 else
2797 {
2798 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
2799 _("No outbound quota configured for network `%s', assigning default bandwidth %llu\n"),
2800 GNUNET_NT_to_string (c),
2801 GNUNET_ATS_DefaultBandwidth);
2802 out_dest[c] = GNUNET_ATS_DefaultBandwidth;
2803 }
2804
2805 /* quota in */
2806 if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string(cfg, "ats", entry_in, &quota_in_str))
2807 { 2809 {
2808 res = GNUNET_NO; 2810 in_dest[c] = 0;
2809 if (0 == strcmp(quota_in_str, BIG_M_STRING)) 2811 out_dest[c] = 0;
2810 { 2812 GNUNET_asprintf(&entry_out,
2811 in_dest[c] = GNUNET_ATS_MaxBandwidth; 2813 "%s_QUOTA_OUT",
2812 res = GNUNET_YES; 2814 GNUNET_NT_to_string(c));
2813 } 2815 GNUNET_asprintf(&entry_in,
2814 if ((GNUNET_NO == res) && (GNUNET_OK == GNUNET_STRINGS_fancy_size_to_bytes (quota_in_str, &in_dest[c]))) 2816 "%s_QUOTA_IN",
2815 res = GNUNET_YES; 2817 GNUNET_NT_to_string(c));
2816 if ((GNUNET_NO == res) && (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (cfg, "ats", entry_in, &in_dest[c]))) 2818
2817 res = GNUNET_YES; 2819 /* quota out */
2820 if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string(cfg, "ats", entry_out, &quota_out_str))
2821 {
2822 res = GNUNET_NO;
2823 if (0 == strcmp(quota_out_str, BIG_M_STRING))
2824 {
2825 out_dest[c] = GNUNET_ATS_MaxBandwidth;
2826 res = GNUNET_YES;
2827 }
2828 if ((GNUNET_NO == res) && (GNUNET_OK == GNUNET_STRINGS_fancy_size_to_bytes(quota_out_str, &out_dest[c])))
2829 res = GNUNET_YES;
2830 if ((GNUNET_NO == res) && (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number(cfg, "ats", entry_out, &out_dest[c])))
2831 res = GNUNET_YES;
2832
2833 if (GNUNET_NO == res)
2834 {
2835 GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
2836 _("Could not load quota for network `%s': `%s', assigning default bandwidth %llu\n"),
2837 GNUNET_NT_to_string(c),
2838 quota_out_str,
2839 GNUNET_ATS_DefaultBandwidth);
2840 out_dest[c] = GNUNET_ATS_DefaultBandwidth;
2841 }
2842 else
2843 {
2844 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
2845 "Outbound quota configure for network `%s' is %llu\n",
2846 GNUNET_NT_to_string(c),
2847 out_dest[c]);
2848 }
2849 GNUNET_free(quota_out_str);
2850 }
2851 else
2852 {
2853 GNUNET_log(GNUNET_ERROR_TYPE_WARNING,
2854 _("No outbound quota configured for network `%s', assigning default bandwidth %llu\n"),
2855 GNUNET_NT_to_string(c),
2856 GNUNET_ATS_DefaultBandwidth);
2857 out_dest[c] = GNUNET_ATS_DefaultBandwidth;
2858 }
2818 2859
2819 if (GNUNET_NO == res) 2860 /* quota in */
2820 { 2861 if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string(cfg, "ats", entry_in, &quota_in_str))
2821 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 2862 {
2822 _("Could not load quota for network `%s': `%s', assigning default bandwidth %llu\n"), 2863 res = GNUNET_NO;
2823 GNUNET_NT_to_string (c), 2864 if (0 == strcmp(quota_in_str, BIG_M_STRING))
2824 quota_in_str, 2865 {
2825 GNUNET_ATS_DefaultBandwidth); 2866 in_dest[c] = GNUNET_ATS_MaxBandwidth;
2826 in_dest[c] = GNUNET_ATS_DefaultBandwidth; 2867 res = GNUNET_YES;
2827 } 2868 }
2869 if ((GNUNET_NO == res) && (GNUNET_OK == GNUNET_STRINGS_fancy_size_to_bytes(quota_in_str, &in_dest[c])))
2870 res = GNUNET_YES;
2871 if ((GNUNET_NO == res) && (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number(cfg, "ats", entry_in, &in_dest[c])))
2872 res = GNUNET_YES;
2873
2874 if (GNUNET_NO == res)
2875 {
2876 GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
2877 _("Could not load quota for network `%s': `%s', assigning default bandwidth %llu\n"),
2878 GNUNET_NT_to_string(c),
2879 quota_in_str,
2880 GNUNET_ATS_DefaultBandwidth);
2881 in_dest[c] = GNUNET_ATS_DefaultBandwidth;
2882 }
2883 else
2884 {
2885 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
2886 "Inbound quota configured for network `%s' is %llu\n",
2887 GNUNET_NT_to_string(c),
2888 in_dest[c]);
2889 }
2890 GNUNET_free(quota_in_str);
2891 }
2828 else 2892 else
2829 { 2893 {
2830 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2894 GNUNET_log(GNUNET_ERROR_TYPE_WARNING,
2831 "Inbound quota configured for network `%s' is %llu\n", 2895 _("No outbound quota configure for network `%s', assigning default bandwidth %llu\n"),
2832 GNUNET_NT_to_string (c), 2896 GNUNET_NT_to_string(c),
2833 in_dest[c]); 2897 GNUNET_ATS_DefaultBandwidth);
2834 } 2898 out_dest[c] = GNUNET_ATS_DefaultBandwidth;
2835 GNUNET_free (quota_in_str); 2899 }
2836 } 2900 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
2837 else 2901 "Loaded quota for network `%s' (in/out): %llu %llu\n",
2838 { 2902 GNUNET_NT_to_string(c),
2839 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 2903 in_dest[c],
2840 _("No outbound quota configure for network `%s', assigning default bandwidth %llu\n"), 2904 out_dest[c]);
2841 GNUNET_NT_to_string (c), 2905 GNUNET_free(entry_out);
2842 GNUNET_ATS_DefaultBandwidth); 2906 GNUNET_free(entry_in);
2843 out_dest[c] = GNUNET_ATS_DefaultBandwidth; 2907 }
2844 }
2845 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
2846 "Loaded quota for network `%s' (in/out): %llu %llu\n",
2847 GNUNET_NT_to_string (c),
2848 in_dest[c],
2849 out_dest[c]);
2850 GNUNET_free (entry_out);
2851 GNUNET_free (entry_in);
2852 }
2853 return GNUNET_NT_COUNT; 2908 return GNUNET_NT_COUNT;
2854} 2909}
2855 2910
@@ -2863,107 +2918,121 @@ GNUNET_ATS_solvers_load_quotas (const struct GNUNET_CONFIGURATION_Handle *cfg,
2863 * @param add additional solver information 2918 * @param add additional solver information
2864 */ 2919 */
2865static void 2920static void
2866solver_info_cb (void *cls, 2921solver_info_cb(void *cls,
2867 enum GAS_Solver_Operation op, 2922 enum GAS_Solver_Operation op,
2868 enum GAS_Solver_Status stat, 2923 enum GAS_Solver_Status stat,
2869 enum GAS_Solver_Additional_Information add) 2924 enum GAS_Solver_Additional_Information add)
2870{ 2925{
2871 char *add_info; 2926 char *add_info;
2872 switch (add) { 2927
2928 switch (add)
2929 {
2873 case GAS_INFO_NONE: 2930 case GAS_INFO_NONE:
2874 add_info = "GAS_INFO_NONE"; 2931 add_info = "GAS_INFO_NONE";
2875 break; 2932 break;
2933
2876 case GAS_INFO_FULL: 2934 case GAS_INFO_FULL:
2877 add_info = "GAS_INFO_MLP_FULL"; 2935 add_info = "GAS_INFO_MLP_FULL";
2878 break; 2936 break;
2937
2879 case GAS_INFO_UPDATED: 2938 case GAS_INFO_UPDATED:
2880 add_info = "GAS_INFO_MLP_UPDATED"; 2939 add_info = "GAS_INFO_MLP_UPDATED";
2881 break; 2940 break;
2941
2882 case GAS_INFO_PROP_ALL: 2942 case GAS_INFO_PROP_ALL:
2883 add_info = "GAS_INFO_PROP_ALL"; 2943 add_info = "GAS_INFO_PROP_ALL";
2884 break; 2944 break;
2945
2885 case GAS_INFO_PROP_SINGLE: 2946 case GAS_INFO_PROP_SINGLE:
2886 add_info = "GAS_INFO_PROP_SINGLE"; 2947 add_info = "GAS_INFO_PROP_SINGLE";
2887 break; 2948 break;
2949
2888 default: 2950 default:
2889 add_info = "INVALID"; 2951 add_info = "INVALID";
2890 break; 2952 break;
2891 } 2953 }
2892 2954
2893 switch (op) 2955 switch (op)
2894 { 2956 {
2895 case GAS_OP_SOLVE_START: 2957 case GAS_OP_SOLVE_START:
2896 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 2958 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
2897 "Solver notifies `%s' with result `%s' `%s'\n", "GAS_OP_SOLVE_START", 2959 "Solver notifies `%s' with result `%s' `%s'\n", "GAS_OP_SOLVE_START",
2898 (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL", add_info); 2960 (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL", add_info);
2899 return; 2961 return;
2962
2900 case GAS_OP_SOLVE_STOP: 2963 case GAS_OP_SOLVE_STOP:
2901 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 2964 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
2902 "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_STOP", 2965 "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_STOP",
2903 (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL", add_info); 2966 (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL", add_info);
2904 return; 2967 return;
2905 2968
2906 case GAS_OP_SOLVE_SETUP_START: 2969 case GAS_OP_SOLVE_SETUP_START:
2907 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 2970 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
2908 "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_SETUP_START", 2971 "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_SETUP_START",
2909 (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL"); 2972 (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL");
2910 return; 2973 return;
2911 2974
2912 case GAS_OP_SOLVE_SETUP_STOP: 2975 case GAS_OP_SOLVE_SETUP_STOP:
2913 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 2976 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
2914 "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_SETUP_STOP", 2977 "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_SETUP_STOP",
2915 (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL"); 2978 (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL");
2916 return; 2979 return;
2917 2980
2918 case GAS_OP_SOLVE_MLP_LP_START: 2981 case GAS_OP_SOLVE_MLP_LP_START:
2919 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 2982 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
2920 "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_LP_START", 2983 "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_LP_START",
2921 (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL"); 2984 (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL");
2922 return; 2985 return;
2986
2923 case GAS_OP_SOLVE_MLP_LP_STOP: 2987 case GAS_OP_SOLVE_MLP_LP_STOP:
2924 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 2988 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
2925 "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_LP_STOP", 2989 "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_LP_STOP",
2926 (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL"); 2990 (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL");
2927 return; 2991 return;
2928 2992
2929 case GAS_OP_SOLVE_MLP_MLP_START: 2993 case GAS_OP_SOLVE_MLP_MLP_START:
2930 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 2994 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
2931 "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_MLP_START", 2995 "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_MLP_START",
2932 (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL"); 2996 (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL");
2933 return; 2997 return;
2998
2934 case GAS_OP_SOLVE_MLP_MLP_STOP: 2999 case GAS_OP_SOLVE_MLP_MLP_STOP:
2935 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 3000 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
2936 "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_MLP_STOP", 3001 "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_MLP_STOP",
2937 (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL"); 3002 (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL");
2938 return; 3003 return;
3004
2939 case GAS_OP_SOLVE_UPDATE_NOTIFICATION_START: 3005 case GAS_OP_SOLVE_UPDATE_NOTIFICATION_START:
2940 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 3006 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
2941 "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_UPDATE_NOTIFICATION_START", 3007 "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_UPDATE_NOTIFICATION_START",
2942 (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL"); 3008 (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL");
2943 return; 3009 return;
3010
2944 case GAS_OP_SOLVE_UPDATE_NOTIFICATION_STOP: 3011 case GAS_OP_SOLVE_UPDATE_NOTIFICATION_STOP:
2945 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 3012 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
2946 "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_UPDATE_NOTIFICATION_STOP", 3013 "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_UPDATE_NOTIFICATION_STOP",
2947 (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL"); 3014 (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL");
2948 return; 3015 return;
3016
2949 default: 3017 default:
2950 break; 3018 break;
2951 } 3019 }
2952} 3020}
2953 3021
2954static void 3022static void
2955solver_bandwidth_changed_cb (void *cls, struct ATS_Address *address) 3023solver_bandwidth_changed_cb(void *cls, struct ATS_Address *address)
2956{ 3024{
2957 struct GNUNET_TIME_Relative duration; 3025 struct GNUNET_TIME_Relative duration;
2958 struct TestPeer *p; 3026 struct TestPeer *p;
2959 static struct PreferenceGenerator *pg; 3027 static struct PreferenceGenerator *pg;
2960 uint32_t delta; 3028 uint32_t delta;
2961 if ( (0 == address->assigned_bw_out) && (0 == address->assigned_bw_in) ) 3029
2962 { 3030 if ((0 == address->assigned_bw_out) && (0 == address->assigned_bw_in))
2963 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 3031 {
2964 "Solver notified to disconnect peer `%s'\n", 3032 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
2965 GNUNET_i2s (&address->peer)); 3033 "Solver notified to disconnect peer `%s'\n",
2966 } 3034 GNUNET_i2s(&address->peer));
3035 }
2967 p = find_peer_by_pid(&address->peer); 3036 p = find_peer_by_pid(&address->peer);
2968 if (NULL == p) 3037 if (NULL == p)
2969 return; 3038 return;
@@ -2971,82 +3040,87 @@ solver_bandwidth_changed_cb (void *cls, struct ATS_Address *address)
2971 p->assigned_bw_in = address->assigned_bw_in; 3040 p->assigned_bw_in = address->assigned_bw_in;
2972 3041
2973 for (pg = pref_gen_head; NULL != pg; pg = pg->next) 3042 for (pg = pref_gen_head; NULL != pg; pg = pg->next)
2974 {
2975 if (pg->peer == p->id)
2976 { 3043 {
2977 duration = GNUNET_TIME_absolute_get_duration(pg->feedback_last_bw_update); 3044 if (pg->peer == p->id)
2978 delta = duration.rel_value_us * pg->last_assigned_bw_out; 3045 {
2979 pg->feedback_bw_out_acc += delta; 3046 duration = GNUNET_TIME_absolute_get_duration(pg->feedback_last_bw_update);
3047 delta = duration.rel_value_us * pg->last_assigned_bw_out;
3048 pg->feedback_bw_out_acc += delta;
2980 3049
2981 delta = duration.rel_value_us * pg->last_assigned_bw_in; 3050 delta = duration.rel_value_us * pg->last_assigned_bw_in;
2982 pg->feedback_bw_in_acc += delta; 3051 pg->feedback_bw_in_acc += delta;
2983 3052
2984 pg->last_assigned_bw_in = address->assigned_bw_in; 3053 pg->last_assigned_bw_in = address->assigned_bw_in;
2985 pg->last_assigned_bw_out = address->assigned_bw_out; 3054 pg->last_assigned_bw_out = address->assigned_bw_out;
2986 pg->feedback_last_bw_update = GNUNET_TIME_absolute_get(); 3055 pg->feedback_last_bw_update = GNUNET_TIME_absolute_get();
3056 }
2987 } 3057 }
2988 }
2989 3058
2990 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 3059 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
2991 "Bandwidth changed addresses %s %p to %u Bps out / %u Bps in\n", 3060 "Bandwidth changed addresses %s %p to %u Bps out / %u Bps in\n",
2992 GNUNET_i2s (&address->peer), 3061 GNUNET_i2s(&address->peer),
2993 address, 3062 address,
2994 address->assigned_bw_out, 3063 address->assigned_bw_out,
2995 address->assigned_bw_in); 3064 address->assigned_bw_in);
2996 3065
2997 if (NULL != l) 3066 if (NULL != l)
2998 GNUNET_ATS_solver_logging_now (l); 3067 GNUNET_ATS_solver_logging_now(l);
2999 3068
3000 return; 3069 return;
3001} 3070}
3002 3071
3003const double * 3072const double *
3004get_preferences_cb (void *cls, const struct GNUNET_PeerIdentity *id) 3073get_preferences_cb(void *cls, const struct GNUNET_PeerIdentity *id)
3005{ 3074{
3006 struct TestPeer *p; 3075 struct TestPeer *p;
3076
3007 if (GNUNET_YES == opt_disable_normalization) 3077 if (GNUNET_YES == opt_disable_normalization)
3008 { 3078 {
3009 if (NULL == (p = find_peer_by_pid (id))) 3079 if (NULL == (p = find_peer_by_pid(id)))
3010 return NULL; 3080 return NULL;
3011 return p->pref_abs; 3081 return p->pref_abs;
3012 } 3082 }
3013 else 3083 else
3014 return GAS_preference_get_by_peer (NULL, 3084 return GAS_preference_get_by_peer(NULL,
3015 id); 3085 id);
3016} 3086}
3017 3087
3018 3088
3019struct SolverHandle * 3089struct SolverHandle *
3020GNUNET_ATS_solvers_solver_start (enum GNUNET_ATS_Solvers type) 3090GNUNET_ATS_solvers_solver_start(enum GNUNET_ATS_Solvers type)
3021{ 3091{
3022 struct SolverHandle *sh; 3092 struct SolverHandle *sh;
3023 char * solver_str; 3093 char * solver_str;
3024 3094
3025 switch (type) { 3095 switch (type)
3096 {
3026 case GNUNET_ATS_SOLVER_PROPORTIONAL: 3097 case GNUNET_ATS_SOLVER_PROPORTIONAL:
3027 solver_str = "proportional"; 3098 solver_str = "proportional";
3028 break; 3099 break;
3100
3029 case GNUNET_ATS_SOLVER_MLP: 3101 case GNUNET_ATS_SOLVER_MLP:
3030 solver_str = "mlp"; 3102 solver_str = "mlp";
3031 break; 3103 break;
3104
3032 case GNUNET_ATS_SOLVER_RIL: 3105 case GNUNET_ATS_SOLVER_RIL:
3033 solver_str = "ril"; 3106 solver_str = "ril";
3034 break; 3107 break;
3108
3035 default: 3109 default:
3036 GNUNET_break (0); 3110 GNUNET_break(0);
3037 return NULL; 3111 return NULL;
3038 break; 3112 break;
3039 } 3113 }
3040 3114
3041 sh = GNUNET_new (struct SolverHandle); 3115 sh = GNUNET_new(struct SolverHandle);
3042 GNUNET_asprintf (&sh->plugin, 3116 GNUNET_asprintf(&sh->plugin,
3043 "libgnunet_plugin_ats_%s", 3117 "libgnunet_plugin_ats_%s",
3044 solver_str); 3118 solver_str);
3045 sh->addresses = GNUNET_CONTAINER_multipeermap_create (128, GNUNET_NO); 3119 sh->addresses = GNUNET_CONTAINER_multipeermap_create(128, GNUNET_NO);
3046 3120
3047 /* setup environment */ 3121 /* setup environment */
3048 sh->env.cfg = e->cfg; 3122 sh->env.cfg = e->cfg;
3049 sh->env.stats = GNUNET_STATISTICS_create ("ats", e->cfg); 3123 sh->env.stats = GNUNET_STATISTICS_create("ats", e->cfg);
3050 sh->env.addresses = sh->addresses; 3124 sh->env.addresses = sh->addresses;
3051 sh->env.bandwidth_changed_cb = &solver_bandwidth_changed_cb; 3125 sh->env.bandwidth_changed_cb = &solver_bandwidth_changed_cb;
3052 sh->env.get_preferences = &get_preferences_cb; 3126 sh->env.get_preferences = &get_preferences_cb;
@@ -3055,35 +3129,35 @@ GNUNET_ATS_solvers_solver_start (enum GNUNET_ATS_Solvers type)
3055 sh->env.network_count = GNUNET_NT_COUNT; 3129 sh->env.network_count = GNUNET_NT_COUNT;
3056 3130
3057 /* start normalization */ 3131 /* start normalization */
3058 GAS_normalization_start (); 3132 GAS_normalization_start();
3059 3133
3060 /* load quotas */ 3134 /* load quotas */
3061 if (GNUNET_NT_COUNT != GNUNET_ATS_solvers_load_quotas (e->cfg, 3135 if (GNUNET_NT_COUNT != GNUNET_ATS_solvers_load_quotas(e->cfg,
3062 sh->env.out_quota, sh->env.in_quota, GNUNET_NT_COUNT)) 3136 sh->env.out_quota, sh->env.in_quota, GNUNET_NT_COUNT))
3063 { 3137 {
3064 GNUNET_break(0); 3138 GNUNET_break(0);
3065 GNUNET_free (sh->plugin); 3139 GNUNET_free(sh->plugin);
3066 GNUNET_free (sh); 3140 GNUNET_free(sh);
3067 end_now (); 3141 end_now();
3068 return NULL; 3142 return NULL;
3069 } 3143 }
3070 3144
3071 sh->sf = GNUNET_PLUGIN_load (sh->plugin, &sh->env); 3145 sh->sf = GNUNET_PLUGIN_load(sh->plugin, &sh->env);
3072 if (NULL == sh->sf) 3146 if (NULL == sh->sf)
3073 { 3147 {
3074 fprintf (stderr, "Failed to load solver `%s'\n", sh->plugin); 3148 fprintf(stderr, "Failed to load solver `%s'\n", sh->plugin);
3075 GNUNET_break(0); 3149 GNUNET_break(0);
3076 GNUNET_free (sh->plugin); 3150 GNUNET_free(sh->plugin);
3077 GNUNET_free (sh); 3151 GNUNET_free(sh);
3078 end_now (); 3152 end_now();
3079 return NULL; 3153 return NULL;
3080 } 3154 }
3081 return sh; 3155 return sh;
3082} 3156}
3083 3157
3084 3158
3085static void 3159static void
3086done () 3160done()
3087{ 3161{
3088 struct TestPeer *cur; 3162 struct TestPeer *cur;
3089 struct TestPeer *next; 3163 struct TestPeer *next;
@@ -3092,79 +3166,79 @@ done ()
3092 struct TestAddress *next_a; 3166 struct TestAddress *next_a;
3093 3167
3094 /* Stop logging */ 3168 /* Stop logging */
3095 GNUNET_ATS_solver_logging_stop (l); 3169 GNUNET_ATS_solver_logging_stop(l);
3096 3170
3097 /* Stop all preference generation */ 3171 /* Stop all preference generation */
3098 GNUNET_ATS_solver_generate_preferences_stop_all (); 3172 GNUNET_ATS_solver_generate_preferences_stop_all();
3099 3173
3100 /* Stop all property generation */ 3174 /* Stop all property generation */
3101 GNUNET_ATS_solver_generate_property_stop_all (); 3175 GNUNET_ATS_solver_generate_property_stop_all();
3102 3176
3103 if (opt_print) 3177 if (opt_print)
3104 { 3178 {
3105 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "== Printing log information \n"); 3179 GNUNET_log(GNUNET_ERROR_TYPE_INFO, "== Printing log information \n");
3106 GNUNET_ATS_solver_logging_eval (l); 3180 GNUNET_ATS_solver_logging_eval(l);
3107 } 3181 }
3108 if (opt_save) 3182 if (opt_save)
3109 { 3183 {
3110 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "== Saving log information \n"); 3184 GNUNET_log(GNUNET_ERROR_TYPE_INFO, "== Saving log information \n");
3111 GNUNET_ATS_solver_logging_write_to_disk (l, e->log_append_time_stamp, 3185 GNUNET_ATS_solver_logging_write_to_disk(l, e->log_append_time_stamp,
3112 e->log_output_dir); 3186 e->log_output_dir);
3113 } 3187 }
3114 3188
3115 if (NULL != l) 3189 if (NULL != l)
3116 { 3190 {
3117 GNUNET_ATS_solver_logging_free (l); 3191 GNUNET_ATS_solver_logging_free(l);
3118 l = NULL; 3192 l = NULL;
3119 } 3193 }
3120 3194
3121 /* Clean up experiment */ 3195 /* Clean up experiment */
3122 if (NULL != e) 3196 if (NULL != e)
3123 { 3197 {
3124 GNUNET_ATS_solvers_experimentation_stop (e); 3198 GNUNET_ATS_solvers_experimentation_stop(e);
3125 e = NULL; 3199 e = NULL;
3126 } 3200 }
3127 3201
3128 next = peer_head; 3202 next = peer_head;
3129 while (NULL != (cur = next)) 3203 while (NULL != (cur = next))
3130 {
3131 next = cur->next;
3132 GNUNET_CONTAINER_DLL_remove (peer_head, peer_tail, cur);
3133 next_a = cur->addr_head;
3134 while (NULL != (cur_a = next_a))
3135 { 3204 {
3136 next_a = cur_a->next; 3205 next = cur->next;
3137 GNUNET_CONTAINER_DLL_remove (cur->addr_head, cur->addr_tail, cur_a); 3206 GNUNET_CONTAINER_DLL_remove(peer_head, peer_tail, cur);
3138 GNUNET_free (cur_a); 3207 next_a = cur->addr_head;
3208 while (NULL != (cur_a = next_a))
3209 {
3210 next_a = cur_a->next;
3211 GNUNET_CONTAINER_DLL_remove(cur->addr_head, cur->addr_tail, cur_a);
3212 GNUNET_free(cur_a);
3213 }
3214 GNUNET_free(cur);
3139 } 3215 }
3140 GNUNET_free (cur);
3141 }
3142 if (NULL != sh) 3216 if (NULL != sh)
3143 { 3217 {
3144 GNUNET_ATS_solvers_solver_stop (sh); 3218 GNUNET_ATS_solvers_solver_stop(sh);
3145 sh = NULL; 3219 sh = NULL;
3146 } 3220 }
3147 3221
3148 /* Shutdown */ 3222 /* Shutdown */
3149 end_now(); 3223 end_now();
3150} 3224}
3151 3225
3152static void 3226static void
3153experiment_done_cb (struct Experiment *e, struct GNUNET_TIME_Relative duration,int success) 3227experiment_done_cb(struct Experiment *e, struct GNUNET_TIME_Relative duration, int success)
3154{ 3228{
3155 if (GNUNET_OK == success) 3229 if (GNUNET_OK == success)
3156 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Experiment done successful in %s\n", 3230 GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Experiment done successful in %s\n",
3157 GNUNET_STRINGS_relative_time_to_string (duration, GNUNET_YES)); 3231 GNUNET_STRINGS_relative_time_to_string(duration, GNUNET_YES));
3158 else 3232 else
3159 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Experiment failed \n"); 3233 GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Experiment failed \n");
3160 3234
3161 GNUNET_SCHEDULER_add_now (&done, NULL); 3235 GNUNET_SCHEDULER_add_now(&done, NULL);
3162} 3236}
3163 3237
3164static void 3238static void
3165episode_done_cb (struct Episode *ep) 3239episode_done_cb(struct Episode *ep)
3166{ 3240{
3167 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Episode %u done\n", ep->id); 3241 GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Episode %u done\n", ep->id);
3168} 3242}
3169 3243
3170 3244
@@ -3173,62 +3247,62 @@ episode_done_cb (struct Episode *ep)
3173 * Do shutdown 3247 * Do shutdown
3174 */ 3248 */
3175static void 3249static void
3176end_now () 3250end_now()
3177{ 3251{
3178 if (NULL != e) 3252 if (NULL != e)
3179 { 3253 {
3180 GNUNET_ATS_solvers_experimentation_stop (e); 3254 GNUNET_ATS_solvers_experimentation_stop(e);
3181 e = NULL; 3255 e = NULL;
3182 } 3256 }
3183 if (NULL != sh) 3257 if (NULL != sh)
3184 { 3258 {
3185 GNUNET_ATS_solvers_solver_stop (sh); 3259 GNUNET_ATS_solvers_solver_stop(sh);
3186 sh = NULL; 3260 sh = NULL;
3187 } 3261 }
3188} 3262}
3189 3263
3190static void 3264static void
3191run (void *cls, char * const *args, const char *cfgfile, 3265run(void *cls, char * const *args, const char *cfgfile,
3192 const struct GNUNET_CONFIGURATION_Handle *cfg) 3266 const struct GNUNET_CONFIGURATION_Handle *cfg)
3193{ 3267{
3194 enum GNUNET_ATS_Solvers solver; 3268 enum GNUNET_ATS_Solvers solver;
3195 int c; 3269 int c;
3196 3270
3197 if (NULL == opt_exp_file) 3271 if (NULL == opt_exp_file)
3198 { 3272 {
3199 fprintf (stderr, "No experiment given ...\n"); 3273 fprintf(stderr, "No experiment given ...\n");
3200 res = 1; 3274 res = 1;
3201 end_now (); 3275 end_now();
3202 return; 3276 return;
3203 } 3277 }
3204 3278
3205 if (NULL == opt_solver) 3279 if (NULL == opt_solver)
3206 { 3280 {
3207 fprintf (stderr, "No solver given ...\n"); 3281 fprintf(stderr, "No solver given ...\n");
3208 res = 1; 3282 res = 1;
3209 end_now (); 3283 end_now();
3210 return; 3284 return;
3211 } 3285 }
3212 3286
3213 if (0 == strcmp(opt_solver, "mlp")) 3287 if (0 == strcmp(opt_solver, "mlp"))
3214 { 3288 {
3215 solver = GNUNET_ATS_SOLVER_MLP; 3289 solver = GNUNET_ATS_SOLVER_MLP;
3216 } 3290 }
3217 else if (0 == strcmp(opt_solver, "proportional")) 3291 else if (0 == strcmp(opt_solver, "proportional"))
3218 { 3292 {
3219 solver = GNUNET_ATS_SOLVER_PROPORTIONAL; 3293 solver = GNUNET_ATS_SOLVER_PROPORTIONAL;
3220 } 3294 }
3221 else if (0 == strcmp(opt_solver, "ril")) 3295 else if (0 == strcmp(opt_solver, "ril"))
3222 { 3296 {
3223 solver = GNUNET_ATS_SOLVER_RIL; 3297 solver = GNUNET_ATS_SOLVER_RIL;
3224 } 3298 }
3225 else 3299 else
3226 { 3300 {
3227 fprintf (stderr, "No solver given ..."); 3301 fprintf(stderr, "No solver given ...");
3228 res = 1; 3302 res = 1;
3229 end_now (); 3303 end_now();
3230 return; 3304 return;
3231 } 3305 }
3232 3306
3233 for (c = 0; c < GNUNET_ATS_PropertyCount; c++) 3307 for (c = 0; c < GNUNET_ATS_PropertyCount; c++)
3234 default_properties[c] = DEFAULT_REL_QUALITY; 3308 default_properties[c] = DEFAULT_REL_QUALITY;
@@ -3237,35 +3311,35 @@ run (void *cls, char * const *args, const char *cfgfile,
3237 default_preferences[c] = DEFAULT_REL_PREFERENCE; 3311 default_preferences[c] = DEFAULT_REL_PREFERENCE;
3238 3312
3239 /* load experiment */ 3313 /* load experiment */
3240 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "=== Loading experiment\n"); 3314 GNUNET_log(GNUNET_ERROR_TYPE_INFO, "=== Loading experiment\n");
3241 e = GNUNET_ATS_solvers_experimentation_load (opt_exp_file); 3315 e = GNUNET_ATS_solvers_experimentation_load(opt_exp_file);
3242 if (NULL == e) 3316 if (NULL == e)
3243 { 3317 {
3244 fprintf (stderr, "Failed to load experiment ...\n"); 3318 fprintf(stderr, "Failed to load experiment ...\n");
3245 res = 1; 3319 res = 1;
3246 end_now (); 3320 end_now();
3247 return; 3321 return;
3248 } 3322 }
3249 3323
3250 /* load solver */ 3324 /* load solver */
3251 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "=== Loading solver\n"); 3325 GNUNET_log(GNUNET_ERROR_TYPE_INFO, "=== Loading solver\n");
3252 sh = GNUNET_ATS_solvers_solver_start (solver); 3326 sh = GNUNET_ATS_solvers_solver_start(solver);
3253 if (NULL == sh) 3327 if (NULL == sh)
3254 { 3328 {
3255 fprintf (stderr, "Failed to start solver ...\n"); 3329 fprintf(stderr, "Failed to start solver ...\n");
3256 end_now (); 3330 end_now();
3257 res = 1; 3331 res = 1;
3258 return; 3332 return;
3259 } 3333 }
3260 3334
3261 /* start logging */ 3335 /* start logging */
3262 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "=== Start logging \n"); 3336 GNUNET_log(GNUNET_ERROR_TYPE_INFO, "=== Start logging \n");
3263 l = GNUNET_ATS_solver_logging_start (e->log_freq); 3337 l = GNUNET_ATS_solver_logging_start(e->log_freq);
3264 3338
3265 /* run experiment */ 3339 /* run experiment */
3266 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "=== Running experiment \n"); 3340 GNUNET_log(GNUNET_ERROR_TYPE_INFO, "=== Running experiment \n");
3267 GNUNET_ATS_solvers_experimentation_run (e, episode_done_cb, 3341 GNUNET_ATS_solvers_experimentation_run(e, episode_done_cb,
3268 experiment_done_cb); 3342 experiment_done_cb);
3269 3343
3270 /* WAIT */ 3344 /* WAIT */
3271} 3345}
@@ -3278,7 +3352,7 @@ run (void *cls, char * const *args, const char *cfgfile,
3278 * @param argv argument values 3352 * @param argv argument values
3279 */ 3353 */
3280int 3354int
3281main (int argc, char *argv[]) 3355main(int argc, char *argv[])
3282{ 3356{
3283 opt_exp_file = NULL; 3357 opt_exp_file = NULL;
3284 opt_solver = NULL; 3358 opt_solver = NULL;
@@ -3289,38 +3363,38 @@ main (int argc, char *argv[])
3289 3363
3290 static struct GNUNET_GETOPT_CommandLineOption options[] = 3364 static struct GNUNET_GETOPT_CommandLineOption options[] =
3291 { 3365 {
3292 GNUNET_GETOPT_option_string ('s', 3366 GNUNET_GETOPT_option_string('s',
3293 "solver", 3367 "solver",
3294 gettext_noop ("solver to use"), 3368 gettext_noop("solver to use"),
3295 &opt_solver), 3369 &opt_solver),
3296 3370
3297 GNUNET_GETOPT_option_string ('e', 3371 GNUNET_GETOPT_option_string('e',
3298 "experiment" 3372 "experiment"
3299 gettext_noop ("experiment to use"), 3373 gettext_noop("experiment to use"),
3300 &opt_exp_file), 3374 &opt_exp_file),
3301 3375
3302 GNUNET_GETOPT_option_verbose (&opt_verbose), 3376 GNUNET_GETOPT_option_verbose(&opt_verbose),
3303 3377
3304 GNUNET_GETOPT_option_flag ('p', 3378 GNUNET_GETOPT_option_flag('p',
3305 "print", 3379 "print",
3306 gettext_noop ("print logging"), 3380 gettext_noop("print logging"),
3307 &opt_print), 3381 &opt_print),
3308 3382
3309 GNUNET_GETOPT_option_flag ('f', 3383 GNUNET_GETOPT_option_flag('f',
3310 "file", 3384 "file",
3311 gettext_noop ("save logging to disk"), 3385 gettext_noop("save logging to disk"),
3312 &opt_save), 3386 &opt_save),
3313 3387
3314 GNUNET_GETOPT_option_flag ('d', 3388 GNUNET_GETOPT_option_flag('d',
3315 "dn", 3389 "dn",
3316 gettext_noop ("disable normalization"), 3390 gettext_noop("disable normalization"),
3317 &opt_disable_normalization), 3391 &opt_disable_normalization),
3318 3392
3319 GNUNET_GETOPT_OPTION_END 3393 GNUNET_GETOPT_OPTION_END
3320 }; 3394 };
3321 3395
3322 GNUNET_PROGRAM_run (argc, argv, "gnunet-ats-solver-eval", 3396 GNUNET_PROGRAM_run(argc, argv, "gnunet-ats-solver-eval",
3323 NULL, options, &run, argv[0]); 3397 NULL, options, &run, argv[0]);
3324 3398
3325 return res; 3399 return res;
3326} 3400}