GNUnet  0.10.x
gnunet-ats-solver-eval.c
Go to the documentation of this file.
1 /*
2  This file is part of GNUnet.
3  Copyright (C) 2010-2013 GNUnet e.V.
4 
5  GNUnet is free software: you can redistribute it and/or modify it
6  under the terms of the GNU Affero General Public License as published
7  by the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  GNUnet is distributed in the hope that it will be useful, but
11  WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Affero General Public License for more details.
14 
15  You should have received a copy of the GNU Affero General Public License
16  along with this program. If not, see <http://www.gnu.org/licenses/>.
17 
18  SPDX-License-Identifier: AGPL3.0-or-later
19  */
26 #include "platform.h"
27 #include "gnunet_util_lib.h"
28 #include "gnunet-ats-solver-eval.h"
31 
32 #define BIG_M_STRING "unlimited"
33 
38 
39 
40 static struct Experiment *e;
41 
42 static struct LoggingHandle *l;
43 
44 static struct SolverHandle *sh;
45 
46 static struct TestPeer *peer_head;
47 
48 static struct TestPeer *peer_tail;
49 
50 static double default_properties[GNUNET_ATS_PropertyCount];
51 static double default_preferences[GNUNET_ATS_PreferenceCount];
52 
56 static char *opt_exp_file;
57 
58 static char *opt_solver;
59 
63 static int opt_log;
64 
68 static int opt_save;
69 
73 static int opt_verbose;
74 
78 static int opt_print;
79 
84 
85 static int res;
86 
87 static void
88 end_now ();
89 
90 
91 static char *
93 {
94  switch (g) {
96  return "CONSTANT";
98  return "LINEAR";
100  return "RANDOM";
102  return "SINUS";
103  default:
104  return "INVALID";
105  break;
106  }
107 }
108 
109 
110 static struct TestPeer *
112 {
113  struct TestPeer *cur;
114  for (cur = peer_head; NULL != cur; cur = cur->next)
115  if (cur->id == id)
116  return cur;
117  return NULL;
118 }
119 
120 static struct TestPeer *
122 {
123  struct TestPeer *cur;
124  for (cur = peer_head; NULL != cur; cur = cur->next)
125  if (0 == GNUNET_memcmp (&cur->peer_id, pid))
126  return cur;
127  return NULL;
128 }
129 
130 static struct TestAddress *
132 {
133  struct TestAddress *cur;
134  for (cur = peer->addr_head; NULL != cur; cur = cur->next)
135  if (cur->aid == aid)
136  return cur;
137  return NULL;
138 }
139 
140 
144 void
146 {
147  struct LoggingTimeStep *lts;
148  struct TestPeer *cur;
149  struct TestAddress *cur_addr;
150  struct LoggingPeer *log_p;
151  struct LoggingAddress *log_a;
152  int c;
153 
154  lts = GNUNET_new (struct LoggingTimeStep);
157  if (NULL == lts->prev)
159  else
161 
162  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Logging %llu, delta %llu\n",
164 
165 
166  /* Store logging data here */
167  for (cur = peer_head; NULL != cur; cur = cur->next)
168  {
170  "Logging peer id %llu\n", cur->id);
171 
172  log_p = GNUNET_new (struct LoggingPeer);
173  log_p->id = cur->id;
174  log_p->peer_id = cur->peer_id;
175  log_p->is_requested = cur->is_requested;
176  for (c = 0; c < GNUNET_ATS_PreferenceCount; c++)
177  {
178  log_p->pref_abs[c] = cur->pref_abs[c];
179  log_p->pref_norm[c] = cur->pref_norm[c];
181  "\t %s = %.2f %.2f [abs/rel]\n",
183  log_p->pref_abs[c], log_p->pref_norm[c]);
184  }
185  GNUNET_CONTAINER_DLL_insert_tail(lts->head, lts->tail, log_p);
186 
187  for (cur_addr = cur->addr_head; NULL != cur_addr; cur_addr = cur_addr->next)
188  {
190  "Logging peer id %llu address %llu\n",
191  cur->id, cur_addr->aid);
192  log_a = GNUNET_new (struct LoggingAddress);
193  log_a->aid = cur_addr->aid;
194  log_a->active = cur_addr->ats_addr->active;
195  log_a->network = cur_addr->network;
196  log_a->assigned_bw_in = cur_addr->ats_addr->assigned_bw_in;
197  log_a->assigned_bw_out = cur_addr->ats_addr->assigned_bw_out;
198  for (c = 0; c < GNUNET_ATS_PropertyCount; c++)
199  {
200  log_a->prop_abs[c] = cur_addr->prop_abs[c];
201  log_a->prop_norm[c] = cur_addr->prop_norm[c];
203  "\t %s = %.2f %.2f [abs/rel]\n",
204  GNUNET_ATS_print_property_type(c),
205  log_a->prop_abs[c],
206  log_a->prop_norm[c]);
207  }
208  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "\t Active = %i\n", log_a->active);
209  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "\t BW in = %llu\n", log_a->assigned_bw_in);
210  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "\t BW out = %llu\n", log_a->assigned_bw_out);
211 
212  GNUNET_CONTAINER_DLL_insert_tail (log_p->addr_head, log_p->addr_tail, log_a);
213  }
214  }
215 }
216 
217 
218 static void
219 logging_task (void *cls)
220 {
221  struct LoggingHandle *l = cls;
222 
223  l->logging_task = NULL;
226  &logging_task,
227  l);
228 }
229 
230 struct LoggingHandle *
232 {
233  struct LoggingHandle *l;
234  l = GNUNET_new (struct LoggingHandle);
235 
236  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Start logging every %s\n",
238  l->log_freq = freq;
240  return l;
241 }
242 
243 void
245 {
246  if (NULL != l->logging_task)
248 
249  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Stop logging\n");
250 
251  l->logging_task = NULL;
252 }
253 
254 static struct LoggingFileHandle *
256  struct LoggingFileHandle *lf_tail,
257  int peer_id, int address_id)
258 {
259  struct LoggingFileHandle *res;
260 
261  for (res = lf_head; NULL != res; res = res->next)
262  if ((res->pid == peer_id) && (res->aid == address_id))
263  return res;
264  return NULL;
265 
266 }
267 
268 void
270  char *output_dir)
271 {
272  struct LoggingTimeStep *lts;
273  struct LoggingPeer *log_p;
274  struct LoggingAddress *log_a;
275  struct LoggingFileHandle *lf_head;
276  struct LoggingFileHandle *lf_tail;
277  struct LoggingFileHandle *cur;
278  struct LoggingFileHandle *next;
279  char * filename;
280  char * datastring;
281  char * propstring;
282  char * propstring_tmp;
283  char * prefstring;
284  char * prefstring_tmp;
285  int c;
286  int use_dir;
287 
288  use_dir = GNUNET_NO;
289  if (NULL != output_dir)
290  {
292  {
293  fprintf (stderr, "Failed to create directory `%s'\n", output_dir);
294  return;
295  }
296  else
297  {
298  fprintf (stderr, "Created directory `%s'\n", output_dir);
299  use_dir = GNUNET_YES;
300  }
301  }
302 
303  lf_head = NULL;
304  lf_tail = NULL;
305 
306  for (lts = l->head; NULL != lts; lts = lts->next)
307  {
308 
309  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Writing log step %llu\n",
310  (long long unsigned int) lts->timestamp.abs_value_us);
311 
312  for (log_p = lts->head; NULL != log_p; log_p = log_p->next)
313  {
314  for (log_a = log_p->addr_head; NULL != log_a; log_a = log_a->next)
315  {
316 
317  cur = find_logging_file_handle (lf_head, lf_tail, log_p->id,
318  log_a->aid);
319  if (NULL == cur)
320  {
321  cur = GNUNET_new (struct LoggingFileHandle);
322  cur->aid = log_a->aid;
323  cur->pid = log_p->id;
324 
325  if (GNUNET_YES == add_time_stamp)
326  GNUNET_asprintf (&filename, "%s%s%s_%s_p%u_a%u_%llu.log",
327  (GNUNET_YES == use_dir) ? output_dir : "",
328  (GNUNET_YES == use_dir) ? DIR_SEPARATOR_STR : "",
329  e->log_prefix,
330  opt_solver,
331  cur->pid,
332  cur->aid,
334  else
335  GNUNET_asprintf (&filename, "%s%s%s_%s_p%u_a%u.log",
336  (GNUNET_YES == use_dir) ? output_dir : "",
337  (GNUNET_YES == use_dir) ? DIR_SEPARATOR_STR : "",
338  e->log_prefix,
339  opt_solver,
340  cur->pid,
341  cur->aid);
342 
343  fprintf (stderr, "Add writing log data for peer %llu address %llu to file `%s'\n",
344  cur->pid, cur->aid, filename);
345 
346 
347  cur->f_hd = GNUNET_DISK_file_open (filename,
355  if (NULL == cur->f_hd)
356  {
357  fprintf (stderr, "Cannot open `%s' to write log data!\n", filename);
358  GNUNET_free (filename);
359  GNUNET_free (cur);
360  goto cleanup;
361  }
362  GNUNET_free (filename);
363  GNUNET_CONTAINER_DLL_insert (lf_head, lf_tail, cur);
364 
365  GNUNET_asprintf(&datastring,"#time delta;log duration;peer_requested;addr net; addr_active; bw in; bw out; " \
366  "UTILIZATION_UP [abs/rel]; UTILIZATION_UP; UTILIZATION_DOWN; UTILIZATION_DOWN; " \
367  "UTILIZATION_PAYLOAD_UP; UTILIZATION_PAYLOAD_UP; UTILIZATION_PAYLOAD_DOWN; UTILIZATION_PAYLOAD_DOWN;"\
368  "DELAY; DELAY; " \
369  "DISTANCE ;DISTANCE ; COST_WAN; COST_WAN; COST_LAN; COST_LAN; " \
370  "COST_WLAN; COST_WLAN;COST_BT; COST_BT; PREF BW abs; PREF BW rel; PREF LATENCY abs; PREF LATENCY rel;\n");
371  GNUNET_DISK_file_write (cur->f_hd, datastring, strlen(datastring));
372  GNUNET_free (datastring);
373 
374  }
375 
376  prefstring = GNUNET_strdup("");
377  for (c = 1; c < GNUNET_ATS_PreferenceCount; c++)
378  {
379  /*
380  fprintf(stderr,"\t %s = %.2f %.2f [abs/rel]\n",
381  GNUNET_ATS_print_preference_type(c),
382  log_p->pref_abs[c], log_p->pref_norm[c]);
383  */
384  GNUNET_asprintf(&prefstring_tmp,"%s;%.3f;%.3f",
385  prefstring, log_p->pref_abs[c], log_p->pref_norm[c]);
386 
387 
388  GNUNET_free (prefstring);
389  prefstring = GNUNET_strdup(prefstring_tmp);
390  GNUNET_free (prefstring_tmp);
391  }
392 
393 
394  propstring = GNUNET_strdup("");
395  for (c = 1; c < GNUNET_ATS_PropertyCount; c++)
396  {
397  if (GNUNET_ATS_NETWORK_TYPE == c)
398  continue;
399  /*
400  fprintf(stderr, "\t %s = %.2f %.2f [abs/rel]\n",
401  GNUNET_ATS_print_property_type(c),
402  log_a->prop_abs[c], log_a->prop_norm[c]);*/
403  GNUNET_asprintf(&propstring_tmp,"%s%.3f;%.3f;",
404  propstring,
405  log_a->prop_abs[c],
406  log_a->prop_norm[c]);
407  GNUNET_free (propstring);
408  propstring = GNUNET_strdup(propstring_tmp);
409  GNUNET_free (propstring_tmp);
410  }
411  GNUNET_asprintf (&datastring, "%llu;%llu;%u;%u;%i;%u;%u;%s;%s\n",
413  lts->timestamp).rel_value_us / 1000, lts->delta,
414  log_p->is_requested, log_a->network, log_a->active,
415  log_a->assigned_bw_in, log_a->assigned_bw_out, propstring,
416  prefstring);
417 
418  GNUNET_DISK_file_write (cur->f_hd, datastring, strlen(datastring));
419  GNUNET_free (datastring);
420  GNUNET_free (prefstring);
421  GNUNET_free (propstring);
422  }
423  }
424  }
425 
426 cleanup:
427  next = lf_head;
428  for (cur = next; NULL != cur; cur = next)
429  {
430  next = cur->next;
431  GNUNET_CONTAINER_DLL_remove (lf_head, lf_tail, cur);
432  if (NULL != cur->f_hd)
434  GNUNET_free (cur);
435  }
436 
437 }
438 
439 void
441 {
442  struct LoggingTimeStep *lts;
443  struct LoggingPeer *log_p;
444  struct LoggingAddress *log_a;
445  int c;
446 
447  for (lts = l->head; NULL != lts; lts = lts->next)
448  {
449  fprintf (stderr, "Log step %llu %llu: \n",
450  (long long unsigned int) lts->timestamp.abs_value_us,
451  (long long unsigned int) lts->delta.rel_value_us);
452 
453  for (log_p = lts->head; NULL != log_p; log_p = log_p->next)
454  {
455  fprintf (stderr,"\tLogging peer pid %llu\n", log_p->id);
456  for (c = 1; c < GNUNET_ATS_PreferenceCount; c++)
457  {
458  fprintf(stderr,"\t %s = %.2f %.2f [abs/rel]\n",
460  log_p->pref_abs[c], log_p->pref_norm[c]);
461  }
462 
463  for (log_a = log_p->addr_head; NULL != log_a; log_a = log_a->next)
464  {
465  fprintf (stderr, "\tPeer pid %llu address %llu: %u %u %u\n",
466  log_p->id, log_a->aid, log_a->active,
467  log_a->assigned_bw_in,
468  log_a->assigned_bw_out);
469 
470  for (c = 1; c < GNUNET_ATS_PropertyCount; c++)
471  {
472  if (GNUNET_ATS_NETWORK_TYPE == c)
473  continue;
474  fprintf(stderr, "\t %s = %.2f %.2f [abs/rel]\n",
475  GNUNET_ATS_print_property_type(c),
476  log_a->prop_abs[c], log_a->prop_norm[c]);
477  }
478  }
479  }
480  }
481 }
482 
483 void
485 {
486  struct LoggingTimeStep *lts_cur;
487  struct LoggingTimeStep *lts_next;
488  struct LoggingPeer *log_p_cur;
489  struct LoggingPeer *log_p_next;
490  struct LoggingAddress *log_a_cur;
491  struct LoggingAddress *log_a_next;
492 
493  if (NULL != l->logging_task)
495  l->logging_task = NULL;
496 
497  lts_next = l->head;
498  while (NULL != (lts_cur = lts_next))
499  {
500  lts_next = lts_cur->next;
501 
502  log_p_next = lts_cur->head;
503  while (NULL != (log_p_cur = log_p_next))
504  {
505  log_p_next = log_p_cur->next;
506 
507  log_a_next = log_p_cur->addr_head;
508  while (NULL != (log_a_cur = log_a_next))
509  {
510  log_a_next = log_a_cur->next;
511 
512  GNUNET_CONTAINER_DLL_remove (log_p_cur->addr_head, log_p_cur->addr_tail, log_a_cur);
513  GNUNET_free (log_a_cur);
514  }
515 
516  GNUNET_CONTAINER_DLL_remove (lts_cur->head, lts_cur->tail, log_p_cur);
517  GNUNET_free (log_p_cur);
518  }
519 
520  GNUNET_CONTAINER_DLL_remove (l->head, l->tail, lts_cur);
521  GNUNET_free (lts_cur);
522  }
523 
524  GNUNET_free (l);
525 }
526 
532 
533 
534 static double
536 {
537  struct GNUNET_TIME_Relative time_delta;
538  double delta_value;
539  double pref_value;
540 
541  /* Calculate the current preference value */
542  switch (pg->type) {
544  pref_value = pg->base_value;
545  break;
548  /* Calculate point of time in the current period */
549  time_delta.rel_value_us = time_delta.rel_value_us %
551  delta_value = ((double) time_delta.rel_value_us /
553  if ((pg->max_value < pg->base_value) &&
554  ((pg->max_value - pg->base_value) > pg->base_value))
555  {
556  /* This will cause an underflow */
557  GNUNET_break (0);
558  }
559  pref_value = pg->base_value + delta_value;
560  break;
563  10000 * (pg->max_value - pg->base_value)) / 10000;
564  pref_value = pg->base_value + delta_value;
565  break;
568  /* Calculate point of time in the current period */
569  time_delta.rel_value_us = time_delta.rel_value_us %
571  if ((pg->max_value - pg->base_value) > pg->base_value)
572  {
573  /* This will cause an underflow for second half of sinus period,
574  * will be detected in general when experiments are loaded */
575  GNUNET_break (0);
576  }
577  delta_value = (pg->max_value - pg->base_value) *
578  sin ( (2 * M_PI) / ((double) pg->duration_period.rel_value_us) *
579  time_delta.rel_value_us);
580  pref_value = pg->base_value + delta_value;
581  break;
582  default:
583  pref_value = 0.0;
584  break;
585  }
586  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Current property value is %f\n",
587  pref_value);
588  return pref_value;
589 }
590 
591 
592 static void
593 set_prop_task (void *cls)
594 {
595  struct PropertyGenerator *pg = cls;
596  struct TestPeer *p;
597  struct TestAddress *a;
598  double prop_value;
599  struct GNUNET_ATS_Information atsi;
600 
601  pg->set_task = NULL;
602 
604  &pg->test_peer->peer_id, pg->test_address->ats_addr))
605  {
606  GNUNET_break (0);
608  "Setting property generation for unknown address [%u:%u]\n",
609  pg->peer, pg->address_id);
610  return;
611  }
612  if (NULL == (p = find_peer_by_id (pg->peer)))
613  {
614  GNUNET_break (0);
616  "Setting property generation for unknown peer %u\n",
617  pg->peer);
618  return;
619  }
620  if (NULL == (a = find_address_by_id (p, pg->address_id)))
621  {
622  GNUNET_break (0);
624  "Setting property generation for unknown peer %u\n",
625  pg->peer);
626  return;
627  }
628 
629  prop_value = get_property (pg);
630  a->prop_abs[pg->ats_property] = prop_value;
631 
633  "Setting property for peer [%u] address [%u] for %s to %f\n",
634  pg->peer, pg->address_id,
635  GNUNET_ATS_print_property_type (pg->ats_property), prop_value);
636 
637  atsi.type = htonl (pg->ats_property);
638  atsi.value = htonl ((uint32_t) prop_value);
639 
640  /* set performance here! */
641  sh->sf->s_bulk_start (sh->sf->cls);
643  {
644  a->prop_abs[pg->ats_property] = prop_value;
645  a->prop_norm[pg->ats_property] = prop_value;
646  sh->sf->s_address_update_property (sh->sf->cls, a->ats_addr,
647  pg->ats_property, prop_value, prop_value);
648  }
649  else
651  sh->sf->s_bulk_stop (sh->sf->cls);
652 
654  &set_prop_task, pg);
655 }
656 
657 
661 static struct PropertyGenerator *
662 find_prop_gen (unsigned int peer, unsigned int address,
663  uint32_t ats_property)
664 {
665  struct PropertyGenerator *cur;
666  for (cur = prop_gen_head; NULL != cur; cur = cur->next)
667  if ((cur->peer == peer) && (cur->address_id == address))
668  {
669  if ((cur->ats_property == ats_property) || (0 == ats_property))
670  return cur;
671  }
672  return NULL;
673 }
674 
675 void
677 {
678  GNUNET_CONTAINER_DLL_remove (prop_gen_head, prop_gen_tail, pg);
679 
680  if (NULL != pg->set_task)
681  {
683  pg->set_task = NULL;
684  }
686  "Removing old up preference generator peer [%u] address [%u] `%s'\n",
687  pg->peer, pg->address_id,
688  GNUNET_ATS_print_property_type(pg->ats_property));
689 
690  GNUNET_free (pg);
691 }
692 
693 
710 struct PropertyGenerator *
712  unsigned int address_id,
713  struct TestPeer *test_peer,
714  struct TestAddress *test_address,
715  enum GeneratorType type,
716  long int base_value,
717  long int value_rate,
718  struct GNUNET_TIME_Relative period,
720  uint32_t ats_property)
721 {
722  struct PropertyGenerator *pg;
723 
724  pg = GNUNET_new (struct PropertyGenerator);
725  GNUNET_CONTAINER_DLL_insert (prop_gen_head, prop_gen_tail, pg);
726  pg->type = type;
727  pg->peer = peer;
729  pg->test_peer = test_peer;
730  pg->address_id = address_id;
732  pg->base_value = base_value;
733  pg->max_value = value_rate;
734  pg->duration_period = period;
735  pg->frequency = frequency;
737 
738  switch (type) {
741  "Setting up %s property generator peer [%u] address [%u] `%s'"\
742  "max %u Bips\n",
743  print_generator_type(type), pg->peer, pg->address_id,
744  GNUNET_ATS_print_property_type (ats_property),
745  base_value);
746  break;
749  "Setting up %s property generator peer [%u] address [%u] `%s' " \
750  "min %u Bips max %u Bips\n",
751  print_generator_type(type), pg->peer, pg->address_id,
752  GNUNET_ATS_print_property_type(ats_property),
753  base_value, value_rate);
754  break;
757  "Setting up %s property generator peer [%u] address [%u] `%s' "\
758  "baserate %u Bips, amplitude %u Bps\n",
759  print_generator_type(type), pg->peer, pg->address_id,
760  GNUNET_ATS_print_property_type(ats_property),
761  base_value, value_rate);
762  break;
765  "Setting up %s property generator peer [%u] address [%u] `%s' "\
766  "min %u Bips max %u Bps\n",
767  print_generator_type(type), pg->peer, pg->address_id,
768  GNUNET_ATS_print_property_type(ats_property),
769  base_value, value_rate);
770  break;
771  default:
772  break;
773  }
774 
776  return pg;
777 }
778 
779 
783 void
785 {
786  struct PropertyGenerator *cur;
787  struct PropertyGenerator *next;
788  next = prop_gen_head;
789  for (cur = next; NULL != cur; cur = next)
790  {
791  next = cur->next;
793  }
794 }
795 
796 
802 
803 
804 static double
806 {
807  struct GNUNET_TIME_Relative time_delta;
808  double delta_value;
809  double pref_value;
810 
811  /* Calculate the current preference value */
812  switch (pg->type) {
814  pref_value = pg->base_value;
815  break;
818  /* Calculate point of time in the current period */
819  time_delta.rel_value_us = time_delta.rel_value_us %
821  delta_value = ((double) time_delta.rel_value_us /
823  if ((pg->max_value < pg->base_value) &&
824  ((pg->max_value - pg->base_value) > pg->base_value))
825  {
826  /* This will cause an underflow */
827  GNUNET_break (0);
828  }
829  pref_value = pg->base_value + delta_value;
830  break;
833  10000 * (pg->max_value - pg->base_value)) / 10000;
834  pref_value = pg->base_value + delta_value;
835  break;
838  /* Calculate point of time in the current period */
839  time_delta.rel_value_us = time_delta.rel_value_us %
841  if ((pg->max_value - pg->base_value) > pg->base_value)
842  {
843  /* This will cause an underflow for second half of sinus period,
844  * will be detected in general when experiments are loaded */
845  GNUNET_break (0);
846  }
847  delta_value = (pg->max_value - pg->base_value) *
848  sin ( (2 * M_PI) / ((double) pg->duration_period.rel_value_us) *
849  time_delta.rel_value_us);
850  pref_value = pg->base_value + delta_value;
851  break;
852  default:
853  pref_value = 0.0;
854  break;
855  }
856  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Current preference value is %f\n",
857  pref_value);
858  return pref_value;
859 }
860 
861 
862 static void
863 set_feedback_task (void *cls)
864 {
865  struct PreferenceGenerator *pg = cls;
866  struct TestPeer *p;
867  double feedback;
868  uint32_t bw_acc_out;
869  uint32_t bw_acc_in;
870  uint32_t delay_acc_in;
871  struct GNUNET_TIME_Relative dur;
872  double p_new;
873 
874  pg->feedback_task = NULL;
875 
876  if (NULL == (p = find_peer_by_id (pg->peer)))
877  {
878  GNUNET_break (0);
880  "Setting feedback for unknown peer %u\n", pg->peer);
881  return;
882  }
883 
884  switch (pg->kind)
885  {
888  bw_acc_in = dur.rel_value_us *pg->last_assigned_bw_in + pg->feedback_bw_in_acc;
889  pg->feedback_bw_in_acc = 0;
890 
891  bw_acc_out = dur.rel_value_us *pg->last_assigned_bw_out + pg->feedback_bw_out_acc;
892  p_new = get_preference (pg);
893  feedback = (p_new / pg->pref_bw_old) * (bw_acc_in + bw_acc_out) /
895 
896  break;
899  delay_acc_in =dur.rel_value_us *pg->last_delay_value + pg->feedback_delay_acc;
900  pg->feedback_delay_acc = 0;
901 
902  p_new = get_preference (pg);
903  feedback = (p_new / pg->pref_latency_old) * (delay_acc_in) /
905 
906  break;
907  default:
908  GNUNET_break (0);
909  feedback = 0.0;
910  break;
911  }
913  "Giving feedback for peer [%u] for client %p pref %s of %.3f\n",
914  pg->peer, NULL + (pg->client_id),
916  feedback);
917 
918  sh->sf->s_feedback (sh->sf->cls, NULL + (pg->client_id), &p->peer_id,
919  pg->feedback_frequency, pg->kind, feedback);
921 
922 
923  pg->feedback_bw_out_acc = 0;
924  pg->feedback_bw_in_acc = 0;
926 
927  pg->feedback_delay_acc = 0;
929 
930 
932  &set_feedback_task, pg);
933 }
934 
935 
936 static void
937 set_pref_task (void *cls)
938 {
939  struct PreferenceGenerator *pg = cls;
940  struct TestPeer *p;
941  double pref_value;
942  pg->set_task = NULL;
943 
944  if (NULL == (p = find_peer_by_id (pg->peer)))
945  {
946  GNUNET_break (0);
948  "Setting preference for unknown peer %u\n", pg->peer);
949  return;
950  }
951 
952  pref_value = get_preference (pg);
953  switch (pg->kind) {
955  pg->pref_bw_old = pref_value;
956  break;
958  pg->pref_latency_old = pref_value;
959  break;
960  default:
961  break;
962  }
963 
964  p->pref_abs[pg->kind] = pref_value;
965 
967  "Setting preference for peer [%u] for client %p pref %s to %f\n",
968  pg->peer, NULL + (pg->client_id),
969  GNUNET_ATS_print_preference_type (pg->kind), pref_value);
970 
972  {
973  p->pref_abs[pg->kind] = pref_value;
974  p->pref_norm[pg->kind] = pref_value;
975  sh->sf->s_pref (sh->sf->cls, &p->peer_id, pg->kind, pref_value);
976  }
977  else
978  update_preference (NULL + (pg->client_id),
979  &p->peer_id,
980  pg->kind,
981  pref_value);
982 
984  &set_pref_task,
985  pg);
986 }
987 
988 
989 static struct PreferenceGenerator *
991 {
992  struct PreferenceGenerator *cur;
993  for (cur = pref_gen_head; NULL != cur; cur = cur->next)
994  if (cur->peer == peer)
995  {
996  if ((cur->kind == kind) || (GNUNET_ATS_PREFERENCE_END == kind))
997  return cur;
998  }
999  return NULL;
1000 }
1001 
1002 void
1004 {
1005  GNUNET_CONTAINER_DLL_remove (pref_gen_head, pref_gen_tail, pg);
1006 
1007  if (NULL != pg->feedback_task)
1008  {
1010  pg->feedback_task = NULL;
1011  }
1012 
1013  if (NULL != pg->set_task)
1014  {
1016  pg->set_task = NULL;
1017  }
1019  "Removing old up preference generator peer [%u] `%s'\n",
1021 
1022  GNUNET_free (pg);
1023 }
1024 
1025 
1026 static struct TestAddress*
1028 {
1029  struct TestAddress *cur;
1030  for (cur = p->addr_head; NULL != cur; cur = cur->next)
1031  if (GNUNET_YES == cur->ats_addr->active)
1032  return cur;
1033  return NULL;
1034 }
1035 
1036 
1053 struct PreferenceGenerator *
1055  unsigned int address_id,
1056  unsigned int client_id,
1057  enum GeneratorType type,
1058  long int base_value,
1059  long int value_rate,
1060  struct GNUNET_TIME_Relative period,
1064 {
1065  struct PreferenceGenerator *pg;
1066  struct TestPeer *p;
1067 
1068  if (NULL == (p = find_peer_by_id (peer)))
1069  {
1070  GNUNET_break (0);
1072  "Starting preference for unknown peer %u\n", peer);
1073  return NULL;
1074  }
1075 
1076  pg = GNUNET_new (struct PreferenceGenerator);
1077  GNUNET_CONTAINER_DLL_insert (pref_gen_head, pref_gen_tail, pg);
1078  pg->type = type;
1079  pg->peer = peer;
1080  pg->client_id = client_id;
1081  pg->kind = kind;
1082  pg->base_value = base_value;
1083  pg->max_value = value_rate;
1084  pg->duration_period = period;
1085  pg->frequency = frequency;
1087  pg->feedback_frequency = feedback_frequency;
1088 
1089  switch (type) {
1092  "Setting up %s preference generator peer [%u] `%s' max %u Bips\n",
1093  print_generator_type (type), pg->peer,
1095  base_value);
1096  break;
1099  "Setting up %s preference generator peer [%u] `%s' min %u Bips max %u Bips\n",
1101  base_value, value_rate);
1102  break;
1105  "Setting up %s preference generator peer [%u] `%s' baserate %u Bips, amplitude %u Bps\n",
1107  base_value, value_rate);
1108  break;
1111  "Setting up %s preference generator peer [%u] `%s' min %u Bips max %u Bps\n",
1113  base_value, value_rate);
1114  break;
1115  default:
1116  break;
1117  }
1118 
1120  if (GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us != feedback_frequency.rel_value_us)
1121  {
1122  struct TestAddress * addr = find_active_address(p);
1123 
1126  pg->feedback_bw_in_acc = 0;
1127  pg->feedback_bw_out_acc = 0;
1128  pg->last_delay_value = addr->prop_norm[GNUNET_ATS_QUALITY_NET_DELAY];
1129  pg->feedback_delay_acc = 0;
1130 
1134  pg->feedback_task = GNUNET_SCHEDULER_add_delayed (feedback_frequency,
1135  &set_feedback_task, pg);
1136  }
1137 
1138  return pg;
1139 }
1140 
1141 
1142 
1146 void
1148 {
1149  struct PreferenceGenerator *cur;
1150  struct PreferenceGenerator *next;
1151  next = pref_gen_head;
1152  for (cur = next; NULL != cur; cur = next)
1153  {
1154  next = cur->next;
1156  }
1157 }
1158 
1159 
1160 
1164 static const char *
1166 {
1167  switch (op) {
1168  case SOLVER_OP_ADD_ADDRESS:
1169  return "ADD_ADDRESS";
1170  case SOLVER_OP_DEL_ADDRESS:
1171  return "DEL_ADDRESS";
1173  return "START_SET_PREFERENCE";
1175  return "STOP_STOP_PREFERENCE";
1177  return "START_SET_PROPERTY";
1179  return "STOP_SET_PROPERTY";
1181  return "START_REQUEST";
1183  return "STOP_REQUEST";
1184  default:
1185  break;
1186  }
1187  return "";
1188 }
1189 
1190 
1191 static struct Experiment *
1193 {
1194  struct Experiment *e;
1195  e = GNUNET_new (struct Experiment);
1196  e->name = NULL;
1197  e->start = NULL;
1199  return e;
1200 }
1201 
1202 
1203 static void
1205 {
1206  struct Episode *cur;
1207  struct Episode *next;
1208  struct GNUNET_ATS_TEST_Operation *cur_o;
1209  struct GNUNET_ATS_TEST_Operation *next_o;
1210 
1211  next = e->start;
1212  for (cur = next; NULL != cur; cur = next)
1213  {
1214  next = cur->next;
1215 
1216  next_o = cur->head;
1217  for (cur_o = next_o; NULL != cur_o; cur_o = next_o)
1218  {
1219  next_o = cur_o->next;
1220  GNUNET_free_non_null (cur_o->address);
1221  GNUNET_free_non_null (cur_o->plugin);
1222  GNUNET_free (cur_o);
1223  }
1224  GNUNET_free (cur);
1225  }
1226 
1231  GNUNET_free (e);
1232 }
1233 
1234 
1235 static int
1237  struct Episode *e,
1238  int op_counter,
1239  char *sec_name,
1240  const struct GNUNET_CONFIGURATION_Handle *cfg)
1241 {
1242  char *op_name;
1243  char *op_network;
1244 
1245  /* peer pid */
1246  GNUNET_asprintf(&op_name, "op-%u-peer-id", op_counter);
1248  sec_name, op_name, &o->peer_id))
1249  {
1250  fprintf (stderr, "Missing peer-id in operation %u `%s' in episode `%s'\n",
1251  op_counter, "ADD_ADDRESS", op_name);
1252  GNUNET_free (op_name);
1253  return GNUNET_SYSERR;
1254  }
1255  GNUNET_free (op_name);
1256 
1257  /* address pid */
1258  GNUNET_asprintf(&op_name, "op-%u-address-id", op_counter);
1260  sec_name, op_name, &o->address_id))
1261  {
1262  fprintf (stderr, "Missing address-id in operation %u `%s' in episode `%s'\n",
1263  op_counter, "ADD_ADDRESS", op_name);
1264  GNUNET_free (op_name);
1265  return GNUNET_SYSERR;
1266  }
1267  GNUNET_free (op_name);
1268 
1269  /* plugin */
1270  GNUNET_asprintf(&op_name, "op-%u-plugin", op_counter);
1272  sec_name, op_name, &o->plugin))
1273  {
1274  fprintf (stderr, "Missing plugin in operation %u `%s' in episode `%s'\n",
1275  op_counter, "ADD_ADDRESS", op_name);
1276  GNUNET_free (op_name);
1277  return GNUNET_SYSERR;
1278  }
1279  GNUNET_free (op_name);
1280 
1281  /* address */
1282  GNUNET_asprintf(&op_name, "op-%u-address", op_counter);
1284  sec_name, op_name, &o->address))
1285  {
1286  fprintf (stderr, "Missing address in operation %u `%s' in episode `%s'\n",
1287  op_counter, "ADD_ADDRESS", op_name);
1288  GNUNET_free (op_name);
1289  return GNUNET_SYSERR;
1290  }
1291  GNUNET_free (op_name);
1292 
1293  /* session */
1294  GNUNET_asprintf(&op_name, "op-%u-address-session", op_counter);
1296  sec_name, op_name, &o->address_session))
1297  {
1298  fprintf (stderr, "Missing address-session in operation %u `%s' in episode `%s'\n",
1299  op_counter, "ADD_ADDRESS", op_name);
1300  GNUNET_free (op_name);
1301  return GNUNET_SYSERR;
1302  }
1303  GNUNET_free (op_name);
1304 
1305  /* network */
1306  GNUNET_asprintf(&op_name, "op-%u-address-network", op_counter);
1308  sec_name, op_name, &op_network))
1309  {
1310  fprintf (stderr, "Missing address-network in operation %u `%s' in episode `%s'\n",
1311  op_counter, "ADD_ADDRESS", op_name);
1312  GNUNET_free (op_name);
1313  return GNUNET_SYSERR;
1314  }
1315  else
1316  {
1317  GNUNET_STRINGS_utf8_toupper (op_network,op_network);
1318  if (0 == strcmp(op_network, "UNSPECIFIED"))
1319  {
1321  }
1322  else if (0 == strcmp(op_network, "LOOPBACK"))
1323  {
1325  }
1326  else if (0 == strcmp(op_network, "LAN"))
1327  {
1329  }
1330  else if (0 == strcmp(op_network, "WAN"))
1331  {
1333  }
1334  else if (0 == strcmp(op_network, "WLAN"))
1335  {
1337  }
1338  else if (0 == strcmp(op_network, "BT"))
1339  {
1341  }
1342  else
1343  {
1344  fprintf (stderr, "Invalid address-network in operation %u `%s' in episode `%s': `%s'\n",
1345  op_counter, "ADD_ADDRESS", op_name, op_network);
1346  GNUNET_free (op_network);
1347  GNUNET_free (op_name);
1348  return GNUNET_SYSERR;
1349  }
1350  }
1351  GNUNET_free (op_network);
1352  GNUNET_free (op_name);
1353 
1355  "Found operation %s: [%llu:%llu] address `%s' plugin `%s' \n",
1356  "ADD_ADDRESS", o->peer_id, o->address_id, o->address, o->plugin);
1357 
1358  return GNUNET_OK;
1359 }
1360 
1361 
1362 static int
1364  struct Episode *e,
1365  int op_counter,
1366  char *sec_name,
1367  const struct GNUNET_CONFIGURATION_Handle *cfg)
1368 {
1369  char *op_name;
1370  //char *op_network;
1371 
1372  /* peer pid */
1373  GNUNET_asprintf(&op_name, "op-%u-peer-id", op_counter);
1375  sec_name, op_name, &o->peer_id))
1376  {
1377  fprintf (stderr, "Missing peer-id in operation %u `%s' in episode `%s'\n",
1378  op_counter, "DEL_ADDRESS", op_name);
1379  GNUNET_free (op_name);
1380  return GNUNET_SYSERR;
1381  }
1382  GNUNET_free (op_name);
1383 
1384  /* address pid */
1385  GNUNET_asprintf(&op_name, "op-%u-address-id", op_counter);
1387  sec_name, op_name, &o->address_id))
1388  {
1389  fprintf (stderr, "Missing address-id in operation %u `%s' in episode `%s'\n",
1390  op_counter, "DEL_ADDRESS", op_name);
1391  GNUNET_free (op_name);
1392  return GNUNET_SYSERR;
1393  }
1394  GNUNET_free (op_name);
1395 
1396 #if 0
1397  /* plugin */
1398  GNUNET_asprintf(&op_name, "op-%u-plugin", op_counter);
1400  sec_name, op_name, &o->plugin))
1401  {
1402  fprintf (stderr, "Missing plugin in operation %u `%s' in episode `%s'\n",
1403  op_counter, "DEL_ADDRESS", op_name);
1404  GNUNET_free (op_name);
1405  return GNUNET_SYSERR;
1406  }
1407  GNUNET_free (op_name);
1408 
1409  /* address */
1410  GNUNET_asprintf(&op_name, "op-%u-address", op_counter);
1412  sec_name, op_name, &o->address))
1413  {
1414  fprintf (stderr, "Missing address in operation %u `%s' in episode `%s'\n",
1415  op_counter, "DEL_ADDRESS", op_name);
1416  GNUNET_free (op_name);
1417  return GNUNET_SYSERR;
1418  }
1419  GNUNET_free (op_name);
1420 
1421  /* session */
1422  GNUNET_asprintf(&op_name, "op-%u-address-session", op_counter);
1424  sec_name, op_name, &o->address_session))
1425  {
1426  fprintf (stderr, "Missing address-session in operation %u `%s' in episode `%s'\n",
1427  op_counter, "DEL_ADDRESS", op_name);
1428  GNUNET_free (op_name);
1429  return GNUNET_SYSERR;
1430  }
1431  GNUNET_free (op_name);
1432 #endif
1433 
1435  "Found operation %s: [%llu:%llu] address `%s' plugin `%s' \n",
1436  "DEL_ADDRESS", o->peer_id, o->address_id, o->address, o->plugin);
1437 
1438  return GNUNET_OK;
1439 }
1440 
1441 
1442 static enum GNUNET_ATS_Property
1443 parse_preference_string (const char * str)
1444 {
1445  int c = 0;
1446  char *props[GNUNET_ATS_PreferenceCount] = GNUNET_ATS_PreferenceTypeString;
1447 
1448  for (c = 0; c < GNUNET_ATS_PreferenceCount; c++)
1449  if (0 == strcmp(str, props[c]))
1450  return c;
1451  return 0;
1452 }
1453 
1454 
1455 static int
1457  struct Episode *e,
1458  int op_counter,
1459  char *sec_name,
1460  const struct GNUNET_CONFIGURATION_Handle *cfg)
1461 {
1462  char *op_name;
1463  char *type;
1464  char *pref;
1465 
1466  /* peer pid */
1467  GNUNET_asprintf(&op_name, "op-%u-peer-id", op_counter);
1469  sec_name, op_name, &o->peer_id))
1470  {
1471  fprintf (stderr, "Missing peer-id in operation %u `%s' in episode `%s'\n",
1472  op_counter, "START_SET_PREFERENCE", op_name);
1473  GNUNET_free (op_name);
1474  return GNUNET_SYSERR;
1475  }
1476  GNUNET_free (op_name);
1477 
1478  /* address pid */
1479  GNUNET_asprintf(&op_name, "op-%u-client-id", op_counter);
1481  sec_name, op_name, &o->client_id))
1482  {
1483  fprintf (stderr, "Missing client-id in operation %u `%s' in episode `%s'\n",
1484  op_counter, "START_SET_PREFERENCE", op_name);
1485  GNUNET_free (op_name);
1486  return GNUNET_SYSERR;
1487  }
1488  GNUNET_free (op_name);
1489 
1490  /* generator */
1491  GNUNET_asprintf(&op_name, "op-%u-gen-type", op_counter);
1493  sec_name, op_name, &type)) )
1494  {
1495  fprintf (stderr, "Missing type in operation %u `%s' in episode `%s'\n",
1496  op_counter, "START_SET_PREFERENCE", op_name);
1497  GNUNET_free (op_name);
1498  return GNUNET_SYSERR;
1499  }
1500 
1501  /* Load arguments for set_rate, start_send, set_preference */
1502  if (0 == strcmp (type, "constant"))
1503  {
1505  }
1506  else if (0 == strcmp (type, "linear"))
1507  {
1509  }
1510  else if (0 == strcmp (type, "sinus"))
1511  {
1513  }
1514  else if (0 == strcmp (type, "random"))
1515  {
1517  }
1518  else
1519  {
1520  fprintf (stderr, "Invalid generator type %u `%s' in episode %u\n",
1521  op_counter, op_name, e->id);
1522  GNUNET_free (type);
1523  GNUNET_free (op_name);
1524  return GNUNET_SYSERR;
1525  }
1526  GNUNET_free (type);
1527  GNUNET_free (op_name);
1528 
1529 
1530  /* Get base rate */
1531  GNUNET_asprintf(&op_name, "op-%u-base-rate", op_counter);
1533  sec_name, op_name, &o->base_rate))
1534  {
1535  fprintf (stderr, "Missing base rate in operation %u `%s' in episode %u\n",
1536  op_counter, op_name, e->id);
1537  GNUNET_free (op_name);
1538  return GNUNET_SYSERR;
1539  }
1540  GNUNET_free (op_name);
1541 
1542 
1543  /* Get max rate */
1544  GNUNET_asprintf(&op_name, "op-%u-max-rate", op_counter);
1546  sec_name, op_name, &o->max_rate))
1547  {
1548  if ((GNUNET_ATS_TEST_TG_LINEAR == o->gen_type) ||
1551  {
1552  fprintf (stderr, "Missing max rate in operation %u `%s' in episode %u\n",
1553  op_counter, op_name, e->id);
1554  GNUNET_free (op_name);
1555  return GNUNET_SYSERR;
1556  }
1557  }
1558  GNUNET_free (op_name);
1559 
1560  /* Get period */
1561  GNUNET_asprintf(&op_name, "op-%u-period", op_counter);
1563  sec_name, op_name, &o->period))
1564  {
1565  o->period = e->duration;
1566  }
1567  GNUNET_free (op_name);
1568 
1569  /* Get frequency */
1570  GNUNET_asprintf(&op_name, "op-%u-frequency", op_counter);
1572  sec_name, op_name, &o->frequency))
1573  {
1574  fprintf (stderr, "Missing frequency in operation %u `%s' in episode %u\n",
1575  op_counter, op_name, e->id);
1576  GNUNET_free (op_name);
1577  return GNUNET_SYSERR;
1578  }
1579  GNUNET_free (op_name);
1580 
1581  /* Get preference */
1582  GNUNET_asprintf(&op_name, "op-%u-pref", op_counter);
1584  sec_name, op_name, &pref))
1585  {
1586  fprintf (stderr, "Missing preference in operation %u `%s' in episode %u\n",
1587  op_counter, op_name, e->id);
1588  GNUNET_free (op_name);
1589  return GNUNET_SYSERR;
1590  }
1591 
1592  if (0 == (o->pref_type = parse_preference_string(pref)))
1593  {
1594  fprintf (stderr, "Invalid preference in operation %u `%s' in episode %u\n",
1595  op_counter, op_name, e->id);
1596  GNUNET_free (op_name);
1597  GNUNET_free (pref);
1598  return GNUNET_SYSERR;
1599  }
1600  GNUNET_free (pref);
1601  GNUNET_free (op_name);
1602 
1603  /* Get feedback delay */
1604  GNUNET_asprintf(&op_name, "op-%u-feedback_delay", op_counter);
1606  sec_name, op_name, &o->feedback_delay))
1607  {
1608  fprintf (stderr, "Using feedback delay %llu in operation %u `%s' in episode %u\n",
1609  (long long unsigned int) o->feedback_delay.rel_value_us,
1610  op_counter, op_name, e->id);
1611  }
1612  else
1614  GNUNET_free (op_name);
1615 
1617  "Found operation %s: [%llu:%llu]: %s = %llu\n",
1618  "START_SET_PREFERENCE", o->peer_id, o->address_id,
1620 
1621  return GNUNET_OK;
1622 }
1623 
1624 
1625 static int
1627  struct Episode *e,
1628  int op_counter,
1629  char *sec_name,
1630  const struct GNUNET_CONFIGURATION_Handle *cfg)
1631 {
1632  char *op_name;
1633  char *pref;
1634 
1635  /* peer pid */
1636  GNUNET_asprintf(&op_name, "op-%u-peer-id", op_counter);
1638  sec_name, op_name, &o->peer_id))
1639  {
1640  fprintf (stderr, "Missing peer-id in operation %u `%s' in episode `%s'\n",
1641  op_counter, "STOP_SET_PREFERENCE", op_name);
1642  GNUNET_free (op_name);
1643  return GNUNET_SYSERR;
1644  }
1645  GNUNET_free (op_name);
1646 
1647  /* address pid */
1648  GNUNET_asprintf(&op_name, "op-%u-address-id", op_counter);
1650  sec_name, op_name, &o->address_id))
1651  {
1652  fprintf (stderr, "Missing address-id in operation %u `%s' in episode `%s'\n",
1653  op_counter, "STOP_SET_PREFERENCE", op_name);
1654  GNUNET_free (op_name);
1655  return GNUNET_SYSERR;
1656  }
1657  GNUNET_free (op_name);
1658 
1659  /* Get preference */
1660  GNUNET_asprintf(&op_name, "op-%u-pref", op_counter);
1662  sec_name, op_name, &pref))
1663  {
1664  fprintf (stderr, "Missing preference in operation %u `%s' in episode `%s'\n",
1665  op_counter, "STOP_SET_PREFERENCE", op_name);
1666  GNUNET_free (op_name);
1667  return GNUNET_SYSERR;
1668  }
1669 
1670  if (0 == (o->pref_type = parse_preference_string(pref)))
1671  {
1672  fprintf (stderr, "Invalid preference in operation %u `%s' in episode %u\n",
1673  op_counter, op_name, e->id);
1674  GNUNET_free (op_name);
1675  GNUNET_free (pref);
1676  return GNUNET_SYSERR;
1677  }
1678  GNUNET_free (pref);
1679  GNUNET_free (op_name);
1680 
1682  "Found operation %s: [%llu:%llu]: %s\n",
1683  "STOP_SET_PREFERENCE", o->peer_id, o->address_id,
1685  return GNUNET_OK;
1686 }
1687 
1688 
1689 static enum GNUNET_ATS_Property
1690 parse_property_string (const char *str)
1691 {
1692  enum GNUNET_ATS_Property c;
1693 
1694  for (c = 0; c < GNUNET_ATS_PropertyCount; c++)
1695  if (0 == strcmp(str,
1696  GNUNET_ATS_print_property_type (c)))
1697  return c;
1698  return 0;
1699 }
1700 
1701 
1702 static int
1704  struct Episode *e,
1705  int op_counter,
1706  char *sec_name,
1707  const struct GNUNET_CONFIGURATION_Handle *cfg)
1708 {
1709  char *op_name;
1710  char *type;
1711  char *prop;
1712 
1713  /* peer pid */
1714  GNUNET_asprintf(&op_name, "op-%u-peer-id", op_counter);
1716  sec_name, op_name, &o->peer_id))
1717  {
1718  fprintf (stderr, "Missing peer-id in operation %u `%s' in episode `%s'\n",
1719  op_counter, "START_SET_PROPERTY", op_name);
1720  GNUNET_free (op_name);
1721  return GNUNET_SYSERR;
1722  }
1723  GNUNET_free (op_name);
1724 
1725  /* address pid */
1726  GNUNET_asprintf(&op_name, "op-%u-address-id", op_counter);
1728  sec_name, op_name, &o->address_id))
1729  {
1730  fprintf (stderr, "Missing address-id in operation %u `%s' in episode `%s'\n",
1731  op_counter, "START_SET_PROPERTY", op_name);
1732  GNUNET_free (op_name);
1733  return GNUNET_SYSERR;
1734  }
1735  GNUNET_free (op_name);
1736 
1737  /* generator */
1738  GNUNET_asprintf(&op_name, "op-%u-gen-type", op_counter);
1740  sec_name, op_name, &type)) )
1741  {
1742  fprintf (stderr, "Missing type in operation %u `%s' in episode `%s'\n",
1743  op_counter, "START_SET_PROPERTY", op_name);
1744  GNUNET_free (op_name);
1745  return GNUNET_SYSERR;
1746  }
1747 
1748  /* Load arguments for set_rate, start_send, set_preference */
1749  if (0 == strcmp (type, "constant"))
1750  {
1752  }
1753  else if (0 == strcmp (type, "linear"))
1754  {
1756  }
1757  else if (0 == strcmp (type, "sinus"))
1758  {
1760  }
1761  else if (0 == strcmp (type, "random"))
1762  {
1764  }
1765  else
1766  {
1767  fprintf (stderr, "Invalid generator type %u `%s' in episode %u\n",
1768  op_counter, op_name, e->id);
1769  GNUNET_free (type);
1770  GNUNET_free (op_name);
1771  return GNUNET_SYSERR;
1772  }
1773  GNUNET_free (type);
1774  GNUNET_free (op_name);
1775 
1776 
1777  /* Get base rate */
1778  GNUNET_asprintf(&op_name, "op-%u-base-rate", op_counter);
1780  sec_name, op_name, &o->base_rate))
1781  {
1782  fprintf (stderr, "Missing base rate in operation %u `%s' in episode %u\n",
1783  op_counter, op_name, e->id);
1784  GNUNET_free (op_name);
1785  return GNUNET_SYSERR;
1786  }
1787  GNUNET_free (op_name);
1788 
1789 
1790  /* Get max rate */
1791  GNUNET_asprintf(&op_name, "op-%u-max-rate", op_counter);
1793  sec_name, op_name, &o->max_rate))
1794  {
1795  if ((GNUNET_ATS_TEST_TG_LINEAR == o->gen_type) ||
1798  {
1799  fprintf (stderr, "Missing max rate in operation %u `%s' in episode %u\n",
1800  op_counter, op_name, e->id);
1801  GNUNET_free (op_name);
1802  return GNUNET_SYSERR;
1803  }
1804  }
1805  GNUNET_free (op_name);
1806 
1807  /* Get period */
1808  GNUNET_asprintf(&op_name, "op-%u-period", op_counter);
1810  sec_name, op_name, &o->period))
1811  {
1812  o->period = e->duration;
1813  }
1814  GNUNET_free (op_name);
1815 
1816  /* Get frequency */
1817  GNUNET_asprintf(&op_name, "op-%u-frequency", op_counter);
1819  sec_name, op_name, &o->frequency))
1820  {
1821  fprintf (stderr, "Missing frequency in operation %u `%s' in episode %u\n",
1822  op_counter, op_name, e->id);
1823  GNUNET_free (op_name);
1824  return GNUNET_SYSERR;
1825  }
1826  GNUNET_free (op_name);
1827 
1828  /* Get preference */
1829  GNUNET_asprintf(&op_name, "op-%u-property", op_counter);
1831  sec_name, op_name, &prop))
1832  {
1833  fprintf (stderr, "Missing property in operation %u `%s' in episode %u\n",
1834  op_counter, op_name, e->id);
1835  GNUNET_free (op_name);
1836  GNUNET_free_non_null (prop);
1837  return GNUNET_SYSERR;
1838  }
1839 
1840  if (0 == (o->prop_type = parse_property_string(prop)))
1841  {
1842  fprintf (stderr, "Invalid property in operation %u `%s' in episode %u\n",
1843  op_counter, op_name, e->id);
1844  GNUNET_free (op_name);
1845  GNUNET_free (prop);
1846  return GNUNET_SYSERR;
1847  }
1848 
1849  GNUNET_free (prop);
1850  GNUNET_free (op_name);
1851 
1853  "Found operation %s: [%llu:%llu] %s = %llu\n",
1854  "START_SET_PROPERTY", o->peer_id, o->address_id,
1855  GNUNET_ATS_print_property_type (o->prop_type), o->base_rate);
1856 
1857  return GNUNET_OK;
1858 }
1859 
1860 static int
1862  struct Episode *e,
1863  int op_counter,
1864  char *sec_name,
1865  const struct GNUNET_CONFIGURATION_Handle *cfg)
1866 {
1867  char *op_name;
1868  char *pref;
1869 
1870  /* peer pid */
1871  GNUNET_asprintf(&op_name, "op-%u-peer-id", op_counter);
1873  sec_name, op_name, &o->peer_id))
1874  {
1875  fprintf (stderr, "Missing peer-id in operation %u `%s' in episode `%s'\n",
1876  op_counter, "STOP_SET_PROPERTY", op_name);
1877  GNUNET_free (op_name);
1878  return GNUNET_SYSERR;
1879  }
1880  GNUNET_free (op_name);
1881 
1882  /* address pid */
1883  GNUNET_asprintf(&op_name, "op-%u-address-id", op_counter);
1885  sec_name, op_name, &o->address_id))
1886  {
1887  fprintf (stderr, "Missing address-id in operation %u `%s' in episode `%s'\n",
1888  op_counter, "STOP_SET_PROPERTY", op_name);
1889  GNUNET_free (op_name);
1890  return GNUNET_SYSERR;
1891  }
1892  GNUNET_free (op_name);
1893 
1894  /* Get property */
1895  GNUNET_asprintf(&op_name, "op-%u-property", op_counter);
1897  sec_name, op_name, &pref))
1898  {
1899  fprintf (stderr, "Missing property in operation %u `%s' in episode `%s'\n",
1900  op_counter, "STOP_SET_PROPERTY", op_name);
1901  GNUNET_free (op_name);
1902  GNUNET_free_non_null (pref);
1903  return GNUNET_SYSERR;
1904  }
1905 
1906  if (0 == (o->prop_type = parse_property_string(pref)))
1907  {
1908  fprintf (stderr, "Invalid property in operation %u `%s' in episode %u\n",
1909  op_counter, op_name, e->id);
1910  GNUNET_free (op_name);
1911  GNUNET_free_non_null (pref);
1912  return GNUNET_SYSERR;
1913  }
1914 
1915  GNUNET_free (pref);
1916  GNUNET_free (op_name);
1917 
1919  "Found operation %s: [%llu:%llu] %s\n",
1920  "STOP_SET_PROPERTY", o->peer_id, o->address_id,
1921  GNUNET_ATS_print_property_type (o->prop_type));
1922 
1923  return GNUNET_OK;
1924 }
1925 
1926 
1927 static int
1929  struct Episode *e,
1930  int op_counter,
1931  char *sec_name,
1932  const struct GNUNET_CONFIGURATION_Handle *cfg)
1933 {
1934  char *op_name;
1935 
1936  /* peer pid */
1937  GNUNET_asprintf(&op_name, "op-%u-peer-id", op_counter);
1939  sec_name, op_name, &o->peer_id))
1940  {
1941  fprintf (stderr, "Missing peer-id in operation %u `%s' in episode `%s'\n",
1942  op_counter, "START_REQUEST", op_name);
1943  GNUNET_free (op_name);
1944  return GNUNET_SYSERR;
1945  }
1946  GNUNET_free (op_name);
1947  return GNUNET_OK;
1948 }
1949 
1950 static int
1952  struct Episode *e,
1953  int op_counter,
1954  char *sec_name,
1955  const struct GNUNET_CONFIGURATION_Handle *cfg)
1956 {
1957  char *op_name;
1958 
1959  /* peer pid */
1960  GNUNET_asprintf(&op_name, "op-%u-peer-id", op_counter);
1962  sec_name, op_name, &o->peer_id))
1963  {
1964  fprintf (stderr, "Missing peer-id in operation %u `%s' in episode `%s'\n",
1965  op_counter, "STOP_REQUEST", op_name);
1966  GNUNET_free (op_name);
1967  return GNUNET_SYSERR;
1968  }
1969  GNUNET_free (op_name);
1970  return GNUNET_OK;
1971 }
1972 
1973 
1974 static int
1975 load_episode (struct Experiment *e, struct Episode *cur,
1977 {
1978  struct GNUNET_ATS_TEST_Operation *o;
1979  char *sec_name;
1980  char *op_name;
1981  char *op;
1982  int op_counter = 0;
1983  int res;
1984  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "=== Parsing episode %u\n",cur->id);
1985  GNUNET_asprintf(&sec_name, "episode-%u", cur->id);
1986 
1987  while (1)
1988  {
1989  /* Load operation */
1990  GNUNET_asprintf(&op_name, "op-%u-operation", op_counter);
1992  sec_name, op_name, &op))
1993  {
1994  GNUNET_free (op_name);
1995  break;
1996  }
1998  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "==== Parsing operation %u: `%s'\n",
1999  cur->id, op_name);
2000 
2001  /* operations = set_rate, start_send, stop_send, set_preference */
2002  if (0 == strcmp (op, "address_add"))
2003  {
2005  res = load_op_add_address (o, cur,
2006  op_counter, sec_name, cfg);
2007  }
2008  else if (0 == strcmp (op, "address_del"))
2009  {
2011  res = load_op_del_address (o, cur,
2012  op_counter, sec_name, cfg);
2013  }
2014  else if (0 == strcmp (op, "start_set_property"))
2015  {
2017  res = load_op_start_set_property (o, cur,
2018  op_counter, sec_name, cfg);
2019  }
2020  else if (0 == strcmp (op, "stop_set_property"))
2021  {
2023  res = load_op_stop_set_property (o, cur,
2024  op_counter, sec_name, cfg);
2025  }
2026  else if (0 == strcmp (op, "start_set_preference"))
2027  {
2029  res = load_op_start_set_preference (o, cur,
2030  op_counter, sec_name, cfg);
2031  }
2032  else if (0 == strcmp (op, "stop_set_preference"))
2033  {
2035  res = load_op_stop_set_preference (o, cur,
2036  op_counter, sec_name, cfg);
2037  }
2038  else if (0 == strcmp (op, "start_request"))
2039  {
2041  res = load_op_start_request (o, cur,
2042  op_counter, sec_name, cfg);
2043  }
2044  else if (0 == strcmp (op, "stop_request"))
2045  {
2047  res = load_op_stop_request(o, cur,
2048  op_counter, sec_name, cfg);
2049  }
2050  else
2051  {
2052  fprintf (stderr, "Invalid operation %u `%s' in episode %u\n",
2053  op_counter, op, cur->id);
2054  res = GNUNET_SYSERR;
2055  }
2056 
2057  GNUNET_free (op);
2058  GNUNET_free (op_name);
2059 
2060  if (GNUNET_SYSERR == res)
2061  {
2062  GNUNET_free (o);
2063  GNUNET_free (sec_name);
2064  return GNUNET_SYSERR;
2065  }
2066 
2068  op_counter++;
2069  }
2070  GNUNET_free (sec_name);
2071  return GNUNET_OK;
2072 }
2073 
2074 static int
2076 {
2077  int e_counter = 0;
2078  char *sec_name;
2079  struct GNUNET_TIME_Relative e_duration;
2080  struct Episode *cur;
2081  struct Episode *last;
2082 
2083  e_counter = 0;
2084  last = NULL;
2085  while (1)
2086  {
2087  GNUNET_asprintf(&sec_name, "episode-%u", e_counter);
2089  sec_name, "duration", &e_duration))
2090  {
2091  GNUNET_free (sec_name);
2092  break;
2093  }
2094 
2095  cur = GNUNET_new (struct Episode);
2096  cur->duration = e_duration;
2097  cur->id = e_counter;
2098 
2099  if (GNUNET_OK != load_episode (e, cur, cfg))
2100  {
2101  GNUNET_free (sec_name);
2102  GNUNET_free (cur);
2103  return GNUNET_SYSERR;
2104  }
2105 
2106  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Found episode %u with duration %s \n",
2107  e_counter,
2109 
2110  /* Update experiment */
2111  e->num_episodes ++;
2113  /* Put in linked list */
2114  if (NULL == last)
2115  e->start = cur;
2116  else
2117  last->next = cur;
2118 
2119  GNUNET_free (sec_name);
2120  e_counter ++;
2121  last = cur;
2122  }
2123  return e_counter;
2124 }
2125 
2126 
2127 static void
2129 {
2130  struct Experiment *e = cls;
2131 
2132  e->experiment_timeout_task = NULL;
2133  fprintf (stderr, "Experiment timeout!\n");
2134 
2135  if (NULL != e->episode_timeout_task)
2136  {
2138  e->episode_timeout_task = NULL;
2139  }
2140 
2142  GNUNET_SYSERR);
2143 }
2144 
2145 struct ATS_Address *
2147  const char *plugin_name,
2148  const void *plugin_addr,
2149  size_t plugin_addr_len,
2150  uint32_t session_id,
2151  uint32_t network)
2152 {
2153  struct ATS_Address *aa = NULL;
2154 
2155  aa = GNUNET_malloc (sizeof (struct ATS_Address) + plugin_addr_len + strlen (plugin_name) + 1);
2156  aa->atsi = GNUNET_new (struct GNUNET_ATS_Information);
2157  aa->atsi[0].type = htonl (GNUNET_ATS_NETWORK_TYPE);
2158  aa->atsi[0].value = htonl (network);
2159  aa->atsi_count = 1;
2160 
2161  aa->peer = *peer;
2162  aa->addr_len = plugin_addr_len;
2163  aa->addr = &aa[1];
2164  aa->plugin = (char *) &aa[1] + plugin_addr_len;
2165  GNUNET_memcpy (&aa[1], plugin_addr, plugin_addr_len);
2166  GNUNET_memcpy (aa->plugin, plugin_name, strlen (plugin_name) + 1);
2167  aa->session_id = session_id;
2168 
2169  return aa;
2170 }
2171 
2172 
2173 
2174 static void
2176 {
2177  struct TestPeer *p;
2178  struct TestAddress *a;
2179  int c;
2180 
2181  if (NULL == (p = find_peer_by_id (op->peer_id)))
2182  {
2183  p = GNUNET_new (struct TestPeer);
2184  p->id = op->peer_id;
2185  p->assigned_bw_in = 0;
2186  p->assigned_bw_out = 0;
2187  memset (&p->peer_id, op->peer_id, sizeof (p->peer_id));
2188  for (c = 0; c < GNUNET_ATS_PreferenceCount; c++)
2189  {
2192  }
2193 
2194  GNUNET_CONTAINER_DLL_insert (peer_head, peer_tail, p);
2195  }
2196 
2197  if (NULL != (find_address_by_id (p, op->address_id)))
2198  {
2199  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Duplicate address %u for peer %u\n",
2200  op->address_id, op->peer_id);
2201  return;
2202  }
2203 
2204  a = GNUNET_new (struct TestAddress);
2205  a->aid = op->address_id;
2206  a->network = op->address_network;
2207  a->ats_addr = create_ats_address (&p->peer_id, op->plugin, op->address,
2208  strlen (op->address) + 1, op->address_session, op->address_network);
2209  memset (&p->peer_id, op->peer_id, sizeof (p->peer_id));
2211 
2212  for (c = 0; c < GNUNET_ATS_PropertyCount; c++)
2214 
2217 
2218  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Adding address %u for peer %u in network `%s'\n",
2220 
2221  sh->sf->s_add (sh->sf->cls, a->ats_addr, op->address_network);
2222 
2223 }
2224 
2225 
2226 static void
2228 {
2229  struct TestPeer *p;
2230  struct TestAddress *a;
2231  struct PropertyGenerator *pg;
2232 
2233  if (NULL == (p = find_peer_by_id (op->peer_id)))
2234  {
2235  GNUNET_break (0);
2237  "Deleting address for unknown peer %u\n", op->peer_id);
2238  return;
2239  }
2240 
2241  if (NULL == (a =find_address_by_id (p, op->address_id)))
2242  {
2243  GNUNET_break (0);
2245  "Deleting address for unknown peer %u\n", op->peer_id);
2246  return;
2247  }
2248 
2249  while (NULL != (pg = find_prop_gen (p->id, a->aid, 0)))
2250  {
2252  }
2253 
2256  &p->peer_id,
2257  a->ats_addr));
2259  "Removing address %u for peer %u\n",
2260  op->address_id,
2261  op->peer_id);
2262 
2263  sh->sf->s_del (sh->sf->cls, a->ats_addr);
2264 
2265  if (NULL != l)
2266  {
2268  }
2270 
2271  GNUNET_free_non_null(a->ats_addr->atsi);
2272  GNUNET_free (a->ats_addr);
2273  GNUNET_free (a);
2274 
2275 }
2276 
2277 static void
2279 {
2280  struct PropertyGenerator *pg;
2281  struct TestPeer *p;
2282  struct TestAddress *a;
2283 
2284  if (NULL != (pg = find_prop_gen (op->peer_id, op->address_id, op->prop_type)))
2285  {
2287  GNUNET_free (pg);
2288  }
2289 
2290  if (NULL == (p = find_peer_by_id (op->peer_id)))
2291  {
2292  GNUNET_break (0);
2294  "Starting property generation for unknown peer %u\n", op->peer_id);
2295  return;
2296  }
2297 
2298  if (NULL == (a = find_address_by_id (p, op->address_id)))
2299  {
2300  GNUNET_break (0);
2302  "Setting property for unknown address %u\n", op->peer_id);
2303  return;
2304  }
2305 
2307  op->address_id,
2308  p, a,
2309  op->gen_type,
2310  op->base_rate,
2311  op->max_rate,
2312  op->period,
2313  op->frequency,
2314  op->prop_type);
2315 }
2316 
2317 static void
2319 {
2320  struct PropertyGenerator *pg = find_prop_gen(op->peer_id, op->address_id,
2321  op->prop_type);
2322  if (NULL != pg)
2323  {
2325  "Stopping preference generation for peer %u address %u\n", op->peer_id,
2326  op->address_id);
2328  }
2329  else
2330  {
2332  "Cannot find preference generator for peer %u address %u\n",
2333  op->peer_id, op->address_id);
2334  GNUNET_break (0);
2335  }
2336 }
2337 
2338 static void
2340 {
2341  struct PreferenceGenerator *pg;
2342  if (NULL != (pg = find_pref_gen (op->peer_id, op->pref_type)))
2343  {
2345  GNUNET_free (pg);
2346  }
2347 
2348  if (NULL == (find_peer_by_id (op->peer_id)))
2349  {
2350  GNUNET_break (0);
2352  "Starting preference generation for unknown peer %u\n", op->peer_id);
2353  return;
2354  }
2355 
2357  op->address_id,
2358  op->client_id,
2359  op->gen_type,
2360  op->base_rate,
2361  op->max_rate,
2362  op->period,
2363  op->frequency,
2364  op->pref_type,
2365  op->frequency);
2366 }
2367 
2368 static void
2370 {
2371  struct PreferenceGenerator *pg = find_pref_gen(op->peer_id,
2372  op->pref_type);
2373  if (NULL != pg)
2374  {
2376  "Stopping property generation for peer %u address %u\n", op->peer_id,
2377  op->address_id);
2379  }
2380  else
2381  {
2383  "Cannot find preference generator for peer %u address %u\n",
2384  op->peer_id, op->address_id);
2385  GNUNET_break (0);
2386  }
2387 }
2388 
2389 
2390 static void
2392 {
2393  struct TestPeer *p;
2394 
2395  if (NULL == (p = find_peer_by_id (op->peer_id)))
2396  {
2397  GNUNET_break (0);
2399  "Requesting address for unknown peer %u\n", op->peer_id);
2400  return;
2401  }
2402 
2403  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Requesting address for peer %u\n",
2404  op->peer_id);
2405  p->is_requested = GNUNET_YES;
2406 
2407  sh->sf->s_get (sh->sf->cls, &p->peer_id);
2408 }
2409 
2410 
2411 static void
2413 {
2414  struct TestPeer *p;
2415 
2416  if (NULL == (p = find_peer_by_id (op->peer_id)))
2417  {
2418  GNUNET_break (0);
2420  "Requesting address for unknown peer %u\n", op->peer_id);
2421  return;
2422  }
2423 
2425  "Stop requesting address for peer %u\n",
2426  op->peer_id);
2427  p->is_requested = GNUNET_NO;
2428  p->assigned_bw_in = 0;
2429  p->assigned_bw_out = 0;
2430  sh->sf->s_get_stop (sh->sf->cls, &p->peer_id);
2431 
2432  if (NULL != l)
2433  {
2435  }
2436 
2437 }
2438 
2439 static void enforce_episode (struct Episode *ep)
2440 {
2441  struct GNUNET_ATS_TEST_Operation *cur;
2442  for (cur = ep->head; NULL != cur; cur = cur->next)
2443  {
2444  switch (cur->type) {
2445  case SOLVER_OP_ADD_ADDRESS:
2446  fprintf (stderr, "Enforcing operation: %s [%llu:%llu]\n",
2447  print_op (cur->type), cur->peer_id, cur->address_id);
2448  enforce_add_address (cur);
2449  break;
2450  case SOLVER_OP_DEL_ADDRESS:
2451  fprintf (stderr, "Enforcing operation: %s [%llu:%llu]\n",
2452  print_op (cur->type), cur->peer_id, cur->address_id);
2453  enforce_del_address (cur);
2454  break;
2456  fprintf (stderr, "Enforcing operation: %s [%llu:%llu] == %llu\n",
2457  print_op (cur->type), cur->peer_id, cur->address_id, cur->base_rate);
2458  enforce_start_property (cur);
2459  break;
2461  fprintf (stderr, "Enforcing operation: %s [%llu:%llu] == %llu\n",
2462  print_op (cur->type), cur->peer_id, cur->address_id, cur->base_rate);
2463  enforce_stop_property (cur);
2464  break;
2466  fprintf (stderr, "Enforcing operation: %s [%llu:%llu] == %llu\n",
2467  print_op (cur->type), cur->peer_id, cur->address_id, cur->base_rate);
2469  break;
2471  fprintf (stderr, "Enforcing operation: %s [%llu:%llu] == %llu\n",
2472  print_op (cur->type), cur->peer_id, cur->address_id, cur->base_rate);
2474  break;
2476  fprintf (stderr, "Enforcing operation: %s [%llu]\n",
2477  print_op (cur->type), cur->peer_id);
2478  enforce_start_request (cur);
2479  break;
2481  fprintf (stderr, "Enforcing operation: %s [%llu]\n",
2482  print_op (cur->type), cur->peer_id);
2483  enforce_stop_request (cur);
2484  break;
2485  default:
2486  break;
2487  }
2488  }
2489 }
2490 
2491 
2492 static void
2493 timeout_episode (void *cls)
2494 {
2495  struct Experiment *e = cls;
2496 
2497  e->episode_timeout_task = NULL;
2498  if (NULL != e->ep_done_cb)
2499  e->ep_done_cb (e->cur);
2500 
2501  /* Scheduling next */
2502  e->cur = e->cur->next;
2503  if (NULL == e->cur)
2504  {
2505  /* done */
2506  fprintf (stderr, "Last episode done!\n");
2507  if (NULL != e->experiment_timeout_task)
2508  {
2510  e->experiment_timeout_task = NULL;
2511  }
2513  return;
2514  }
2515 
2516  fprintf (stderr, "Running episode %u with timeout %s\n",
2517  e->cur->id,
2520  &timeout_episode, e);
2521  enforce_episode(e->cur);
2522 
2523 
2524 }
2525 
2526 
2527 void
2531 {
2532  fprintf (stderr, "Running experiment `%s' with timeout %s\n", e->name,
2534  e->e_done_cb = e_done_cb;
2535  e->ep_done_cb = ep_done_cb;
2537 
2538  /* Start total time out */
2540  &timeout_experiment, e);
2541 
2542  /* Start */
2543  if (NULL == e->start)
2544  {
2545  GNUNET_break (0);
2546  return;
2547  }
2548 
2549  e->cur = e->start;
2550  fprintf (stderr, "Running episode %u with timeout %s\n",
2551  e->cur->id,
2554  &timeout_episode, e);
2555  enforce_episode(e->cur);
2556 
2557 }
2558 
2559 void
2561 {
2562  if (NULL != e->experiment_timeout_task)
2563  {
2565  e->experiment_timeout_task = NULL;
2566  }
2567  if (NULL != e->episode_timeout_task)
2568  {
2570  e->episode_timeout_task = NULL;
2571  }
2572  if (NULL != e->cfg)
2573  {
2575  e->cfg = NULL;
2576  }
2577  free_experiment (e);
2578 }
2579 
2580 
2581 struct Experiment *
2583 {
2584  struct Experiment *e;
2586  e = NULL;
2587 
2589  if (GNUNET_SYSERR == GNUNET_CONFIGURATION_load (cfg, filename))
2590  {
2591  fprintf (stderr, "Failed to load `%s'\n", filename);
2593  return NULL;
2594  }
2595 
2596  e = create_experiment ();
2597 
2598  if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string(cfg, "experiment",
2599  "name", &e->name))
2600  {
2601  fprintf (stderr, "Invalid %s \n", "name");
2602  free_experiment (e);
2603  return NULL;
2604  }
2605  else
2606  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Experiment name: `%s'\n", e->name);
2607 
2608  if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string(cfg, "experiment",
2609  "log_prefix", &e->log_prefix))
2610  {
2611  fprintf (stderr, "Invalid %s \n", "log_prefix");
2612  free_experiment (e);
2613  return NULL;
2614  }
2615  else
2616  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Experiment logging prefix: `%s'\n",
2617  e->log_prefix);
2618 
2619  if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_filename (cfg, "experiment",
2620  "log_output_dir", &e->log_output_dir))
2621  {
2622  e->log_output_dir = NULL;
2623  }
2624  else
2625  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Experiment logging output directory: `%s'\n",
2626  e->log_output_dir);
2627 
2628 
2630  "experiment", "log_append_time_stamp")))
2632  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Experiment logging append timestamp: `%s'\n",
2633  (GNUNET_YES == e->log_append_time_stamp) ? "yes" : "no");
2634 
2635 
2636  if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_filename (cfg, "experiment",
2637  "cfg_file", &e->cfg_file))
2638  {
2639  fprintf (stderr, "Invalid %s \n", "cfg_file");
2640  free_experiment (e);
2641  return NULL;
2642  }
2643  else
2644  {
2645  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Experiment configuration: `%s'\n", e->cfg_file);
2648  {
2649  fprintf (stderr, "Invalid configuration %s \n", "cfg_file");
2650  free_experiment (e);
2651  return NULL;
2652  }
2653 
2654  }
2655 
2656  if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_time(cfg, "experiment",
2657  "log_freq", &e->log_freq))
2658  {
2659  fprintf (stderr, "Invalid %s \n", "log_freq");
2660  free_experiment (e);
2661  return NULL;
2662  }
2663  else
2664  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Experiment logging frequency: `%s'\n",
2666 
2667  if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_time(cfg, "experiment",
2668  "max_duration", &e->max_duration))
2669  {
2670  fprintf (stderr, "Invalid %s", "max_duration");
2671  free_experiment (e);
2672  return NULL;
2673  }
2674  else
2675  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Experiment duration: `%s'\n",
2677 
2678  if (GNUNET_SYSERR == load_episodes (e, cfg))
2679  {
2682  e = NULL;
2683  fprintf (stderr, "Failed to load experiment\n");
2684  return NULL;
2685  }
2686  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Loaded %u episodes with total duration %s\n",
2687  e->num_episodes,
2689 
2691  return e;
2692 }
2693 
2694 
2695 
2700 static int
2701 free_all_it (void *cls,
2702  const struct GNUNET_PeerIdentity *key,
2703  void *value)
2704 {
2705  struct ATS_Address *address = value;
2707  key, value));
2708  GNUNET_free (address);
2709 
2710  return GNUNET_OK;
2711 }
2712 
2713 void
2715 {
2717  GNUNET_NO);
2718  GNUNET_PLUGIN_unload (sh->plugin, sh->sf);
2719  sh->sf = NULL;
2721 
2723  &free_all_it,
2724  NULL);
2726  GNUNET_free (sh->plugin);
2727  GNUNET_free (sh);
2728 }
2729 
2730 
2740 unsigned int
2742  unsigned long long *out_dest,
2743  unsigned long long *in_dest,
2744  int dest_length)
2745 {
2746  char * entry_in = NULL;
2747  char * entry_out = NULL;
2748  char * quota_out_str;
2749  char * quota_in_str;
2750  int c;
2751  int res;
2752 
2753  for (c = 0; (c < GNUNET_NT_COUNT) && (c < dest_length); c++)
2754  {
2755  in_dest[c] = 0;
2756  out_dest[c] = 0;
2757  GNUNET_asprintf (&entry_out,
2758  "%s_QUOTA_OUT",
2759  GNUNET_NT_to_string (c));
2760  GNUNET_asprintf (&entry_in,
2761  "%s_QUOTA_IN",
2762  GNUNET_NT_to_string (c));
2763 
2764  /* quota out */
2765  if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string(cfg, "ats", entry_out, &quota_out_str))
2766  {
2767  res = GNUNET_NO;
2768  if (0 == strcmp(quota_out_str, BIG_M_STRING))
2769  {
2770  out_dest[c] = GNUNET_ATS_MaxBandwidth;
2771  res = GNUNET_YES;
2772  }
2773  if ((GNUNET_NO == res) && (GNUNET_OK == GNUNET_STRINGS_fancy_size_to_bytes (quota_out_str, &out_dest[c])))
2774  res = GNUNET_YES;
2775  if ((GNUNET_NO == res) && (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (cfg, "ats", entry_out, &out_dest[c])))
2776  res = GNUNET_YES;
2777 
2778  if (GNUNET_NO == res)
2779  {
2781  _("Could not load quota for network `%s': `%s', assigning default bandwidth %llu\n"),
2782  GNUNET_NT_to_string (c),
2783  quota_out_str,
2785  out_dest[c] = GNUNET_ATS_DefaultBandwidth;
2786  }
2787  else
2788  {
2790  "Outbound quota configure for network `%s' is %llu\n",
2791  GNUNET_NT_to_string (c),
2792  out_dest[c]);
2793  }
2794  GNUNET_free (quota_out_str);
2795  }
2796  else
2797  {
2799  _("No outbound quota configured for network `%s', assigning default bandwidth %llu\n"),
2800  GNUNET_NT_to_string (c),
2802  out_dest[c] = GNUNET_ATS_DefaultBandwidth;
2803  }
2804 
2805  /* quota in */
2806  if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string(cfg, "ats", entry_in, &quota_in_str))
2807  {
2808  res = GNUNET_NO;
2809  if (0 == strcmp(quota_in_str, BIG_M_STRING))
2810  {
2811  in_dest[c] = GNUNET_ATS_MaxBandwidth;
2812  res = GNUNET_YES;
2813  }
2814  if ((GNUNET_NO == res) && (GNUNET_OK == GNUNET_STRINGS_fancy_size_to_bytes (quota_in_str, &in_dest[c])))
2815  res = GNUNET_YES;
2816  if ((GNUNET_NO == res) && (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (cfg, "ats", entry_in, &in_dest[c])))
2817  res = GNUNET_YES;
2818 
2819  if (GNUNET_NO == res)
2820  {
2822  _("Could not load quota for network `%s': `%s', assigning default bandwidth %llu\n"),
2823  GNUNET_NT_to_string (c),
2824  quota_in_str,
2826  in_dest[c] = GNUNET_ATS_DefaultBandwidth;
2827  }
2828  else
2829  {
2831  "Inbound quota configured for network `%s' is %llu\n",
2832  GNUNET_NT_to_string (c),
2833  in_dest[c]);
2834  }
2835  GNUNET_free (quota_in_str);
2836  }
2837  else
2838  {
2840  _("No outbound quota configure for network `%s', assigning default bandwidth %llu\n"),
2841  GNUNET_NT_to_string (c),
2843  out_dest[c] = GNUNET_ATS_DefaultBandwidth;
2844  }
2846  "Loaded quota for network `%s' (in/out): %llu %llu\n",
2847  GNUNET_NT_to_string (c),
2848  in_dest[c],
2849  out_dest[c]);
2850  GNUNET_free (entry_out);
2851  GNUNET_free (entry_in);
2852  }
2853  return GNUNET_NT_COUNT;
2854 }
2855 
2856 
2865 static void
2866 solver_info_cb (void *cls,
2867  enum GAS_Solver_Operation op,
2868  enum GAS_Solver_Status stat,
2870 {
2871  char *add_info;
2872  switch (add) {
2873  case GAS_INFO_NONE:
2874  add_info = "GAS_INFO_NONE";
2875  break;
2876  case GAS_INFO_FULL:
2877  add_info = "GAS_INFO_MLP_FULL";
2878  break;
2879  case GAS_INFO_UPDATED:
2880  add_info = "GAS_INFO_MLP_UPDATED";
2881  break;
2882  case GAS_INFO_PROP_ALL:
2883  add_info = "GAS_INFO_PROP_ALL";
2884  break;
2885  case GAS_INFO_PROP_SINGLE:
2886  add_info = "GAS_INFO_PROP_SINGLE";
2887  break;
2888  default:
2889  add_info = "INVALID";
2890  break;
2891  }
2892 
2893  switch (op)
2894  {
2895  case GAS_OP_SOLVE_START:
2897  "Solver notifies `%s' with result `%s' `%s'\n", "GAS_OP_SOLVE_START",
2898  (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL", add_info);
2899  return;
2900  case GAS_OP_SOLVE_STOP:
2902  "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_STOP",
2903  (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL", add_info);
2904  return;
2905 
2908  "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_SETUP_START",
2909  (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL");
2910  return;
2911 
2914  "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_SETUP_STOP",
2915  (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL");
2916  return;
2917 
2920  "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_LP_START",
2921  (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL");
2922  return;
2925  "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_LP_STOP",
2926  (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL");
2927  return;
2928 
2931  "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_MLP_START",
2932  (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL");
2933  return;
2936  "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_MLP_STOP",
2937  (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL");
2938  return;
2941  "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_UPDATE_NOTIFICATION_START",
2942  (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL");
2943  return;
2946  "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_UPDATE_NOTIFICATION_STOP",
2947  (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL");
2948  return;
2949  default:
2950  break;
2951  }
2952 }
2953 
2954 static void
2956 {
2957  struct GNUNET_TIME_Relative duration;
2958  struct TestPeer *p;
2959  static struct PreferenceGenerator *pg;
2960  uint32_t delta;
2961  if ( (0 == address->assigned_bw_out) && (0 == address->assigned_bw_in) )
2962  {
2964  "Solver notified to disconnect peer `%s'\n",
2965  GNUNET_i2s (&address->peer));
2966  }
2967  p = find_peer_by_pid(&address->peer);
2968  if (NULL == p)
2969  return;
2970  p->assigned_bw_out = address->assigned_bw_out;
2971  p->assigned_bw_in = address->assigned_bw_in;
2972 
2973  for (pg = pref_gen_head; NULL != pg; pg = pg->next)
2974  {
2975  if (pg->peer == p->id)
2976  {
2978  delta = duration.rel_value_us * pg->last_assigned_bw_out;
2979  pg->feedback_bw_out_acc += delta;
2980 
2981  delta = duration.rel_value_us * pg->last_assigned_bw_in;
2982  pg->feedback_bw_in_acc += delta;
2983 
2984  pg->last_assigned_bw_in = address->assigned_bw_in;
2985  pg->last_assigned_bw_out = address->assigned_bw_out;
2987  }
2988  }
2989 
2991  "Bandwidth changed addresses %s %p to %u Bps out / %u Bps in\n",
2992  GNUNET_i2s (&address->peer),
2993  address,
2994  address->assigned_bw_out,
2995  address->assigned_bw_in);
2996 
2997  if (NULL != l)
2999 
3000  return;
3001 }
3002 
3003 const double *
3004 get_preferences_cb (void *cls, const struct GNUNET_PeerIdentity *id)
3005 {
3006  struct TestPeer *p;
3008  {
3009  if (NULL == (p = find_peer_by_pid (id)))
3010  return NULL;
3011  return p->pref_abs;
3012  }
3013  else
3014  return GAS_preference_get_by_peer (NULL,
3015  id);
3016 }
3017 
3018 
3019 struct SolverHandle *
3021 {
3022  struct SolverHandle *sh;
3023  char * solver_str;
3024 
3025  switch (type) {
3027  solver_str = "proportional";
3028  break;
3029  case GNUNET_ATS_SOLVER_MLP:
3030  solver_str = "mlp";
3031  break;
3032  case GNUNET_ATS_SOLVER_RIL:
3033  solver_str = "ril";
3034  break;
3035  default:
3036  GNUNET_break (0);
3037  return NULL;
3038  break;
3039  }
3040 
3041  sh = GNUNET_new (struct SolverHandle);
3042  GNUNET_asprintf (&sh->plugin,
3043  "libgnunet_plugin_ats_%s",
3044  solver_str);
3046 
3047  /* setup environment */
3048  sh->env.cfg = e->cfg;
3049  sh->env.stats = GNUNET_STATISTICS_create ("ats", e->cfg);
3050  sh->env.addresses = sh->addresses;
3054  sh->env.info_cb = &solver_info_cb;
3056 
3057  /* start normalization */
3059 
3060  /* load quotas */
3063  {
3064  GNUNET_break(0);
3065  GNUNET_free (sh->plugin);
3066  GNUNET_free (sh);
3067  end_now ();
3068  return NULL;
3069  }
3070 
3071  sh->sf = GNUNET_PLUGIN_load (sh->plugin, &sh->env);
3072  if (NULL == sh->sf)
3073  {
3074  fprintf (stderr, "Failed to load solver `%s'\n", sh->plugin);
3075  GNUNET_break(0);
3076  GNUNET_free (sh->plugin);
3077  GNUNET_free (sh);
3078  end_now ();
3079  return NULL;
3080  }
3081  return sh;
3082 }
3083 
3084 
3085 static void
3087 {
3088  struct TestPeer *cur;
3089  struct TestPeer *next;
3090 
3091  struct TestAddress *cur_a;
3092  struct TestAddress *next_a;
3093 
3094  /* Stop logging */
3096 
3097  /* Stop all preference generation */
3099 
3100  /* Stop all property generation */
3102 
3103  if (opt_print)
3104  {
3105  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "== Printing log information \n");
3107  }
3108  if (opt_save)
3109  {
3110  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "== Saving log information \n");
3112  e->log_output_dir);
3113  }
3114 
3115  if (NULL != l)
3116  {
3118  l = NULL;
3119  }
3120 
3121  /* Clean up experiment */
3122  if (NULL != e)
3123  {
3125  e = NULL;
3126  }
3127 
3128  next = peer_head;
3129  while (NULL != (cur = next))
3130  {
3131  next = cur->next;
3132  GNUNET_CONTAINER_DLL_remove (peer_head, peer_tail, cur);
3133  next_a = cur->addr_head;
3134  while (NULL != (cur_a = next_a))
3135  {
3136  next_a = cur_a->next;
3137  GNUNET_CONTAINER_DLL_remove (cur->addr_head, cur->addr_tail, cur_a);
3138  GNUNET_free (cur_a);
3139  }
3140  GNUNET_free (cur);
3141  }
3142  if (NULL != sh)
3143  {
3145  sh = NULL;
3146  }
3147 
3148  /* Shutdown */
3149  end_now();
3150 }
3151 
3152 static void
3154 {
3155  if (GNUNET_OK == success)
3156  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Experiment done successful in %s\n",
3158  else
3159  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Experiment failed \n");
3160 
3161  GNUNET_SCHEDULER_add_now (&done, NULL);
3162 }
3163 
3164 static void
3166 {
3167  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Episode %u done\n", ep->id);
3168 }
3169 
3170 
3171 
3175 static void
3177 {
3178  if (NULL != e)
3179  {
3181  e = NULL;
3182  }
3183  if (NULL != sh)
3184  {
3186  sh = NULL;
3187  }
3188 }
3189 
3190 static void
3191 run (void *cls, char * const *args, const char *cfgfile,
3192  const struct GNUNET_CONFIGURATION_Handle *cfg)
3193 {
3194  enum GNUNET_ATS_Solvers solver;
3195  int c;
3196 
3197  if (NULL == opt_exp_file)
3198  {
3199  fprintf (stderr, "No experiment given ...\n");
3200  res = 1;
3201  end_now ();
3202  return;
3203  }
3204 
3205  if (NULL == opt_solver)
3206  {
3207  fprintf (stderr, "No solver given ...\n");
3208  res = 1;
3209  end_now ();
3210  return;
3211  }
3212 
3213  if (0 == strcmp(opt_solver, "mlp"))
3214  {
3215  solver = GNUNET_ATS_SOLVER_MLP;
3216  }
3217  else if (0 == strcmp(opt_solver, "proportional"))
3218  {
3220  }
3221  else if (0 == strcmp(opt_solver, "ril"))
3222  {
3223  solver = GNUNET_ATS_SOLVER_RIL;
3224  }
3225  else
3226  {
3227  fprintf (stderr, "No solver given ...");
3228  res = 1;
3229  end_now ();
3230  return;
3231  }
3232 
3233  for (c = 0; c < GNUNET_ATS_PropertyCount; c++)
3235 
3236  for (c = 0; c < GNUNET_ATS_PreferenceCount; c++)
3238 
3239  /* load experiment */
3240  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "=== Loading experiment\n");
3242  if (NULL == e)
3243  {
3244  fprintf (stderr, "Failed to load experiment ...\n");
3245  res = 1;
3246  end_now ();
3247  return;
3248  }
3249 
3250  /* load solver */
3251  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "=== Loading solver\n");
3252  sh = GNUNET_ATS_solvers_solver_start (solver);
3253  if (NULL == sh)
3254  {
3255  fprintf (stderr, "Failed to start solver ...\n");
3256  end_now ();
3257  res = 1;
3258  return;
3259  }
3260 
3261  /* start logging */
3262  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "=== Start logging \n");
3264 
3265  /* run experiment */
3266  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "=== Running experiment \n");
3269 
3270  /* WAIT */
3271 }
3272 
3273 
3280 int
3281 main (int argc, char *argv[])
3282 {
3283  opt_exp_file = NULL;
3284  opt_solver = NULL;
3285  opt_log = GNUNET_NO;
3286  opt_save = GNUNET_NO;
3287 
3288  res = 0;
3289 
3290  static struct GNUNET_GETOPT_CommandLineOption options[] =
3291  {
3293  "solver",
3294  gettext_noop ("solver to use"),
3295  &opt_solver),
3296 
3298  "experiment"
3299  gettext_noop ("experiment to use"),
3300  &opt_exp_file),
3301 
3303 
3305  "print",
3306  gettext_noop ("print logging"),
3307  &opt_print),
3308 
3310  "file",
3311  gettext_noop ("save logging to disk"),
3312  &opt_save),
3313 
3315  "dn",
3316  gettext_noop ("disable normalization"),
3318 
3320  };
3321 
3322  GNUNET_PROGRAM_run (argc, argv, "gnunet-ats-solver-eval",
3323  NULL, options, &run, argv[0]);
3324 
3325  return res;
3326 }
3327 /* end of file ats-testing-experiment.c*/
void GNUNET_ATS_solver_generate_preferences_stop(struct PreferenceGenerator *pg)
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
struct LoggingPeer * head
void GAS_normalization_stop()
Stop the normalization component and free all items.
struct GNUNET_ATS_TEST_Operation * next
GAS_solver_stop_get_preferred_address s_get_stop
Tell solver stop notifying ATS about changes for this peers.
Local area network.
Definition: gnunet_nt_lib.h:50
static void enforce_start_property(struct GNUNET_ATS_TEST_Operation *op)
double prop_abs[GNUNET_ATS_PropertyCount]
Solving of the LP problem was started MLP solver only.
After the problem was finished, start notifications about changes to addresses.
static void done()
struct Episode * start
Create file if it doesn&#39;t exist.
void GNUNET_ATS_solvers_solver_stop(struct SolverHandle *sh)
struct PreferenceGenerator * next
struct LoggingHandle * GNUNET_ATS_solver_logging_start(struct GNUNET_TIME_Relative freq)
struct LoggingTimeStep * tail
struct GNUNET_TIME_Absolute time_start
int GNUNET_CONFIGURATION_get_value_time(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, struct GNUNET_TIME_Relative *time)
Get a configuration value that should be a relative time.
static void set_feedback_task(void *cls)
GNUNET_ATS_TESTING_EpisodeDoneCallback ep_done_cb
GAS_solver_address_add s_add
Add a new address for a peer to the solver.
static void enforce_add_address(struct GNUNET_ATS_TEST_Operation *op)
int GNUNET_DISK_file_close(struct GNUNET_DISK_FileHandle *h)
Close an open file.
Definition: disk.c:1817
long long unsigned int peer_id
GNUNET_ATS_TESTING_ExperimentDoneCallback e_done_cb
int GNUNET_CONFIGURATION_get_value_number(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, unsigned long long *number)
Get a configuration value that should be a number.
uint64_t rel_value_us
The actual value.
The proportional solver had to recalculate for a single network.
const char * GNUNET_NT_to_string(enum GNUNET_NetworkType net)
Convert a enum GNUNET_NetworkType to a string.
Definition: nt.c:43
static struct GNUNET_TIME_Relative delta
Definition: speedup.c:35
uint32_t session_id
Session ID, can never be 0.
struct Episode * next
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
The setup of the problem as a preparation to solve it was started.
struct GNUNET_STATISTICS_Handle * stats
Statistics handle to be used by the solver.
void GNUNET_ATS_solver_logging_free(struct LoggingHandle *l)
static void enforce_del_address(struct GNUNET_ATS_TEST_Operation *op)
double pref_abs[GNUNET_ATS_PreferenceCount]
struct GNUNET_TIME_Relative total_duration
struct LoggingTimeStep * prev
int active
Is this the active address for this peer?
GAS_get_preferences get_preferences
ATS addresses function to obtain preference values.
static int load_episodes(struct Experiment *e, struct GNUNET_CONFIGURATION_Handle *cfg)
static int load_op_start_set_property(struct GNUNET_ATS_TEST_Operation *o, struct Episode *e, int op_counter, char *sec_name, const struct GNUNET_CONFIGURATION_Handle *cfg)
struct GNUNET_PeerIdentity peer
Peer ID this address is for.
struct GNUNET_STATISTICS_Handle * GNUNET_STATISTICS_create(const char *subsystem, const struct GNUNET_CONFIGURATION_Handle *cfg)
Get handle for the statistics service.
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_verbose(unsigned int *level)
Define the &#39;-V&#39; verbosity option.
struct LoggingAddress * addr_tail
long long unsigned int peer
GAS_Solver_Status
Status of a GAS_Solver_Operation operation.
struct GNUNET_TIME_Relative duration_period
static int load_op_stop_set_property(struct GNUNET_ATS_TEST_Operation *o, struct Episode *e, int op_counter, char *sec_name, const struct GNUNET_CONFIGURATION_Handle *cfg)
uint32_t GNUNET_CRYPTO_random_u32(enum GNUNET_CRYPTO_Quality mode, uint32_t i)
Produce a random value.
static int opt_log
cmd option -l: enable logging
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
The proportional solver had to recalculate for all networks.
No more specific information.
const void * addr
Address (in plugin-specific binary format).
static char * opt_exp_file
cmd option -e: experiment file
struct PropertyGenerator * GNUNET_ATS_solver_generate_property_start(unsigned int peer, unsigned int address_id, struct TestPeer *test_peer, struct TestAddress *test_address, enum GeneratorType type, long int base_value, long int value_rate, struct GNUNET_TIME_Relative period, struct GNUNET_TIME_Relative frequency, uint32_t ats_property)
Generate between the source master and the partner and set property with a value depending on the gen...
long long unsigned int aid
struct LoggingTimeStep * next
static void solver_info_cb(void *cls, enum GAS_Solver_Operation op, enum GAS_Solver_Status stat, enum GAS_Solver_Additional_Information add)
Information callback for the solver.
long long unsigned int address_id
#define DEFAULT_REL_QUALITY
Value we return for a normalized quality score if we have no data.
static void logging_task(void *cls)
long long unsigned int id
static struct TestPeer * find_peer_by_pid(const struct GNUNET_PeerIdentity *pid)
struct GNUNET_PeerIdentity peer_id
GAS_solver_address_feedback_preference s_feedback
Give feedback about the current assignment.
struct LoggingTimeStep * head
static struct Experiment * e
int GNUNET_DISK_directory_create_for_file(const char *filename)
Create the directory structure for storing a file.
Definition: disk.c:833
ats service address: management of ATS properties and preferences normalization
GAS_solver_address_property_changed s_address_update_property
Update the properties of an address in the solver.
static struct GNUNET_HashCode session_id
int GNUNET_STRINGS_fancy_size_to_bytes(const char *fancy_size, unsigned long long *size)
Convert a given fancy human-readable size to bytes.
Definition: strings.c:317
int GNUNET_CONTAINER_multipeermap_remove(struct GNUNET_CONTAINER_MultiPeerMap *map, const struct GNUNET_PeerIdentity *key, const void *value)
Remove the given key-value pair from the map.
static char * peer_id
Option –peer.
Definition: gnunet-cadet.c:42
Wide area network (i.e.
Definition: gnunet_nt_lib.h:55
#define GNUNET_NO
Definition: gnunet_common.h:81
struct GNUNET_TIME_Absolute feedback_last_delay_update
int main(int argc, char *argv[])
Main function of the benchmark.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
A full solution process is performed Quite specific to the MLP solver.
static struct TestAddress * find_active_address(struct TestPeer *p)
Wireless LAN (i.e.
Definition: gnunet_nt_lib.h:60
#define GNUNET_free_non_null(ptr)
Free the memory pointed to by ptr if ptr is not NULL.
char * plugin
Plugin name.
size_t addr_len
Address length, number of bytes in addr.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
Definition of a command line option.
unsigned int num_episodes
struct GNUNET_TIME_Relative period
long long unsigned int client_id
struct GNUNET_CONFIGURATION_Handle * GNUNET_CONFIGURATION_create(void)
Create a new configuration object.
long long unsigned int pid
Solving of the LP problem is done MLP solver only.
void GNUNET_ATS_solver_logging_eval(struct LoggingHandle *l)
void GNUNET_STATISTICS_destroy(struct GNUNET_STATISTICS_Handle *h, int sync_first)
Destroy a handle (free all state associated with it).
struct GNUNET_CONTAINER_MultiPeerMap * GNUNET_CONTAINER_multipeermap_create(unsigned int len, int do_not_copy_keys)
Create a multi peer map (hash map for public keys of peers).
Handle for the service.
struct LoggingAddress * next
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
manage preferences expressed by clients
static void update_preference(struct GNUNET_SERVICE_Client *client, const struct GNUNET_PeerIdentity *peer, enum GNUNET_ATS_PreferenceKind kind, float score_abs)
Update the absolute preference and calculate the new relative preference value.
struct GNUNET_STATISTICS_Handle * GSA_stats
Handle for statistics.
uint64_t abs_value_us
The actual value.
GNUNET_ATS_Solvers
static struct TestPeer * peer_tail
struct TestAddress * addr_tail
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
End of preference list.
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_OPTION_END
Definition: 002.c:13
struct ATS_Address * ats_addr
void GNUNET_CONTAINER_multipeermap_destroy(struct GNUNET_CONTAINER_MultiPeerMap *map)
Destroy a hash map.
struct PropertyGenerator * next
static enum GNUNET_ATS_Property parse_preference_string(const char *str)
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_string(char shortName, const char *name, const char *argumentHelp, const char *description, char **str)
Allow user to specify a string.
int GNUNET_CONFIGURATION_load(struct GNUNET_CONFIGURATION_Handle *cfg, const char *filename)
Load configuration.
#define _(String)
GNU gettext support macro.
Definition: platform.h:208
enum GNUNET_ATS_PreferenceKind kind
struct SolverHandle * GNUNET_ATS_solvers_solver_start(enum GNUNET_ATS_Solvers type)
GAS_Solver_Operation
Operation codes for solver information callback.
void * GNUNET_PLUGIN_unload(const char *library_name, void *arg)
Unload plugin (runs the "done" callback and returns whatever "done" returned).
Definition: plugin.c:258
uint32_t assigned_bw_in
Inbound bandwidth assigned by solver.
struct LoggingPeer * tail
static char * opt_solver
struct GNUNET_SCHEDULER_Task * experiment_timeout_task
struct LoggingPeer * next
static struct LoggingHandle * l
static struct PropertyGenerator * find_prop_gen(unsigned int peer, unsigned int address, uint32_t ats_property)
Set ats_property to 0 to find all pgs.
Solving of the MLP problem is done MLP solver only.
double pref_abs[GNUNET_ATS_PREFERENCE_END]
struct GNUNET_TIME_Relative log_freq
void GAS_normalization_update_property(struct ATS_Address *address)
Update and normalize atsi performance information.
int GNUNET_asprintf(char **buf, const char *format,...)
Like asprintf, just portable.
Bluetooth LAN.
Definition: gnunet_nt_lib.h:65
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_delayed(struct GNUNET_TIME_Relative delay, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay.
Definition: scheduler.c:1246
struct GNUNET_TIME_Absolute feedback_last_bw_update
struct LoggingAddress * addr_head
struct GNUNET_SCHEDULER_Task * set_task
A solution iteration has been started.
static void end_now()
Do shutdown.
void GNUNET_STRINGS_utf8_toupper(const char *input, char *output)
Convert the utf-8 input string to upper case.
Definition: strings.c:580
static int opt_save
cmd option -p: enable plots
#define GNUNET_memcpy(dst, src, n)
static void enforce_stop_property(struct GNUNET_ATS_TEST_Operation *op)
static struct GNUNET_OS_Process * p
Helper process we started.
Definition: gnunet-qr.c:59
static void experiment_done_cb(struct Experiment *e, struct GNUNET_TIME_Relative duration, int success)
void(* GNUNET_ATS_TESTING_ExperimentDoneCallback)(struct Experiment *e, struct GNUNET_TIME_Relative duration, int success)
static struct LoggingFileHandle * find_logging_file_handle(struct LoggingFileHandle *lf_head, struct LoggingFileHandle *lf_tail, int peer_id, int address_id)
enum GeneratorType type
static char * value
Value of the record to add/remove.
struct LoggingFileHandle * next
double prop_norm[GNUNET_ATS_PropertyCount]
struct Episode * cur
Truncate file if it exists.
ssize_t GNUNET_DISK_file_write(const struct GNUNET_DISK_FileHandle *h, const void *buffer, size_t n)
Write a buffer to a file.
Definition: disk.c:1049
static int free_all_it(void *cls, const struct GNUNET_PeerIdentity *key, void *value)
Solver.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_now(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run as soon as possible.
Definition: scheduler.c:1273
static char * print_generator_type(enum GeneratorType g)
static struct PropertyGenerator * prop_gen_tail
void GNUNET_ATS_solver_logging_now(struct LoggingHandle *l)
Logging.
static int load_op_stop_set_preference(struct GNUNET_ATS_TEST_Operation *o, struct Episode *e, int op_counter, char *sec_name, const struct GNUNET_CONFIGURATION_Handle *cfg)
static struct SolverHandle * sh
GAS_Solver_Additional_Information
Status of the operation.
const char * GNUNET_STRINGS_relative_time_to_string(struct GNUNET_TIME_Relative delta, int do_round)
Give relative time in human-readable fancy format.
Definition: strings.c:727
struct ATS_Address * create_ats_address(const struct GNUNET_PeerIdentity *peer, const char *plugin_name, const void *plugin_addr, size_t plugin_addr_len, uint32_t session_id, uint32_t network)
GAS_solver_address_delete s_del
Delete an address in the solver.
long long unsigned int aid
Solving of the MLP problem was started MLP solver only.
static int load_op_start_request(struct GNUNET_ATS_TEST_Operation *o, struct Episode *e, int op_counter, char *sec_name, const struct GNUNET_CONFIGURATION_Handle *cfg)
long long unsigned int base_rate
static const char * print_op(enum OperationType op)
Experiments.
void GNUNET_CONFIGURATION_destroy(struct GNUNET_CONFIGURATION_Handle *cfg)
Destroy configuration object.
const double * get_preferences_cb(void *cls, const struct GNUNET_PeerIdentity *id)
static char * filename
uint32_t assigned_bw_in
void GNUNET_ATS_solver_generate_property_stop(struct PropertyGenerator *pg)
static void cleanup(void *cls)
Function scheduled as very last function, cleans up after us.
enum GNUNET_ATS_PreferenceKind pref_type
struct GNUNET_TIME_Relative frequency
static void timeout_experiment(void *cls)
void(* GNUNET_ATS_TESTING_EpisodeDoneCallback)(struct Episode *e)
#define GNUNET_TIME_UNIT_FOREVER_REL
Constant used to specify "forever".
long long unsigned int address_id
static char * plugin_name
Solver plugin name as string.
static int load_op_add_address(struct GNUNET_ATS_TEST_Operation *o, struct Episode *e, int op_counter, char *sec_name, const struct GNUNET_CONFIGURATION_Handle *cfg)
#define GNUNET_ATS_DefaultBandwidth
Default bandwidth assigned to a network : 64 KB/s.
const char * GNUNET_ATS_print_preference_type(enum GNUNET_ATS_PreferenceKind type)
Convert a enum GNUNET_ATS_PreferenceType to a string.
struct GNUNET_SCHEDULER_Task * episode_timeout_task
GAS_solver_address_change_preference s_pref
Change relative preference for quality in solver.
void GNUNET_ATS_solvers_experimentation_run(struct Experiment *e, GNUNET_ATS_TESTING_EpisodeDoneCallback ep_done_cb, GNUNET_ATS_TESTING_ExperimentDoneCallback e_done_cb)
struct GNUNET_SCHEDULER_Task * set_task
static void enforce_start_request(struct GNUNET_ATS_TEST_Operation *op)
void GNUNET_ATS_solvers_experimentation_stop(struct Experiment *e)
static int res
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
Definition: time.c:118
struct GNUNET_TIME_Relative duration
Entry for a benchmark peer.
struct GNUNET_TIME_Absolute start_time
struct LinkProperty * props
list of link properties
static struct PreferenceGenerator * pref_gen_head
Preference Generators.
static int load_op_stop_request(struct GNUNET_ATS_TEST_Operation *o, struct Episode *e, int op_counter, char *sec_name, const struct GNUNET_CONFIGURATION_Handle *cfg)
int GNUNET_CONFIGURATION_get_value_string(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, char **value)
Get a configuration value that should be a string.
void GNUNET_ATS_solver_generate_property_stop_all()
Stop all preferences generators.
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
Definition: gnunet-arm.c:104
An operation in an experiment.
struct TestAddress * test_address
static double get_property(struct PropertyGenerator *pg)
#define GNUNET_ATS_MaxBandwidth
Maximum bandwidth assigned to a network : 4095 MB/s.
Address with additional information.
static int opt_print
cmd option -p: print logs
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
struct GNUNET_HashCode key
The key used in the DHT.
#define GNUNET_SYSERR
Definition: gnunet_common.h:79
struct GNUNET_TIME_Absolute time_start
static int opt_disable_normalization
cmd option -d: disable normalization
static struct TestPeer * peer_head
struct GNUNET_TIME_Relative delta
static struct Experiment * create_experiment()
void GNUNET_ATS_solver_generate_preferences_stop_all()
Stop all preferences generators.
static void solver_bandwidth_changed_cb(void *cls, struct ATS_Address *address)
struct GNUNET_TIME_Absolute timestamp
void * cls
Closure to pass to all solver functions in this struct.
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
Change the peer&#39;s latency value to the given amount.
#define DEFAULT_REL_PREFERENCE
Default relative preference value we assume if we know nothing.
Loopback (same host).
Definition: gnunet_nt_lib.h:45
struct GNUNET_TIME_Absolute feedback_last
static int opt_verbose
cmd option -v: verbose logs
struct GNUNET_ATS_SolverFunctions * sf
Solver handle.
static int add
Desired action is to add a record.
static void set_prop_task(void *cls)
struct GNUNET_DISK_FileHandle * f_hd
#define GNUNET_TIME_UNIT_ZERO
Relative time zero.
#define GNUNET_memcmp(a, b)
Compare memory in a and b, where both must be of the same pointer type.
struct GNUNET_CONFIGURATION_Handle * cfg
unsigned int GNUNET_ATS_solvers_load_quotas(const struct GNUNET_CONFIGURATION_Handle *cfg, unsigned long long *out_dest, unsigned long long *in_dest, int dest_length)
Load quotas for networks from configuration.
static double default_properties[GNUNET_ATS_PropertyCount]
#define BIG_M_STRING
GAS_solver_get_preferred_address s_get
Tell solver to notify ATS if the address to use changes for a specific peer using the bandwidth chang...
unsigned long long in_quota[6]
Array of configured inbound quotas Order according to networks in network array.
A solution iteration has been finished.
static int load_op_start_set_preference(struct GNUNET_ATS_TEST_Operation *o, struct Episode *e, int op_counter, char *sec_name, const struct GNUNET_CONFIGURATION_Handle *cfg)
Allow multiple values with the same key.
struct GNUNET_ATS_TEST_Operation * head
static void episode_done_cb(struct Episode *ep)
int GNUNET_CONTAINER_multipeermap_put(struct GNUNET_CONTAINER_MultiPeerMap *map, const struct GNUNET_PeerIdentity *key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt)
Store a key-value pair in the map.
struct GNUNET_ATS_TEST_Operation * tail
struct TestAddress * next
static int load_episode(struct Experiment *e, struct Episode *cur, struct GNUNET_CONFIGURATION_Handle *cfg)
struct GNUNET_SCHEDULER_Task * feedback_task
static void enforce_stop_request(struct GNUNET_ATS_TEST_Operation *op)
int GNUNET_CONTAINER_multipeermap_iterate(struct GNUNET_CONTAINER_MultiPeerMap *map, GNUNET_CONTAINER_PeerMapIterator it, void *it_cls)
Iterate over all entries in the map.
struct PreferenceGenerator * GNUNET_ATS_solver_generate_preferences_start(unsigned int peer, unsigned int address_id, unsigned int client_id, enum GeneratorType type, long int base_value, long int value_rate, struct GNUNET_TIME_Relative period, struct GNUNET_TIME_Relative frequency, enum GNUNET_ATS_PreferenceKind kind, struct GNUNET_TIME_Relative feedback_frequency)
Generate between the source master and the partner and set property with a value depending on the gen...
Everybody can read.
GAS_solver_bulk_start s_bulk_start
Start a bulk operation.
struct GNUNET_TIME_Relative GNUNET_TIME_relative_add(struct GNUNET_TIME_Relative a1, struct GNUNET_TIME_Relative a2)
Add relative times together.
Definition: time.c:576
double prop_abs[GNUNET_ATS_PropertyCount]
void GNUNET_ATS_solver_logging_stop(struct LoggingHandle *l)
The identity of the host (wraps the signing key of the peer).
static void run(void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
int GNUNET_CONTAINER_multipeermap_contains_value(const struct GNUNET_CONTAINER_MultiPeerMap *map, const struct GNUNET_PeerIdentity *key, const void *value)
Check if the map contains the given value under the given key.
static struct PreferenceGenerator * find_pref_gen(unsigned int peer, enum GNUNET_ATS_PreferenceKind kind)
uint32_t assigned_bw_out
Outbound bandwidth assigned by solver.
struct Experiment * GNUNET_ATS_solvers_experimentation_load(char *filename)
long long unsigned int peer
void GNUNET_ATS_solver_logging_write_to_disk(struct LoggingHandle *l, int add_time_stamp, char *output_dir)
static int load_op_del_address(struct GNUNET_ATS_TEST_Operation *o, struct Episode *e, int op_counter, char *sec_name, const struct GNUNET_CONFIGURATION_Handle *cfg)
configuration data
Definition: configuration.c:85
struct TestAddress * addr_head
static void enforce_start_preference(struct GNUNET_ATS_TEST_Operation *op)
struct GNUNET_TIME_Relative GNUNET_TIME_absolute_get_duration(struct GNUNET_TIME_Absolute whence)
Get the duration of an operation as the difference of the current time and the given start time "henc...
Definition: time.c:373
void GAS_normalization_start()
Start the normalization component.
static enum GNUNET_ATS_Property parse_property_string(const char *str)
struct GNUNET_TIME_Relative frequency
static void timeout_episode(void *cls)
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_flag(char shortName, const char *name, const char *description, int *val)
Allow user to specify a flag (which internally means setting an integer to 1/GNUNET_YES/GNUNET_OK.
static double get_preference(struct PreferenceGenerator *pg)
const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration handle to be used by the solver.
#define GNUNET_log(kind,...)
GAS_solver_information_callback info_cb
Callback for solver to call with status information, can be NULL.
long long unsigned int aid
Open the file for both reading and writing.
Change the peer&#39;s bandwidth value (value per byte of bandwidth in the goal function) to the given amo...
uint32_t assigned_bw_out
static int test_address(void *cls, const struct GNUNET_HELLO_Address *address, struct GNUNET_TIME_Absolute expiration)
Test for checking whether HELLO message is empty.
int GNUNET_CONFIGURATION_get_value_filename(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, char **value)
Get a configuration value that should be the name of a file or directory.
The setup of the problem as a preparation to solve is finished.
unsigned long long out_quota[6]
Array of configured outbound quotas Order according to networks in network array. ...
static struct GNUNET_TIME_Relative duration
How long do we run the test?
struct TestPeer * next
static struct TestPeer * find_peer_by_id(int id)
int GNUNET_PROGRAM_run(int argc, char *const *argv, const char *binaryName, const char *binaryHelp, const struct GNUNET_GETOPT_CommandLineOption *options, GNUNET_PROGRAM_Main task, void *task_cls)
Run a standard GNUnet command startup sequence (initialize loggers and configuration, parse options).
Definition: program.c:361
An existing solution was reused Quite specific to the MLP solver.
struct GNUNET_TIME_Relative feedback_delay
struct TestPeer * test_peer
struct GNUNET_TIME_Relative frequency
static struct PreferenceGenerator * pref_gen_tail
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
#define GNUNET_YES
Definition: gnunet_common.h:80
static void free_experiment(struct Experiment *e)
struct GNUNET_TIME_Relative GNUNET_TIME_absolute_get_difference(struct GNUNET_TIME_Absolute start, struct GNUNET_TIME_Absolute end)
Compute the time difference between the given start and end times.
Definition: time.c:353
void * GNUNET_PLUGIN_load(const char *library_name, void *arg)
Setup plugin (runs the "init" callback and returns whatever "init" returned).
Definition: plugin.c:210
#define GNUNET_ATS_PreferenceTypeString
ATS preference types as string array initializer.
static void set_pref_task(void *cls)
#define DEFAULT_ABS_PREFERENCE
Default preference value we assume if we know nothing.
struct GNUNET_TIME_Relative log_freq
struct GNUNET_CONTAINER_MultiPeerMap * addresses
Address hashmap.
struct GNUNET_ATS_PluginEnvironment env
Solver environment.
#define DIR_SEPARATOR_STR
Definition: plibc.h:632
GNUNET_ATS_PreferenceKind
Enum defining all known preference categories.
struct GNUNET_TIME_Relative feedback_frequency
double pref_norm[GNUNET_ATS_PREFERENCE_END]
static struct GNUNET_ARM_Operation * op
Current operation.
Definition: gnunet-arm.c:139
struct GNUNET_CONTAINER_MultiPeerMap * addresses
Hashmap containing all addresses available.
static double default_preferences[GNUNET_ATS_PreferenceCount]
static struct GNUNET_PeerIdentity pid
Identity of the peer we transmit to / connect to.
struct GNUNET_SCHEDULER_Task * logging_task
long long unsigned int max_rate
int GNUNET_CONFIGURATION_get_value_yesno(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option)
Get a configuration value that should be in a set of "YES" or "NO".
double prop_norm[GNUNET_ATS_PropertyCount]
struct GNUNET_DISK_FileHandle * GNUNET_DISK_file_open(const char *fn, enum GNUNET_DISK_OpenFlags flags, enum GNUNET_DISK_AccessPermissions perm)
Open a file.
Definition: disk.c:1673
uint32_t atsi_count
ATS performance information for this address, size of the atsi array.
struct GNUNET_TIME_Relative max_duration
GAS_solver_bulk_stop s_bulk_stop
Bulk operation done.
static char * address
GNS address for this phone.
GAS_bandwidth_changed_cb bandwidth_changed_cb
ATS addresses callback to be notified about bandwidth assignment changes.
After the problem was finished, notifications about changes to addresses are done.
long long unsigned int address_session
const double * GAS_preference_get_by_peer(void *cls, const struct GNUNET_PeerIdentity *id)
Get the normalized preference values for a specific peer or the default values if.
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
#define GNUNET_NT_COUNT
struct GNUNET_TIME_Relative duration_period
unsigned int network_count
Number of networks available, size of the out_quota and in_quota arrays.
static struct TestAddress * find_address_by_id(struct TestPeer *peer, int aid)
No good quality of the operation is needed (i.e., random numbers can be pseudo-random).
double pref_norm[GNUNET_ATS_PreferenceCount]
#define GNUNET_malloc(size)
Wrapper around malloc.
static void enforce_episode(struct Episode *ep)
static void enforce_stop_preference(struct GNUNET_ATS_TEST_Operation *op)
#define GNUNET_free(ptr)
Wrapper around free.
static struct PropertyGenerator * prop_gen_head
Property Generators.
long long unsigned int id
Time for relative time used by GNUnet, in microseconds.
char * plugin
Solver plugin name.
#define gettext_noop(String)
Definition: gettext.h:69
Category of last resort.
Definition: gnunet_nt_lib.h:40
struct GNUNET_PeerIdentity peer_id
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:965