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