GNUnet  0.16.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)
95  {
97  return "CONSTANT";
98 
100  return "LINEAR";
101 
103  return "RANDOM";
104 
106  return "SINUS";
107 
108  default:
109  return "INVALID";
110  break;
111  }
112 }
113 
114 
115 static struct TestPeer *
117 {
118  struct TestPeer *cur;
119 
120  for (cur = peer_head; NULL != cur; cur = cur->next)
121  if (cur->id == id)
122  return cur;
123  return NULL;
124 }
125 
126 
127 static struct TestPeer *
129 {
130  struct TestPeer *cur;
131 
132  for (cur = peer_head; NULL != cur; cur = cur->next)
133  if (0 == GNUNET_memcmp (&cur->peer_id, pid))
134  return cur;
135  return NULL;
136 }
137 
138 
139 static struct TestAddress *
141 {
142  struct TestAddress *cur;
143 
144  for (cur = peer->addr_head; NULL != cur; cur = cur->next)
145  if (cur->aid == aid)
146  return cur;
147  return NULL;
148 }
149 
150 
154 void
156 {
157  struct LoggingTimeStep *lts;
158  struct TestPeer *cur;
159  struct TestAddress *cur_addr;
160  struct LoggingPeer *log_p;
161  struct LoggingAddress *log_a;
162  int c;
163 
164  lts = GNUNET_new (struct LoggingTimeStep);
167  if (NULL == lts->prev)
169  else
171 
172  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Logging %llu, delta %llu\n",
174 
175 
176  /* Store logging data here */
177  for (cur = peer_head; NULL != cur; cur = cur->next)
178  {
180  "Logging peer id %llu\n", cur->id);
181 
182  log_p = GNUNET_new (struct LoggingPeer);
183  log_p->id = cur->id;
184  log_p->peer_id = cur->peer_id;
185  log_p->is_requested = cur->is_requested;
186  for (c = 0; c < GNUNET_ATS_PreferenceCount; c++)
187  {
188  log_p->pref_abs[c] = cur->pref_abs[c];
189  log_p->pref_norm[c] = cur->pref_norm[c];
191  "\t %s = %.2f %.2f [abs/rel]\n",
193  log_p->pref_abs[c], log_p->pref_norm[c]);
194  }
195  GNUNET_CONTAINER_DLL_insert_tail (lts->head, lts->tail, log_p);
196 
197  for (cur_addr = cur->addr_head; NULL != cur_addr; cur_addr = cur_addr->next)
198  {
200  "Logging peer id %llu address %llu\n",
201  cur->id, cur_addr->aid);
202  log_a = GNUNET_new (struct LoggingAddress);
203  log_a->aid = cur_addr->aid;
204  log_a->active = cur_addr->ats_addr->active;
205  log_a->network = cur_addr->network;
206  log_a->assigned_bw_in = cur_addr->ats_addr->assigned_bw_in;
207  log_a->assigned_bw_out = cur_addr->ats_addr->assigned_bw_out;
208  for (c = 0; c < GNUNET_ATS_PropertyCount; c++)
209  {
210  log_a->prop_abs[c] = cur_addr->prop_abs[c];
211  log_a->prop_norm[c] = cur_addr->prop_norm[c];
213  "\t %s = %.2f %.2f [abs/rel]\n",
214  GNUNET_ATS_print_property_type (c),
215  log_a->prop_abs[c],
216  log_a->prop_norm[c]);
217  }
218  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "\t Active = %i\n", log_a->active);
219  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "\t BW in = %llu\n",
220  log_a->assigned_bw_in);
221  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "\t BW out = %llu\n",
222  log_a->assigned_bw_out);
223 
225  log_a);
226  }
227  }
228 }
229 
230 
231 static void
232 logging_task (void *cls)
233 {
234  struct LoggingHandle *l = cls;
235 
236  l->logging_task = NULL;
239  &logging_task,
240  l);
241 }
242 
243 
244 struct LoggingHandle *
246 {
247  struct LoggingHandle *l;
248 
249  l = GNUNET_new (struct LoggingHandle);
250 
251  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Start logging every %s\n",
253  l->log_freq = freq;
255  return l;
256 }
257 
258 
259 void
261 {
262  if (NULL != l->logging_task)
264 
265  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Stop logging\n");
266 
267  l->logging_task = NULL;
268 }
269 
270 
271 static struct LoggingFileHandle *
273  struct LoggingFileHandle *lf_tail,
274  int peer_id, int address_id)
275 {
276  struct LoggingFileHandle *res;
277 
278  for (res = lf_head; NULL != res; res = res->next)
279  if ((res->pid == peer_id) && (res->aid == address_id))
280  return res;
281  return NULL;
282 }
283 
284 
285 void
287  add_time_stamp,
288  char *output_dir)
289 {
290  struct LoggingTimeStep *lts;
291  struct LoggingPeer *log_p;
292  struct LoggingAddress *log_a;
293  struct LoggingFileHandle *lf_head;
294  struct LoggingFileHandle *lf_tail;
295  struct LoggingFileHandle *cur;
296  struct LoggingFileHandle *next;
297  char *filename;
298  char *datastring;
299  char *propstring;
300  char *propstring_tmp;
301  char *prefstring;
302  char *prefstring_tmp;
303  int c;
304  int use_dir;
305 
306  use_dir = GNUNET_NO;
307  if (NULL != output_dir)
308  {
310  {
311  fprintf (stderr, "Failed to create directory `%s'\n", output_dir);
312  return;
313  }
314  else
315  {
316  fprintf (stderr, "Created directory `%s'\n", output_dir);
317  use_dir = GNUNET_YES;
318  }
319  }
320 
321  lf_head = NULL;
322  lf_tail = NULL;
323 
324  for (lts = l->head; NULL != lts; lts = lts->next)
325  {
326  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Writing log step %llu\n",
327  (long long unsigned int) lts->timestamp.abs_value_us);
328 
329  for (log_p = lts->head; NULL != log_p; log_p = log_p->next)
330  {
331  for (log_a = log_p->addr_head; NULL != log_a; log_a = log_a->next)
332  {
333  cur = find_logging_file_handle (lf_head, lf_tail, log_p->id,
334  log_a->aid);
335  if (NULL == cur)
336  {
337  cur = GNUNET_new (struct LoggingFileHandle);
338  cur->aid = log_a->aid;
339  cur->pid = log_p->id;
340 
341  if (GNUNET_YES == add_time_stamp)
342  GNUNET_asprintf (&filename, "%s%s%s_%s_p%u_a%u_%llu.log",
343  (GNUNET_YES == use_dir) ? output_dir : "",
344  (GNUNET_YES == use_dir) ? DIR_SEPARATOR_STR : "",
345  e->log_prefix,
346  opt_solver,
347  cur->pid,
348  cur->aid,
350  else
351  GNUNET_asprintf (&filename, "%s%s%s_%s_p%u_a%u.log",
352  (GNUNET_YES == use_dir) ? output_dir : "",
353  (GNUNET_YES == use_dir) ? DIR_SEPARATOR_STR : "",
354  e->log_prefix,
355  opt_solver,
356  cur->pid,
357  cur->aid);
358 
359  fprintf (stderr,
360  "Add writing log data for peer %llu address %llu to file `%s'\n",
361  cur->pid, cur->aid, filename);
362 
363 
372  if (NULL == cur->f_hd)
373  {
374  fprintf (stderr, "Cannot open `%s' to write log data!\n", filename);
376  GNUNET_free (cur);
377  goto cleanup;
378  }
380  GNUNET_CONTAINER_DLL_insert (lf_head, lf_tail, cur);
381 
382  GNUNET_asprintf (&datastring,
383  "#time delta;log duration;peer_requested;addr net; addr_active; bw in; bw out; " \
384  "UTILIZATION_UP [abs/rel]; UTILIZATION_UP; UTILIZATION_DOWN; UTILIZATION_DOWN; " \
385  "UTILIZATION_PAYLOAD_UP; UTILIZATION_PAYLOAD_UP; UTILIZATION_PAYLOAD_DOWN; UTILIZATION_PAYLOAD_DOWN;" \
386  "DELAY; DELAY; " \
387  "DISTANCE ;DISTANCE ; COST_WAN; COST_WAN; COST_LAN; COST_LAN; " \
388  "COST_WLAN; COST_WLAN;COST_BT; COST_BT; PREF BW abs; PREF BW rel; PREF LATENCY abs; PREF LATENCY rel;\n");
389  GNUNET_DISK_file_write (cur->f_hd, datastring, strlen (datastring));
390  GNUNET_free (datastring);
391  }
392 
393  prefstring = GNUNET_strdup ("");
394  for (c = 1; c < GNUNET_ATS_PreferenceCount; c++)
395  {
396  /*
397  fprintf(stderr,"\t %s = %.2f %.2f [abs/rel]\n",
398  GNUNET_ATS_print_preference_type(c),
399  log_p->pref_abs[c], log_p->pref_norm[c]);
400  */GNUNET_asprintf (&prefstring_tmp, "%s;%.3f;%.3f",
401  prefstring, log_p->pref_abs[c], log_p->pref_norm[c]);
402 
403 
404  GNUNET_free (prefstring);
405  prefstring = GNUNET_strdup (prefstring_tmp);
406  GNUNET_free (prefstring_tmp);
407  }
408 
409 
410  propstring = GNUNET_strdup ("");
411  for (c = 1; c < GNUNET_ATS_PropertyCount; c++)
412  {
413  if (GNUNET_ATS_NETWORK_TYPE == c)
414  continue;
415  /*
416  fprintf(stderr, "\t %s = %.2f %.2f [abs/rel]\n",
417  GNUNET_ATS_print_property_type(c),
418  log_a->prop_abs[c], log_a->prop_norm[c]);*/
419  GNUNET_asprintf (&propstring_tmp, "%s%.3f;%.3f;",
420  propstring,
421  log_a->prop_abs[c],
422  log_a->prop_norm[c]);
423  GNUNET_free (propstring);
424  propstring = GNUNET_strdup (propstring_tmp);
425  GNUNET_free (propstring_tmp);
426  }
427  GNUNET_asprintf (&datastring, "%llu;%llu;%u;%u;%i;%u;%u;%s;%s\n",
429  l->head->timestamp,
430  lts->timestamp).
431  rel_value_us / 1000, lts->delta,
432  log_p->is_requested, log_a->network, log_a->active,
433  log_a->assigned_bw_in, log_a->assigned_bw_out,
434  propstring,
435  prefstring);
436 
437  GNUNET_DISK_file_write (cur->f_hd, datastring, strlen (datastring));
438  GNUNET_free (datastring);
439  GNUNET_free (prefstring);
440  GNUNET_free (propstring);
441  }
442  }
443  }
444 
445  cleanup:
446  next = lf_head;
447  for (cur = next; NULL != cur; cur = next)
448  {
449  next = cur->next;
450  GNUNET_CONTAINER_DLL_remove (lf_head, lf_tail, cur);
451  if (NULL != cur->f_hd)
453  GNUNET_free (cur);
454  }
455 }
456 
457 
458 void
460 {
461  struct LoggingTimeStep *lts;
462  struct LoggingPeer *log_p;
463  struct LoggingAddress *log_a;
464  int c;
465 
466  for (lts = l->head; NULL != lts; lts = lts->next)
467  {
468  fprintf (stderr, "Log step %llu %llu: \n",
469  (long long unsigned int) lts->timestamp.abs_value_us,
470  (long long unsigned int) lts->delta.rel_value_us);
471 
472  for (log_p = lts->head; NULL != log_p; log_p = log_p->next)
473  {
474  fprintf (stderr, "\tLogging peer pid %llu\n", log_p->id);
475  for (c = 1; c < GNUNET_ATS_PreferenceCount; c++)
476  {
477  fprintf (stderr, "\t %s = %.2f %.2f [abs/rel]\n",
479  log_p->pref_abs[c], log_p->pref_norm[c]);
480  }
481 
482  for (log_a = log_p->addr_head; NULL != log_a; log_a = log_a->next)
483  {
484  fprintf (stderr, "\tPeer pid %llu address %llu: %u %u %u\n",
485  log_p->id, log_a->aid, log_a->active,
486  log_a->assigned_bw_in,
487  log_a->assigned_bw_out);
488 
489  for (c = 1; c < GNUNET_ATS_PropertyCount; c++)
490  {
491  if (GNUNET_ATS_NETWORK_TYPE == c)
492  continue;
493  fprintf (stderr, "\t %s = %.2f %.2f [abs/rel]\n",
494  GNUNET_ATS_print_property_type (c),
495  log_a->prop_abs[c], log_a->prop_norm[c]);
496  }
497  }
498  }
499  }
500 }
501 
502 
503 void
505 {
506  struct LoggingTimeStep *lts_cur;
507  struct LoggingTimeStep *lts_next;
508  struct LoggingPeer *log_p_cur;
509  struct LoggingPeer *log_p_next;
510  struct LoggingAddress *log_a_cur;
511  struct LoggingAddress *log_a_next;
512 
513  if (NULL != l->logging_task)
515  l->logging_task = NULL;
516 
517  lts_next = l->head;
518  while (NULL != (lts_cur = lts_next))
519  {
520  lts_next = lts_cur->next;
521 
522  log_p_next = lts_cur->head;
523  while (NULL != (log_p_cur = log_p_next))
524  {
525  log_p_next = log_p_cur->next;
526 
527  log_a_next = log_p_cur->addr_head;
528  while (NULL != (log_a_cur = log_a_next))
529  {
530  log_a_next = log_a_cur->next;
531 
532  GNUNET_CONTAINER_DLL_remove (log_p_cur->addr_head, log_p_cur->addr_tail,
533  log_a_cur);
534  GNUNET_free (log_a_cur);
535  }
536 
537  GNUNET_CONTAINER_DLL_remove (lts_cur->head, lts_cur->tail, log_p_cur);
538  GNUNET_free (log_p_cur);
539  }
540 
541  GNUNET_CONTAINER_DLL_remove (l->head, l->tail, lts_cur);
542  GNUNET_free (lts_cur);
543  }
544 
545  GNUNET_free (l);
546 }
547 
548 
554 
555 
556 static double
558 {
559  struct GNUNET_TIME_Relative time_delta;
560  double delta_value;
561  double pref_value;
562 
563  /* Calculate the current preference value */
564  switch (pg->type)
565  {
567  pref_value = pg->base_value;
568  break;
569 
572  /* Calculate point of time in the current period */
573  time_delta.rel_value_us = time_delta.rel_value_us
575  delta_value = ((double) time_delta.rel_value_us
577  - pg->base_value);
578  if ((pg->max_value < pg->base_value) &&
579  ((pg->max_value - pg->base_value) > pg->base_value))
580  {
581  /* This will cause an underflow */
582  GNUNET_break (0);
583  }
584  pref_value = pg->base_value + delta_value;
585  break;
586 
589  10000 * (pg->max_value
590  - pg->base_value))
591  / 10000;
592  pref_value = pg->base_value + delta_value;
593  break;
594 
597  /* Calculate point of time in the current period */
598  time_delta.rel_value_us = time_delta.rel_value_us
600  if ((pg->max_value - pg->base_value) > pg->base_value)
601  {
602  /* This will cause an underflow for second half of sinus period,
603  * will be detected in general when experiments are loaded */
604  GNUNET_break (0);
605  }
606  delta_value = (pg->max_value - pg->base_value)
607  * sin ((2 * M_PI)
608  / ((double) pg->duration_period.rel_value_us)
609  * time_delta.rel_value_us);
610  pref_value = pg->base_value + delta_value;
611  break;
612 
613  default:
614  pref_value = 0.0;
615  break;
616  }
617  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Current property value is %f\n",
618  pref_value);
619  return pref_value;
620 }
621 
622 
623 static void
624 set_prop_task (void *cls)
625 {
626  struct PropertyGenerator *pg = cls;
627  struct TestPeer *p;
628  struct TestAddress *a;
629  double prop_value;
630  struct GNUNET_ATS_Information atsi;
631 
632  pg->set_task = NULL;
633 
635  &pg->test_peer
636  ->peer_id,
637  pg->
638  test_address->
639  ats_addr))
640  {
641  GNUNET_break (0);
643  "Setting property generation for unknown address [%u:%u]\n",
644  pg->peer, pg->address_id);
645  return;
646  }
647  if (NULL == (p = find_peer_by_id (pg->peer)))
648  {
649  GNUNET_break (0);
651  "Setting property generation for unknown peer %u\n",
652  pg->peer);
653  return;
654  }
655  if (NULL == (a = find_address_by_id (p, pg->address_id)))
656  {
657  GNUNET_break (0);
659  "Setting property generation for unknown peer %u\n",
660  pg->peer);
661  return;
662  }
663 
664  prop_value = get_property (pg);
665  a->prop_abs[pg->ats_property] = prop_value;
666 
668  "Setting property for peer [%u] address [%u] for %s to %f\n",
669  pg->peer, pg->address_id,
670  GNUNET_ATS_print_property_type (pg->ats_property), prop_value);
671 
672  atsi.type = htonl (pg->ats_property);
673  atsi.value = htonl ((uint32_t) prop_value);
674 
675  /* set performance here! */
676  sh->sf->s_bulk_start (sh->sf->cls);
678  {
679  a->prop_abs[pg->ats_property] = prop_value;
680  a->prop_norm[pg->ats_property] = prop_value;
682  pg->ats_property, prop_value,
683  prop_value);
684  }
685  else
687  sh->sf->s_bulk_stop (sh->sf->cls);
688 
690  &set_prop_task, pg);
691 }
692 
693 
697 static struct PropertyGenerator *
698 find_prop_gen (unsigned int peer, unsigned int address,
699  uint32_t ats_property)
700 {
701  struct PropertyGenerator *cur;
702 
703  for (cur = prop_gen_head; NULL != cur; cur = cur->next)
704  if ((cur->peer == peer) && (cur->address_id == address))
705  {
706  if ((cur->ats_property == ats_property) || (0 == ats_property))
707  return cur;
708  }
709  return NULL;
710 }
711 
712 
713 void
715 {
717 
718  if (NULL != pg->set_task)
719  {
721  pg->set_task = NULL;
722  }
724  "Removing old up preference generator peer [%u] address [%u] `%s'\n",
725  pg->peer, pg->address_id,
726  GNUNET_ATS_print_property_type (pg->ats_property));
727 
728  GNUNET_free (pg);
729 }
730 
731 
748 struct PropertyGenerator *
750  unsigned int address_id,
751  struct TestPeer *test_peer,
752  struct TestAddress *test_address,
753  enum GeneratorType type,
754  long int base_value,
755  long int value_rate,
756  struct GNUNET_TIME_Relative period,
757  struct GNUNET_TIME_Relative
758  frequency,
759  uint32_t ats_property)
760 {
761  struct PropertyGenerator *pg;
762 
763  pg = GNUNET_new (struct PropertyGenerator);
765  pg->type = type;
766  pg->peer = peer;
768  pg->test_peer = test_peer;
769  pg->address_id = address_id;
771  pg->base_value = base_value;
772  pg->max_value = value_rate;
773  pg->duration_period = period;
774  pg->frequency = frequency;
776 
777  switch (type)
778  {
781  "Setting up %s property generator peer [%u] address [%u] `%s'" \
782  "max %u Bips\n",
784  GNUNET_ATS_print_property_type (ats_property),
785  base_value);
786  break;
787 
790  "Setting up %s property generator peer [%u] address [%u] `%s' " \
791  "min %u Bips max %u Bips\n",
793  GNUNET_ATS_print_property_type (ats_property),
794  base_value, value_rate);
795  break;
796 
799  "Setting up %s property generator peer [%u] address [%u] `%s' " \
800  "baserate %u Bips, amplitude %u Bps\n",
802  GNUNET_ATS_print_property_type (ats_property),
803  base_value, value_rate);
804  break;
805 
808  "Setting up %s property generator peer [%u] address [%u] `%s' " \
809  "min %u Bips max %u Bps\n",
811  GNUNET_ATS_print_property_type (ats_property),
812  base_value, value_rate);
813  break;
814 
815  default:
816  break;
817  }
818 
820  return pg;
821 }
822 
823 
827 void
829 {
830  struct PropertyGenerator *cur;
831  struct PropertyGenerator *next;
832 
834  for (cur = next; NULL != cur; cur = next)
835  {
836  next = cur->next;
838  }
839 }
840 
841 
847 
848 
849 static double
851 {
852  struct GNUNET_TIME_Relative time_delta;
853  double delta_value;
854  double pref_value;
855 
856  /* Calculate the current preference value */
857  switch (pg->type)
858  {
860  pref_value = pg->base_value;
861  break;
862 
865  /* Calculate point of time in the current period */
866  time_delta.rel_value_us = time_delta.rel_value_us
868  delta_value = ((double) time_delta.rel_value_us
870  - pg->base_value);
871  if ((pg->max_value < pg->base_value) &&
872  ((pg->max_value - pg->base_value) > pg->base_value))
873  {
874  /* This will cause an underflow */
875  GNUNET_break (0);
876  }
877  pref_value = pg->base_value + delta_value;
878  break;
879 
882  10000 * (pg->max_value
883  - pg->base_value))
884  / 10000;
885  pref_value = pg->base_value + delta_value;
886  break;
887 
890  /* Calculate point of time in the current period */
891  time_delta.rel_value_us = time_delta.rel_value_us
893  if ((pg->max_value - pg->base_value) > pg->base_value)
894  {
895  /* This will cause an underflow for second half of sinus period,
896  * will be detected in general when experiments are loaded */
897  GNUNET_break (0);
898  }
899  delta_value = (pg->max_value - pg->base_value)
900  * sin ((2 * M_PI)
901  / ((double) pg->duration_period.rel_value_us)
902  * time_delta.rel_value_us);
903  pref_value = pg->base_value + delta_value;
904  break;
905 
906  default:
907  pref_value = 0.0;
908  break;
909  }
910  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Current preference value is %f\n",
911  pref_value);
912  return pref_value;
913 }
914 
915 
916 static void
917 set_feedback_task (void *cls)
918 {
919  struct PreferenceGenerator *pg = cls;
920  struct TestPeer *p;
921  double feedback;
922  uint32_t bw_acc_out;
923  uint32_t bw_acc_in;
924  uint32_t delay_acc_in;
925  struct GNUNET_TIME_Relative dur;
926  double p_new;
927 
928  pg->feedback_task = NULL;
929 
930  if (NULL == (p = find_peer_by_id (pg->peer)))
931  {
932  GNUNET_break (0);
934  "Setting feedback for unknown peer %u\n", pg->peer);
935  return;
936  }
937 
938  switch (pg->kind)
939  {
942  bw_acc_in = dur.rel_value_us * pg->last_assigned_bw_in
943  + pg->feedback_bw_in_acc;
944  pg->feedback_bw_in_acc = 0;
945 
946  bw_acc_out = dur.rel_value_us * pg->last_assigned_bw_out
947  + pg->feedback_bw_out_acc;
948  p_new = get_preference (pg);
949  feedback = (p_new / pg->pref_bw_old) * (bw_acc_in + bw_acc_out)
952 
953  break;
954 
957  delay_acc_in = dur.rel_value_us * pg->last_delay_value
958  + pg->feedback_delay_acc;
959  pg->feedback_delay_acc = 0;
960 
961  p_new = get_preference (pg);
962  feedback = (p_new / pg->pref_latency_old) * (delay_acc_in)
965 
966  break;
967 
968  default:
969  GNUNET_break (0);
970  feedback = 0.0;
971  break;
972  }
974  "Giving feedback for peer [%u] for client %p pref %s of %.3f\n",
975  pg->peer, NULL + (pg->client_id),
977  feedback);
978 
979  sh->sf->s_feedback (sh->sf->cls, NULL + (pg->client_id), &p->peer_id,
980  pg->feedback_frequency, pg->kind, feedback);
982 
983 
984  pg->feedback_bw_out_acc = 0;
985  pg->feedback_bw_in_acc = 0;
987 
988  pg->feedback_delay_acc = 0;
990 
991 
993  &set_feedback_task, pg);
994 }
995 
996 
997 static void
998 set_pref_task (void *cls)
999 {
1000  struct PreferenceGenerator *pg = cls;
1001  struct TestPeer *p;
1002  double pref_value;
1003 
1004  pg->set_task = NULL;
1005 
1006  if (NULL == (p = find_peer_by_id (pg->peer)))
1007  {
1008  GNUNET_break (0);
1010  "Setting preference for unknown peer %u\n", pg->peer);
1011  return;
1012  }
1013 
1014  pref_value = get_preference (pg);
1015  switch (pg->kind)
1016  {
1018  pg->pref_bw_old = pref_value;
1019  break;
1020 
1022  pg->pref_latency_old = pref_value;
1023  break;
1024 
1025  default:
1026  break;
1027  }
1028 
1029  p->pref_abs[pg->kind] = pref_value;
1030 
1032  "Setting preference for peer [%u] for client %p pref %s to %f\n",
1033  pg->peer, NULL + (pg->client_id),
1034  GNUNET_ATS_print_preference_type (pg->kind), pref_value);
1035 
1037  {
1038  p->pref_abs[pg->kind] = pref_value;
1039  p->pref_norm[pg->kind] = pref_value;
1040  sh->sf->s_pref (sh->sf->cls, &p->peer_id, pg->kind, pref_value);
1041  }
1042  else
1043  update_preference (NULL + (pg->client_id),
1044  &p->peer_id,
1045  pg->kind,
1046  pref_value);
1047 
1049  &set_pref_task,
1050  pg);
1051 }
1052 
1053 
1054 static struct PreferenceGenerator *
1056 {
1057  struct PreferenceGenerator *cur;
1058 
1059  for (cur = pref_gen_head; NULL != cur; cur = cur->next)
1060  if (cur->peer == peer)
1061  {
1062  if ((cur->kind == kind) || (GNUNET_ATS_PREFERENCE_END == kind))
1063  return cur;
1064  }
1065  return NULL;
1066 }
1067 
1068 
1069 void
1071 {
1073 
1074  if (NULL != pg->feedback_task)
1075  {
1077  pg->feedback_task = NULL;
1078  }
1079 
1080  if (NULL != pg->set_task)
1081  {
1083  pg->set_task = NULL;
1084  }
1086  "Removing old up preference generator peer [%u] `%s'\n",
1088 
1089  GNUNET_free (pg);
1090 }
1091 
1092 
1093 static struct TestAddress*
1095 {
1096  struct TestAddress *cur;
1097 
1098  for (cur = p->addr_head; NULL != cur; cur = cur->next)
1099  if (GNUNET_YES == cur->ats_addr->active)
1100  return cur;
1101  return NULL;
1102 }
1103 
1104 
1121 struct PreferenceGenerator *
1123  unsigned int address_id,
1124  unsigned int client_id,
1125  enum GeneratorType type,
1126  long int base_value,
1127  long int value_rate,
1128  struct GNUNET_TIME_Relative
1129  period,
1130  struct GNUNET_TIME_Relative
1131  frequency,
1133  kind,
1134  struct GNUNET_TIME_Relative
1136 {
1137  struct PreferenceGenerator *pg;
1138  struct TestPeer *p;
1139 
1140  if (NULL == (p = find_peer_by_id (peer)))
1141  {
1142  GNUNET_break (0);
1144  "Starting preference for unknown peer %u\n", peer);
1145  return NULL;
1146  }
1147 
1148  pg = GNUNET_new (struct PreferenceGenerator);
1150  pg->type = type;
1151  pg->peer = peer;
1152  pg->client_id = client_id;
1153  pg->kind = kind;
1154  pg->base_value = base_value;
1155  pg->max_value = value_rate;
1156  pg->duration_period = period;
1157  pg->frequency = frequency;
1159  pg->feedback_frequency = feedback_frequency;
1160 
1161  switch (type)
1162  {
1165  "Setting up %s preference generator peer [%u] `%s' max %u Bips\n",
1168  base_value);
1169  break;
1170 
1173  "Setting up %s preference generator peer [%u] `%s' min %u Bips max %u Bips\n",
1176  base_value, value_rate);
1177  break;
1178 
1181  "Setting up %s preference generator peer [%u] `%s' baserate %u Bips, amplitude %u Bps\n",
1184  base_value, value_rate);
1185  break;
1186 
1189  "Setting up %s preference generator peer [%u] `%s' min %u Bips max %u Bps\n",
1192  base_value, value_rate);
1193  break;
1194 
1195  default:
1196  break;
1197  }
1198 
1200  if (GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us !=
1201  feedback_frequency.rel_value_us)
1202  {
1203  struct TestAddress *addr = find_active_address (p);
1204 
1205  pg->last_assigned_bw_in = p->assigned_bw_in;
1206  pg->last_assigned_bw_out = p->assigned_bw_out;
1207  pg->feedback_bw_in_acc = 0;
1208  pg->feedback_bw_out_acc = 0;
1209  pg->last_delay_value = addr->prop_norm[GNUNET_ATS_QUALITY_NET_DELAY];
1210  pg->feedback_delay_acc = 0;
1211 
1215  pg->feedback_task = GNUNET_SCHEDULER_add_delayed (feedback_frequency,
1216  &set_feedback_task, pg);
1217  }
1218 
1219  return pg;
1220 }
1221 
1222 
1226 void
1228 {
1229  struct PreferenceGenerator *cur;
1230  struct PreferenceGenerator *next;
1231 
1232  next = pref_gen_head;
1233  for (cur = next; NULL != cur; cur = next)
1234  {
1235  next = cur->next;
1237  }
1238 }
1239 
1240 
1244 static const char *
1246 {
1247  switch (op)
1248  {
1249  case SOLVER_OP_ADD_ADDRESS:
1250  return "ADD_ADDRESS";
1251 
1252  case SOLVER_OP_DEL_ADDRESS:
1253  return "DEL_ADDRESS";
1254 
1256  return "START_SET_PREFERENCE";
1257 
1259  return "STOP_STOP_PREFERENCE";
1260 
1262  return "START_SET_PROPERTY";
1263 
1265  return "STOP_SET_PROPERTY";
1266 
1268  return "START_REQUEST";
1269 
1271  return "STOP_REQUEST";
1272 
1273  default:
1274  break;
1275  }
1276  return "";
1277 }
1278 
1279 
1280 static struct Experiment *
1282 {
1283  struct Experiment *e;
1284 
1285  e = GNUNET_new (struct Experiment);
1286  e->name = NULL;
1287  e->start = NULL;
1289  return e;
1290 }
1291 
1292 
1293 static void
1295 {
1296  struct Episode *cur;
1297  struct Episode *next;
1298  struct GNUNET_ATS_TEST_Operation *cur_o;
1299  struct GNUNET_ATS_TEST_Operation *next_o;
1300 
1301  next = e->start;
1302  for (cur = next; NULL != cur; cur = next)
1303  {
1304  next = cur->next;
1305 
1306  next_o = cur->head;
1307  for (cur_o = next_o; NULL != cur_o; cur_o = next_o)
1308  {
1309  next_o = cur_o->next;
1310  GNUNET_free (cur_o->address);
1311  GNUNET_free (cur_o->plugin);
1312  GNUNET_free (cur_o);
1313  }
1314  GNUNET_free (cur);
1315  }
1316 
1317  GNUNET_free (e->name);
1320  GNUNET_free (e->cfg_file);
1321  GNUNET_free (e);
1322 }
1323 
1324 
1325 static int
1327  struct Episode *e,
1328  int op_counter,
1329  char *sec_name,
1330  const struct GNUNET_CONFIGURATION_Handle *cfg)
1331 {
1332  char *op_name;
1333  char *op_network;
1334 
1335  /* peer pid */
1336  GNUNET_asprintf (&op_name, "op-%u-peer-id", op_counter);
1338  sec_name, op_name,
1339  &o->peer_id))
1340  {
1341  fprintf (stderr, "Missing peer-id in operation %u `%s' in episode `%s'\n",
1342  op_counter, "ADD_ADDRESS", op_name);
1343  GNUNET_free (op_name);
1344  return GNUNET_SYSERR;
1345  }
1346  GNUNET_free (op_name);
1347 
1348  /* address pid */
1349  GNUNET_asprintf (&op_name, "op-%u-address-id", op_counter);
1351  sec_name, op_name,
1352  &o->address_id))
1353  {
1354  fprintf (stderr,
1355  "Missing address-id in operation %u `%s' in episode `%s'\n",
1356  op_counter, "ADD_ADDRESS", op_name);
1357  GNUNET_free (op_name);
1358  return GNUNET_SYSERR;
1359  }
1360  GNUNET_free (op_name);
1361 
1362  /* plugin */
1363  GNUNET_asprintf (&op_name, "op-%u-plugin", op_counter);
1365  sec_name, op_name,
1366  &o->plugin))
1367  {
1368  fprintf (stderr, "Missing plugin in operation %u `%s' in episode `%s'\n",
1369  op_counter, "ADD_ADDRESS", op_name);
1370  GNUNET_free (op_name);
1371  return GNUNET_SYSERR;
1372  }
1373  GNUNET_free (op_name);
1374 
1375  /* address */
1376  GNUNET_asprintf (&op_name, "op-%u-address", op_counter);
1378  sec_name, op_name,
1379  &o->address))
1380  {
1381  fprintf (stderr, "Missing address in operation %u `%s' in episode `%s'\n",
1382  op_counter, "ADD_ADDRESS", op_name);
1383  GNUNET_free (op_name);
1384  return GNUNET_SYSERR;
1385  }
1386  GNUNET_free (op_name);
1387 
1388  /* session */
1389  GNUNET_asprintf (&op_name, "op-%u-address-session", op_counter);
1391  sec_name, op_name,
1392  &o->
1393  address_session))
1394  {
1395  fprintf (stderr,
1396  "Missing address-session in operation %u `%s' in episode `%s'\n",
1397  op_counter, "ADD_ADDRESS", op_name);
1398  GNUNET_free (op_name);
1399  return GNUNET_SYSERR;
1400  }
1401  GNUNET_free (op_name);
1402 
1403  /* network */
1404  GNUNET_asprintf (&op_name, "op-%u-address-network", op_counter);
1406  sec_name, op_name,
1407  &op_network))
1408  {
1409  fprintf (stderr,
1410  "Missing address-network in operation %u `%s' in episode `%s'\n",
1411  op_counter, "ADD_ADDRESS", op_name);
1412  GNUNET_free (op_name);
1413  return GNUNET_SYSERR;
1414  }
1415  else
1416  {
1418  op_network));
1419  if (0 == strcmp (op_network, "UNSPECIFIED"))
1420  {
1422  }
1423  else if (0 == strcmp (op_network, "LOOPBACK"))
1424  {
1426  }
1427  else if (0 == strcmp (op_network, "LAN"))
1428  {
1430  }
1431  else if (0 == strcmp (op_network, "WAN"))
1432  {
1434  }
1435  else if (0 == strcmp (op_network, "WLAN"))
1436  {
1438  }
1439  else if (0 == strcmp (op_network, "BT"))
1440  {
1442  }
1443  else
1444  {
1445  fprintf (stderr,
1446  "Invalid address-network in operation %u `%s' in episode `%s': `%s'\n",
1447  op_counter, "ADD_ADDRESS", op_name, op_network);
1448  GNUNET_free (op_network);
1449  GNUNET_free (op_name);
1450  return GNUNET_SYSERR;
1451  }
1452  }
1453  GNUNET_free (op_network);
1454  GNUNET_free (op_name);
1455 
1457  "Found operation %s: [%llu:%llu] address `%s' plugin `%s' \n",
1458  "ADD_ADDRESS", o->peer_id, o->address_id, o->address, o->plugin);
1459 
1460  return GNUNET_OK;
1461 }
1462 
1463 
1464 static int
1466  struct Episode *e,
1467  int op_counter,
1468  char *sec_name,
1469  const struct GNUNET_CONFIGURATION_Handle *cfg)
1470 {
1471  char *op_name;
1472 
1473  // char *op_network;
1474 
1475  /* peer pid */
1476  GNUNET_asprintf (&op_name, "op-%u-peer-id", op_counter);
1478  sec_name, op_name,
1479  &o->peer_id))
1480  {
1481  fprintf (stderr, "Missing peer-id in operation %u `%s' in episode `%s'\n",
1482  op_counter, "DEL_ADDRESS", op_name);
1483  GNUNET_free (op_name);
1484  return GNUNET_SYSERR;
1485  }
1486  GNUNET_free (op_name);
1487 
1488  /* address pid */
1489  GNUNET_asprintf (&op_name, "op-%u-address-id", op_counter);
1491  sec_name, op_name,
1492  &o->address_id))
1493  {
1494  fprintf (stderr,
1495  "Missing address-id in operation %u `%s' in episode `%s'\n",
1496  op_counter, "DEL_ADDRESS", op_name);
1497  GNUNET_free (op_name);
1498  return GNUNET_SYSERR;
1499  }
1500  GNUNET_free (op_name);
1501 
1502 #if 0
1503  /* plugin */
1504  GNUNET_asprintf (&op_name, "op-%u-plugin", op_counter);
1506  sec_name, op_name,
1507  &o->plugin))
1508  {
1509  fprintf (stderr, "Missing plugin in operation %u `%s' in episode `%s'\n",
1510  op_counter, "DEL_ADDRESS", op_name);
1511  GNUNET_free (op_name);
1512  return GNUNET_SYSERR;
1513  }
1514  GNUNET_free (op_name);
1515 
1516  /* address */
1517  GNUNET_asprintf (&op_name, "op-%u-address", op_counter);
1519  sec_name, op_name,
1520  &o->address))
1521  {
1522  fprintf (stderr, "Missing address in operation %u `%s' in episode `%s'\n",
1523  op_counter, "DEL_ADDRESS", op_name);
1524  GNUNET_free (op_name);
1525  return GNUNET_SYSERR;
1526  }
1527  GNUNET_free (op_name);
1528 
1529  /* session */
1530  GNUNET_asprintf (&op_name, "op-%u-address-session", op_counter);
1532  sec_name, op_name,
1533  &o->
1534  address_session))
1535  {
1536  fprintf (stderr,
1537  "Missing address-session in operation %u `%s' in episode `%s'\n",
1538  op_counter, "DEL_ADDRESS", op_name);
1539  GNUNET_free (op_name);
1540  return GNUNET_SYSERR;
1541  }
1542  GNUNET_free (op_name);
1543 #endif
1544 
1546  "Found operation %s: [%llu:%llu] address `%s' plugin `%s' \n",
1547  "DEL_ADDRESS", o->peer_id, o->address_id, o->address, o->plugin);
1548 
1549  return GNUNET_OK;
1550 }
1551 
1552 
1553 static enum GNUNET_ATS_Property
1554 parse_preference_string (const char *str)
1555 {
1556  int c = 0;
1557  char *props[GNUNET_ATS_PreferenceCount] = GNUNET_ATS_PreferenceTypeString;
1558 
1559  for (c = 0; c < GNUNET_ATS_PreferenceCount; c++)
1560  if (0 == strcmp (str, props[c]))
1561  return c;
1562  return 0;
1563 }
1564 
1565 
1566 static int
1568  struct Episode *e,
1569  int op_counter,
1570  char *sec_name,
1571  const struct GNUNET_CONFIGURATION_Handle *cfg)
1572 {
1573  char *op_name;
1574  char *type;
1575  char *pref;
1576 
1577  /* peer pid */
1578  GNUNET_asprintf (&op_name, "op-%u-peer-id", op_counter);
1580  sec_name, op_name,
1581  &o->peer_id))
1582  {
1583  fprintf (stderr, "Missing peer-id in operation %u `%s' in episode `%s'\n",
1584  op_counter, "START_SET_PREFERENCE", op_name);
1585  GNUNET_free (op_name);
1586  return GNUNET_SYSERR;
1587  }
1588  GNUNET_free (op_name);
1589 
1590  /* address pid */
1591  GNUNET_asprintf (&op_name, "op-%u-client-id", op_counter);
1593  sec_name, op_name,
1594  &o->client_id))
1595  {
1596  fprintf (stderr, "Missing client-id in operation %u `%s' in episode `%s'\n",
1597  op_counter, "START_SET_PREFERENCE", op_name);
1598  GNUNET_free (op_name);
1599  return GNUNET_SYSERR;
1600  }
1601  GNUNET_free (op_name);
1602 
1603  /* generator */
1604  GNUNET_asprintf (&op_name, "op-%u-gen-type", op_counter);
1606  sec_name,
1607  op_name, &type)))
1608  {
1609  fprintf (stderr, "Missing type in operation %u `%s' in episode `%s'\n",
1610  op_counter, "START_SET_PREFERENCE", op_name);
1611  GNUNET_free (op_name);
1612  return GNUNET_SYSERR;
1613  }
1614 
1615  /* Load arguments for set_rate, start_send, set_preference */
1616  if (0 == strcmp (type, "constant"))
1617  {
1619  }
1620  else if (0 == strcmp (type, "linear"))
1621  {
1623  }
1624  else if (0 == strcmp (type, "sinus"))
1625  {
1627  }
1628  else if (0 == strcmp (type, "random"))
1629  {
1631  }
1632  else
1633  {
1634  fprintf (stderr, "Invalid generator type %u `%s' in episode %u\n",
1635  op_counter, op_name, e->id);
1636  GNUNET_free (type);
1637  GNUNET_free (op_name);
1638  return GNUNET_SYSERR;
1639  }
1640  GNUNET_free (type);
1641  GNUNET_free (op_name);
1642 
1643 
1644  /* Get base rate */
1645  GNUNET_asprintf (&op_name, "op-%u-base-rate", op_counter);
1647  sec_name, op_name,
1648  &o->base_rate))
1649  {
1650  fprintf (stderr, "Missing base rate in operation %u `%s' in episode %u\n",
1651  op_counter, op_name, e->id);
1652  GNUNET_free (op_name);
1653  return GNUNET_SYSERR;
1654  }
1655  GNUNET_free (op_name);
1656 
1657 
1658  /* Get max rate */
1659  GNUNET_asprintf (&op_name, "op-%u-max-rate", op_counter);
1661  sec_name, op_name,
1662  &o->max_rate))
1663  {
1664  if ((GNUNET_ATS_TEST_TG_LINEAR == o->gen_type) ||
1667  {
1668  fprintf (stderr, "Missing max rate in operation %u `%s' in episode %u\n",
1669  op_counter, op_name, e->id);
1670  GNUNET_free (op_name);
1671  return GNUNET_SYSERR;
1672  }
1673  }
1674  GNUNET_free (op_name);
1675 
1676  /* Get period */
1677  GNUNET_asprintf (&op_name, "op-%u-period", op_counter);
1679  sec_name, op_name,
1680  &o->period))
1681  {
1682  o->period = e->duration;
1683  }
1684  GNUNET_free (op_name);
1685 
1686  /* Get frequency */
1687  GNUNET_asprintf (&op_name, "op-%u-frequency", op_counter);
1689  sec_name, op_name,
1690  &o->frequency))
1691  {
1692  fprintf (stderr, "Missing frequency in operation %u `%s' in episode %u\n",
1693  op_counter, op_name, e->id);
1694  GNUNET_free (op_name);
1695  return GNUNET_SYSERR;
1696  }
1697  GNUNET_free (op_name);
1698 
1699  /* Get preference */
1700  GNUNET_asprintf (&op_name, "op-%u-pref", op_counter);
1702  sec_name, op_name,
1703  &pref))
1704  {
1705  fprintf (stderr, "Missing preference in operation %u `%s' in episode %u\n",
1706  op_counter, op_name, e->id);
1707  GNUNET_free (op_name);
1708  return GNUNET_SYSERR;
1709  }
1710 
1711  if (0 == (o->pref_type = parse_preference_string (pref)))
1712  {
1713  fprintf (stderr, "Invalid preference in operation %u `%s' in episode %u\n",
1714  op_counter, op_name, e->id);
1715  GNUNET_free (op_name);
1716  GNUNET_free (pref);
1717  return GNUNET_SYSERR;
1718  }
1719  GNUNET_free (pref);
1720  GNUNET_free (op_name);
1721 
1722  /* Get feedback delay */
1723  GNUNET_asprintf (&op_name, "op-%u-feedback_delay", op_counter);
1725  sec_name, op_name,
1726  &o->feedback_delay))
1727  {
1728  fprintf (stderr,
1729  "Using feedback delay %llu in operation %u `%s' in episode %u\n",
1730  (long long unsigned int) o->feedback_delay.rel_value_us,
1731  op_counter, op_name, e->id);
1732  }
1733  else
1735  GNUNET_free (op_name);
1736 
1738  "Found operation %s: [%llu:%llu]: %s = %llu\n",
1739  "START_SET_PREFERENCE", o->peer_id, o->address_id,
1741 
1742  return GNUNET_OK;
1743 }
1744 
1745 
1746 static int
1748  struct Episode *e,
1749  int op_counter,
1750  char *sec_name,
1751  const struct GNUNET_CONFIGURATION_Handle *cfg)
1752 {
1753  char *op_name;
1754  char *pref;
1755 
1756  /* peer pid */
1757  GNUNET_asprintf (&op_name, "op-%u-peer-id", op_counter);
1759  sec_name, op_name,
1760  &o->peer_id))
1761  {
1762  fprintf (stderr, "Missing peer-id in operation %u `%s' in episode `%s'\n",
1763  op_counter, "STOP_SET_PREFERENCE", op_name);
1764  GNUNET_free (op_name);
1765  return GNUNET_SYSERR;
1766  }
1767  GNUNET_free (op_name);
1768 
1769  /* address pid */
1770  GNUNET_asprintf (&op_name, "op-%u-address-id", op_counter);
1772  sec_name, op_name,
1773  &o->address_id))
1774  {
1775  fprintf (stderr,
1776  "Missing address-id in operation %u `%s' in episode `%s'\n",
1777  op_counter, "STOP_SET_PREFERENCE", op_name);
1778  GNUNET_free (op_name);
1779  return GNUNET_SYSERR;
1780  }
1781  GNUNET_free (op_name);
1782 
1783  /* Get preference */
1784  GNUNET_asprintf (&op_name, "op-%u-pref", op_counter);
1786  sec_name, op_name,
1787  &pref))
1788  {
1789  fprintf (stderr,
1790  "Missing preference in operation %u `%s' in episode `%s'\n",
1791  op_counter, "STOP_SET_PREFERENCE", op_name);
1792  GNUNET_free (op_name);
1793  return GNUNET_SYSERR;
1794  }
1795 
1796  if (0 == (o->pref_type = parse_preference_string (pref)))
1797  {
1798  fprintf (stderr, "Invalid preference in operation %u `%s' in episode %u\n",
1799  op_counter, op_name, e->id);
1800  GNUNET_free (op_name);
1801  GNUNET_free (pref);
1802  return GNUNET_SYSERR;
1803  }
1804  GNUNET_free (pref);
1805  GNUNET_free (op_name);
1806 
1808  "Found operation %s: [%llu:%llu]: %s\n",
1809  "STOP_SET_PREFERENCE", o->peer_id, o->address_id,
1811  return GNUNET_OK;
1812 }
1813 
1814 
1815 static enum GNUNET_ATS_Property
1816 parse_property_string (const char *str)
1817 {
1818  enum GNUNET_ATS_Property c;
1819 
1820  for (c = 0; c < GNUNET_ATS_PropertyCount; c++)
1821  if (0 == strcmp (str,
1822  GNUNET_ATS_print_property_type (c)))
1823  return c;
1824  return 0;
1825 }
1826 
1827 
1828 static int
1830  struct Episode *e,
1831  int op_counter,
1832  char *sec_name,
1833  const struct GNUNET_CONFIGURATION_Handle *cfg)
1834 {
1835  char *op_name;
1836  char *type;
1837  char *prop;
1838 
1839  /* peer pid */
1840  GNUNET_asprintf (&op_name, "op-%u-peer-id", op_counter);
1842  sec_name, op_name,
1843  &o->peer_id))
1844  {
1845  fprintf (stderr, "Missing peer-id in operation %u `%s' in episode `%s'\n",
1846  op_counter, "START_SET_PROPERTY", op_name);
1847  GNUNET_free (op_name);
1848  return GNUNET_SYSERR;
1849  }
1850  GNUNET_free (op_name);
1851 
1852  /* address pid */
1853  GNUNET_asprintf (&op_name, "op-%u-address-id", op_counter);
1855  sec_name, op_name,
1856  &o->address_id))
1857  {
1858  fprintf (stderr,
1859  "Missing address-id in operation %u `%s' in episode `%s'\n",
1860  op_counter, "START_SET_PROPERTY", op_name);
1861  GNUNET_free (op_name);
1862  return GNUNET_SYSERR;
1863  }
1864  GNUNET_free (op_name);
1865 
1866  /* generator */
1867  GNUNET_asprintf (&op_name, "op-%u-gen-type", op_counter);
1869  sec_name,
1870  op_name, &type)))
1871  {
1872  fprintf (stderr, "Missing type in operation %u `%s' in episode `%s'\n",
1873  op_counter, "START_SET_PROPERTY", op_name);
1874  GNUNET_free (op_name);
1875  return GNUNET_SYSERR;
1876  }
1877 
1878  /* Load arguments for set_rate, start_send, set_preference */
1879  if (0 == strcmp (type, "constant"))
1880  {
1882  }
1883  else if (0 == strcmp (type, "linear"))
1884  {
1886  }
1887  else if (0 == strcmp (type, "sinus"))
1888  {
1890  }
1891  else if (0 == strcmp (type, "random"))
1892  {
1894  }
1895  else
1896  {
1897  fprintf (stderr, "Invalid generator type %u `%s' in episode %u\n",
1898  op_counter, op_name, e->id);
1899  GNUNET_free (type);
1900  GNUNET_free (op_name);
1901  return GNUNET_SYSERR;
1902  }
1903  GNUNET_free (type);
1904  GNUNET_free (op_name);
1905 
1906 
1907  /* Get base rate */
1908  GNUNET_asprintf (&op_name, "op-%u-base-rate", op_counter);
1910  sec_name, op_name,
1911  &o->base_rate))
1912  {
1913  fprintf (stderr, "Missing base rate in operation %u `%s' in episode %u\n",
1914  op_counter, op_name, e->id);
1915  GNUNET_free (op_name);
1916  return GNUNET_SYSERR;
1917  }
1918  GNUNET_free (op_name);
1919 
1920 
1921  /* Get max rate */
1922  GNUNET_asprintf (&op_name, "op-%u-max-rate", op_counter);
1924  sec_name, op_name,
1925  &o->max_rate))
1926  {
1927  if ((GNUNET_ATS_TEST_TG_LINEAR == o->gen_type) ||
1930  {
1931  fprintf (stderr, "Missing max rate in operation %u `%s' in episode %u\n",
1932  op_counter, op_name, e->id);
1933  GNUNET_free (op_name);
1934  return GNUNET_SYSERR;
1935  }
1936  }
1937  GNUNET_free (op_name);
1938 
1939  /* Get period */
1940  GNUNET_asprintf (&op_name, "op-%u-period", op_counter);
1942  sec_name, op_name,
1943  &o->period))
1944  {
1945  o->period = e->duration;
1946  }
1947  GNUNET_free (op_name);
1948 
1949  /* Get frequency */
1950  GNUNET_asprintf (&op_name, "op-%u-frequency", op_counter);
1952  sec_name, op_name,
1953  &o->frequency))
1954  {
1955  fprintf (stderr, "Missing frequency in operation %u `%s' in episode %u\n",
1956  op_counter, op_name, e->id);
1957  GNUNET_free (op_name);
1958  return GNUNET_SYSERR;
1959  }
1960  GNUNET_free (op_name);
1961 
1962  /* Get preference */
1963  GNUNET_asprintf (&op_name, "op-%u-property", op_counter);
1965  sec_name, op_name,
1966  &prop))
1967  {
1968  fprintf (stderr, "Missing property in operation %u `%s' in episode %u\n",
1969  op_counter, op_name, e->id);
1970  GNUNET_free (op_name);
1971  GNUNET_free (prop);
1972  return GNUNET_SYSERR;
1973  }
1974 
1975  if (0 == (o->prop_type = parse_property_string (prop)))
1976  {
1977  fprintf (stderr, "Invalid property in operation %u `%s' in episode %u\n",
1978  op_counter, op_name, e->id);
1979  GNUNET_free (op_name);
1980  GNUNET_free (prop);
1981  return GNUNET_SYSERR;
1982  }
1983 
1984  GNUNET_free (prop);
1985  GNUNET_free (op_name);
1986 
1988  "Found operation %s: [%llu:%llu] %s = %llu\n",
1989  "START_SET_PROPERTY", o->peer_id, o->address_id,
1990  GNUNET_ATS_print_property_type (o->prop_type), o->base_rate);
1991 
1992  return GNUNET_OK;
1993 }
1994 
1995 
1996 static int
1998  struct Episode *e,
1999  int op_counter,
2000  char *sec_name,
2001  const struct GNUNET_CONFIGURATION_Handle *cfg)
2002 {
2003  char *op_name;
2004  char *pref;
2005 
2006  /* peer pid */
2007  GNUNET_asprintf (&op_name, "op-%u-peer-id", op_counter);
2009  sec_name, op_name,
2010  &o->peer_id))
2011  {
2012  fprintf (stderr, "Missing peer-id in operation %u `%s' in episode `%s'\n",
2013  op_counter, "STOP_SET_PROPERTY", op_name);
2014  GNUNET_free (op_name);
2015  return GNUNET_SYSERR;
2016  }
2017  GNUNET_free (op_name);
2018 
2019  /* address pid */
2020  GNUNET_asprintf (&op_name, "op-%u-address-id", op_counter);
2022  sec_name, op_name,
2023  &o->address_id))
2024  {
2025  fprintf (stderr,
2026  "Missing address-id in operation %u `%s' in episode `%s'\n",
2027  op_counter, "STOP_SET_PROPERTY", op_name);
2028  GNUNET_free (op_name);
2029  return GNUNET_SYSERR;
2030  }
2031  GNUNET_free (op_name);
2032 
2033  /* Get property */
2034  GNUNET_asprintf (&op_name, "op-%u-property", op_counter);
2036  sec_name, op_name,
2037  &pref))
2038  {
2039  fprintf (stderr, "Missing property in operation %u `%s' in episode `%s'\n",
2040  op_counter, "STOP_SET_PROPERTY", op_name);
2041  GNUNET_free (op_name);
2042  GNUNET_free (pref);
2043  return GNUNET_SYSERR;
2044  }
2045 
2046  if (0 == (o->prop_type = parse_property_string (pref)))
2047  {
2048  fprintf (stderr, "Invalid property in operation %u `%s' in episode %u\n",
2049  op_counter, op_name, e->id);
2050  GNUNET_free (op_name);
2051  GNUNET_free (pref);
2052  return GNUNET_SYSERR;
2053  }
2054 
2055  GNUNET_free (pref);
2056  GNUNET_free (op_name);
2057 
2059  "Found operation %s: [%llu:%llu] %s\n",
2060  "STOP_SET_PROPERTY", o->peer_id, o->address_id,
2061  GNUNET_ATS_print_property_type (o->prop_type));
2062 
2063  return GNUNET_OK;
2064 }
2065 
2066 
2067 static int
2069  struct Episode *e,
2070  int op_counter,
2071  char *sec_name,
2072  const struct GNUNET_CONFIGURATION_Handle *cfg)
2073 {
2074  char *op_name;
2075 
2076  /* peer pid */
2077  GNUNET_asprintf (&op_name, "op-%u-peer-id", op_counter);
2079  sec_name, op_name,
2080  &o->peer_id))
2081  {
2082  fprintf (stderr, "Missing peer-id in operation %u `%s' in episode `%s'\n",
2083  op_counter, "START_REQUEST", op_name);
2084  GNUNET_free (op_name);
2085  return GNUNET_SYSERR;
2086  }
2087  GNUNET_free (op_name);
2088  return GNUNET_OK;
2089 }
2090 
2091 
2092 static int
2094  struct Episode *e,
2095  int op_counter,
2096  char *sec_name,
2097  const struct GNUNET_CONFIGURATION_Handle *cfg)
2098 {
2099  char *op_name;
2100 
2101  /* peer pid */
2102  GNUNET_asprintf (&op_name, "op-%u-peer-id", op_counter);
2104  sec_name, op_name,
2105  &o->peer_id))
2106  {
2107  fprintf (stderr, "Missing peer-id in operation %u `%s' in episode `%s'\n",
2108  op_counter, "STOP_REQUEST", op_name);
2109  GNUNET_free (op_name);
2110  return GNUNET_SYSERR;
2111  }
2112  GNUNET_free (op_name);
2113  return GNUNET_OK;
2114 }
2115 
2116 
2117 static int
2118 load_episode (struct Experiment *e, struct Episode *cur,
2120 {
2121  struct GNUNET_ATS_TEST_Operation *o;
2122  char *sec_name;
2123  char *op_name;
2124  char *op;
2125  int op_counter = 0;
2126  int res;
2127 
2128  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "=== Parsing episode %u\n", cur->id);
2129  GNUNET_asprintf (&sec_name, "episode-%u", cur->id);
2130 
2131  while (1)
2132  {
2133  /* Load operation */
2134  GNUNET_asprintf (&op_name, "op-%u-operation", op_counter);
2136  sec_name,
2137  op_name, &op))
2138  {
2139  GNUNET_free (op_name);
2140  break;
2141  }
2143  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "==== Parsing operation %u: `%s'\n",
2144  cur->id, op_name);
2145 
2146  /* operations = set_rate, start_send, stop_send, set_preference */
2147  if (0 == strcmp (op, "address_add"))
2148  {
2150  res = load_op_add_address (o, cur,
2151  op_counter, sec_name, cfg);
2152  }
2153  else if (0 == strcmp (op, "address_del"))
2154  {
2156  res = load_op_del_address (o, cur,
2157  op_counter, sec_name, cfg);
2158  }
2159  else if (0 == strcmp (op, "start_set_property"))
2160  {
2162  res = load_op_start_set_property (o, cur,
2163  op_counter, sec_name, cfg);
2164  }
2165  else if (0 == strcmp (op, "stop_set_property"))
2166  {
2168  res = load_op_stop_set_property (o, cur,
2169  op_counter, sec_name, cfg);
2170  }
2171  else if (0 == strcmp (op, "start_set_preference"))
2172  {
2175  op_counter, sec_name, cfg);
2176  }
2177  else if (0 == strcmp (op, "stop_set_preference"))
2178  {
2180  res = load_op_stop_set_preference (o, cur,
2181  op_counter, sec_name, cfg);
2182  }
2183  else if (0 == strcmp (op, "start_request"))
2184  {
2186  res = load_op_start_request (o, cur,
2187  op_counter, sec_name, cfg);
2188  }
2189  else if (0 == strcmp (op, "stop_request"))
2190  {
2192  res = load_op_stop_request (o, cur,
2193  op_counter, sec_name, cfg);
2194  }
2195  else
2196  {
2197  fprintf (stderr, "Invalid operation %u `%s' in episode %u\n",
2198  op_counter, op, cur->id);
2199  res = GNUNET_SYSERR;
2200  }
2201 
2202  GNUNET_free (op);
2203  GNUNET_free (op_name);
2204 
2205  if (GNUNET_SYSERR == res)
2206  {
2207  GNUNET_free (o);
2208  GNUNET_free (sec_name);
2209  return GNUNET_SYSERR;
2210  }
2211 
2212  GNUNET_CONTAINER_DLL_insert_tail (cur->head, cur->tail, o);
2213  op_counter++;
2214  }
2215  GNUNET_free (sec_name);
2216  return GNUNET_OK;
2217 }
2218 
2219 
2220 static int
2222 {
2223  int e_counter = 0;
2224  char *sec_name;
2225  struct GNUNET_TIME_Relative e_duration;
2226  struct Episode *cur;
2227  struct Episode *last;
2228 
2229  e_counter = 0;
2230  last = NULL;
2231  while (1)
2232  {
2233  GNUNET_asprintf (&sec_name, "episode-%u", e_counter);
2235  sec_name,
2236  "duration",
2237  &e_duration))
2238  {
2239  GNUNET_free (sec_name);
2240  break;
2241  }
2242 
2243  cur = GNUNET_new (struct Episode);
2244  cur->duration = e_duration;
2245  cur->id = e_counter;
2246 
2247  if (GNUNET_OK != load_episode (e, cur, cfg))
2248  {
2249  GNUNET_free (sec_name);
2250  GNUNET_free (cur);
2251  return GNUNET_SYSERR;
2252  }
2253 
2254  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Found episode %u with duration %s \n",
2255  e_counter,
2257  GNUNET_YES));
2258 
2259  /* Update experiment */
2260  e->num_episodes++;
2262  cur->duration);
2263  /* Put in linked list */
2264  if (NULL == last)
2265  e->start = cur;
2266  else
2267  last->next = cur;
2268 
2269  GNUNET_free (sec_name);
2270  e_counter++;
2271  last = cur;
2272  }
2273  return e_counter;
2274 }
2275 
2276 
2277 static void
2279 {
2280  struct Experiment *e = cls;
2281 
2282  e->experiment_timeout_task = NULL;
2283  fprintf (stderr, "Experiment timeout!\n");
2284 
2285  if (NULL != e->episode_timeout_task)
2286  {
2288  e->episode_timeout_task = NULL;
2289  }
2290 
2292  GNUNET_SYSERR);
2293 }
2294 
2295 
2296 struct ATS_Address *
2298  const char *plugin_name,
2299  const void *plugin_addr,
2300  size_t plugin_addr_len,
2301  uint32_t session_id,
2302  uint32_t network)
2303 {
2304  struct ATS_Address *aa = NULL;
2305 
2306  aa = GNUNET_malloc (sizeof(struct ATS_Address) + plugin_addr_len + strlen (
2307  plugin_name) + 1);
2308  aa->atsi = GNUNET_new (struct GNUNET_ATS_Information);
2309  aa->atsi[0].type = htonl (GNUNET_ATS_NETWORK_TYPE);
2310  aa->atsi[0].value = htonl (network);
2311  aa->atsi_count = 1;
2312 
2313  aa->peer = *peer;
2314  aa->addr_len = plugin_addr_len;
2315  aa->addr = &aa[1];
2316  aa->plugin = (char *) &aa[1] + plugin_addr_len;
2317  GNUNET_memcpy (&aa[1], plugin_addr, plugin_addr_len);
2318  GNUNET_memcpy (aa->plugin, plugin_name, strlen (plugin_name) + 1);
2319  aa->session_id = session_id;
2320 
2321  return aa;
2322 }
2323 
2324 
2325 static void
2327 {
2328  struct TestPeer *p;
2329  struct TestAddress *a;
2330  int c;
2331 
2332  if (NULL == (p = find_peer_by_id (op->peer_id)))
2333  {
2334  p = GNUNET_new (struct TestPeer);
2335  p->id = op->peer_id;
2336  p->assigned_bw_in = 0;
2337  p->assigned_bw_out = 0;
2338  memset (&p->peer_id, op->peer_id, sizeof(p->peer_id));
2339  for (c = 0; c < GNUNET_ATS_PreferenceCount; c++)
2340  {
2341  p->pref_abs[c] = DEFAULT_ABS_PREFERENCE;
2342  p->pref_norm[c] = DEFAULT_REL_PREFERENCE;
2343  }
2344 
2346  }
2347 
2348  if (NULL != (find_address_by_id (p, op->address_id)))
2349  {
2350  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Duplicate address %u for peer %u\n",
2351  op->address_id, op->peer_id);
2352  return;
2353  }
2354 
2355  a = GNUNET_new (struct TestAddress);
2356  a->aid = op->address_id;
2357  a->network = op->address_network;
2358  a->ats_addr = create_ats_address (&p->peer_id, op->plugin, op->address,
2359  strlen (op->address) + 1,
2360  op->address_session, op->address_network);
2361  memset (&p->peer_id, op->peer_id, sizeof(p->peer_id));
2362  GNUNET_CONTAINER_DLL_insert_tail (p->addr_head, p->addr_tail, a);
2363 
2364  for (c = 0; c < GNUNET_ATS_PropertyCount; c++)
2366 
2369 
2371  "Adding address %u for peer %u in network `%s'\n",
2372  op->address_id, op->peer_id, GNUNET_NT_to_string (a->network));
2373 
2374  sh->sf->s_add (sh->sf->cls, a->ats_addr, op->address_network);
2375 }
2376 
2377 
2378 static void
2380 {
2381  struct TestPeer *p;
2382  struct TestAddress *a;
2383  struct PropertyGenerator *pg;
2384 
2385  if (NULL == (p = find_peer_by_id (op->peer_id)))
2386  {
2387  GNUNET_break (0);
2389  "Deleting address for unknown peer %u\n", op->peer_id);
2390  return;
2391  }
2392 
2393  if (NULL == (a = find_address_by_id (p, op->address_id)))
2394  {
2395  GNUNET_break (0);
2397  "Deleting address for unknown peer %u\n", op->peer_id);
2398  return;
2399  }
2400 
2401  while (NULL != (pg = find_prop_gen (p->id, a->aid, 0)))
2402  {
2404  }
2405 
2408  &p->peer_id,
2409  a->ats_addr));
2411  "Removing address %u for peer %u\n",
2412  op->address_id,
2413  op->peer_id);
2414 
2415  sh->sf->s_del (sh->sf->cls, a->ats_addr);
2416 
2417  if (NULL != l)
2418  {
2420  }
2421  GNUNET_CONTAINER_DLL_remove (p->addr_head, p->addr_tail, a);
2422 
2423  GNUNET_free (a->ats_addr->atsi);
2424  GNUNET_free (a->ats_addr);
2425  GNUNET_free (a);
2426 }
2427 
2428 
2429 static void
2431 {
2432  struct PropertyGenerator *pg;
2433  struct TestPeer *p;
2434  struct TestAddress *a;
2435 
2436  if (NULL != (pg = find_prop_gen (op->peer_id, op->address_id, op->prop_type)))
2437  {
2439  GNUNET_free (pg);
2440  }
2441 
2442  if (NULL == (p = find_peer_by_id (op->peer_id)))
2443  {
2444  GNUNET_break (0);
2446  "Starting property generation for unknown peer %u\n",
2447  op->peer_id);
2448  return;
2449  }
2450 
2451  if (NULL == (a = find_address_by_id (p, op->address_id)))
2452  {
2453  GNUNET_break (0);
2455  "Setting property for unknown address %u\n", op->peer_id);
2456  return;
2457  }
2458 
2460  op->address_id,
2461  p, a,
2462  op->gen_type,
2463  op->base_rate,
2464  op->max_rate,
2465  op->period,
2466  op->frequency,
2467  op->prop_type);
2468 }
2469 
2470 
2471 static void
2473 {
2474  struct PropertyGenerator *pg = find_prop_gen (op->peer_id, op->address_id,
2475  op->prop_type);
2476 
2477  if (NULL != pg)
2478  {
2480  "Stopping preference generation for peer %u address %u\n",
2481  op->peer_id,
2482  op->address_id);
2484  }
2485  else
2486  {
2488  "Cannot find preference generator for peer %u address %u\n",
2489  op->peer_id, op->address_id);
2490  GNUNET_break (0);
2491  }
2492 }
2493 
2494 
2495 static void
2497 {
2498  struct PreferenceGenerator *pg;
2499 
2500  if (NULL != (pg = find_pref_gen (op->peer_id, op->pref_type)))
2501  {
2503  GNUNET_free (pg);
2504  }
2505 
2506  if (NULL == (find_peer_by_id (op->peer_id)))
2507  {
2508  GNUNET_break (0);
2510  "Starting preference generation for unknown peer %u\n",
2511  op->peer_id);
2512  return;
2513  }
2514 
2516  op->address_id,
2517  op->client_id,
2518  op->gen_type,
2519  op->base_rate,
2520  op->max_rate,
2521  op->period,
2522  op->frequency,
2523  op->pref_type,
2524  op->frequency);
2525 }
2526 
2527 
2528 static void
2530 {
2531  struct PreferenceGenerator *pg = find_pref_gen (op->peer_id,
2532  op->pref_type);
2533 
2534  if (NULL != pg)
2535  {
2537  "Stopping property generation for peer %u address %u\n",
2538  op->peer_id,
2539  op->address_id);
2541  }
2542  else
2543  {
2545  "Cannot find preference generator for peer %u address %u\n",
2546  op->peer_id, op->address_id);
2547  GNUNET_break (0);
2548  }
2549 }
2550 
2551 
2552 static void
2554 {
2555  struct TestPeer *p;
2556 
2557  if (NULL == (p = find_peer_by_id (op->peer_id)))
2558  {
2559  GNUNET_break (0);
2561  "Requesting address for unknown peer %u\n", op->peer_id);
2562  return;
2563  }
2564 
2565  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Requesting address for peer %u\n",
2566  op->peer_id);
2567  p->is_requested = GNUNET_YES;
2568 
2569  sh->sf->s_get (sh->sf->cls, &p->peer_id);
2570 }
2571 
2572 
2573 static void
2575 {
2576  struct TestPeer *p;
2577 
2578  if (NULL == (p = find_peer_by_id (op->peer_id)))
2579  {
2580  GNUNET_break (0);
2582  "Requesting address for unknown peer %u\n", op->peer_id);
2583  return;
2584  }
2585 
2587  "Stop requesting address for peer %u\n",
2588  op->peer_id);
2589  p->is_requested = GNUNET_NO;
2590  p->assigned_bw_in = 0;
2591  p->assigned_bw_out = 0;
2592  sh->sf->s_get_stop (sh->sf->cls, &p->peer_id);
2593 
2594  if (NULL != l)
2595  {
2597  }
2598 }
2599 
2600 
2601 static void
2603 {
2604  struct GNUNET_ATS_TEST_Operation *cur;
2605 
2606  for (cur = ep->head; NULL != cur; cur = cur->next)
2607  {
2608  switch (cur->type)
2609  {
2610  case SOLVER_OP_ADD_ADDRESS:
2611  fprintf (stderr, "Enforcing operation: %s [%llu:%llu]\n",
2612  print_op (cur->type), cur->peer_id, cur->address_id);
2613  enforce_add_address (cur);
2614  break;
2615 
2616  case SOLVER_OP_DEL_ADDRESS:
2617  fprintf (stderr, "Enforcing operation: %s [%llu:%llu]\n",
2618  print_op (cur->type), cur->peer_id, cur->address_id);
2619  enforce_del_address (cur);
2620  break;
2621 
2623  fprintf (stderr, "Enforcing operation: %s [%llu:%llu] == %llu\n",
2624  print_op (cur->type), cur->peer_id, cur->address_id,
2625  cur->base_rate);
2626  enforce_start_property (cur);
2627  break;
2628 
2630  fprintf (stderr, "Enforcing operation: %s [%llu:%llu] == %llu\n",
2631  print_op (cur->type), cur->peer_id, cur->address_id,
2632  cur->base_rate);
2633  enforce_stop_property (cur);
2634  break;
2635 
2637  fprintf (stderr, "Enforcing operation: %s [%llu:%llu] == %llu\n",
2638  print_op (cur->type), cur->peer_id, cur->address_id,
2639  cur->base_rate);
2641  break;
2642 
2644  fprintf (stderr, "Enforcing operation: %s [%llu:%llu] == %llu\n",
2645  print_op (cur->type), cur->peer_id, cur->address_id,
2646  cur->base_rate);
2648  break;
2649 
2651  fprintf (stderr, "Enforcing operation: %s [%llu]\n",
2652  print_op (cur->type), cur->peer_id);
2653  enforce_start_request (cur);
2654  break;
2655 
2657  fprintf (stderr, "Enforcing operation: %s [%llu]\n",
2658  print_op (cur->type), cur->peer_id);
2659  enforce_stop_request (cur);
2660  break;
2661 
2662  default:
2663  break;
2664  }
2665  }
2666 }
2667 
2668 
2669 static void
2670 timeout_episode (void *cls)
2671 {
2672  struct Experiment *e = cls;
2673 
2674  e->episode_timeout_task = NULL;
2675  if (NULL != e->ep_done_cb)
2676  e->ep_done_cb (e->cur);
2677 
2678  /* Scheduling next */
2679  e->cur = e->cur->next;
2680  if (NULL == e->cur)
2681  {
2682  /* done */
2683  fprintf (stderr, "Last episode done!\n");
2684  if (NULL != e->experiment_timeout_task)
2685  {
2687  e->experiment_timeout_task = NULL;
2688  }
2690  GNUNET_OK);
2691  return;
2692  }
2693 
2694  fprintf (stderr, "Running episode %u with timeout %s\n",
2695  e->cur->id,
2697  GNUNET_YES));
2699  &timeout_episode, e);
2700  enforce_episode (e->cur);
2701 }
2702 
2703 
2704 void
2707  ep_done_cb,
2709  e_done_cb)
2710 {
2711  fprintf (stderr, "Running experiment `%s' with timeout %s\n", e->name,
2713  GNUNET_YES));
2714  e->e_done_cb = e_done_cb;
2715  e->ep_done_cb = ep_done_cb;
2717 
2718  /* Start total time out */
2721  e);
2722 
2723  /* Start */
2724  if (NULL == e->start)
2725  {
2726  GNUNET_break (0);
2727  return;
2728  }
2729 
2730  e->cur = e->start;
2731  fprintf (stderr, "Running episode %u with timeout %s\n",
2732  e->cur->id,
2734  GNUNET_YES));
2736  &timeout_episode, e);
2737  enforce_episode (e->cur);
2738 }
2739 
2740 
2741 void
2743 {
2744  if (NULL != e->experiment_timeout_task)
2745  {
2747  e->experiment_timeout_task = NULL;
2748  }
2749  if (NULL != e->episode_timeout_task)
2750  {
2752  e->episode_timeout_task = NULL;
2753  }
2754  if (NULL != e->cfg)
2755  {
2757  e->cfg = NULL;
2758  }
2759  free_experiment (e);
2760 }
2761 
2762 
2763 struct Experiment *
2765 {
2766  struct Experiment *e;
2768 
2769  e = NULL;
2770 
2773  {
2774  fprintf (stderr, "Failed to load `%s'\n", filename);
2776  return NULL;
2777  }
2778 
2779  e = create_experiment ();
2780 
2782  "name", &e->name))
2783  {
2784  fprintf (stderr, "Invalid %s \n", "name");
2785  free_experiment (e);
2786  return NULL;
2787  }
2788  else
2789  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Experiment name: `%s'\n", e->name);
2790 
2792  "log_prefix",
2793  &e->log_prefix))
2794  {
2795  fprintf (stderr, "Invalid %s \n", "log_prefix");
2796  free_experiment (e);
2797  return NULL;
2798  }
2799  else
2800  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Experiment logging prefix: `%s'\n",
2801  e->log_prefix);
2802 
2804  "experiment",
2805  "log_output_dir",
2806  &e->
2807  log_output_dir))
2808  {
2809  e->log_output_dir = NULL;
2810  }
2811  else
2813  "Experiment logging output directory: `%s'\n",
2814  e->log_output_dir);
2815 
2816 
2819  "experiment",
2820  "log_append_time_stamp")))
2823  "Experiment logging append timestamp: `%s'\n",
2824  (GNUNET_YES == e->log_append_time_stamp) ? "yes" : "no");
2825 
2826 
2828  "experiment",
2829  "cfg_file",
2830  &e->cfg_file))
2831  {
2832  fprintf (stderr, "Invalid %s \n", "cfg_file");
2833  free_experiment (e);
2834  return NULL;
2835  }
2836  else
2837  {
2838  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Experiment configuration: `%s'\n",
2839  e->cfg_file);
2842  {
2843  fprintf (stderr, "Invalid configuration %s \n", "cfg_file");
2844  free_experiment (e);
2845  return NULL;
2846  }
2847  }
2848 
2850  "log_freq",
2851  &e->log_freq))
2852  {
2853  fprintf (stderr, "Invalid %s \n", "log_freq");
2854  free_experiment (e);
2855  return NULL;
2856  }
2857  else
2858  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Experiment logging frequency: `%s'\n",
2860  GNUNET_YES));
2861 
2863  "max_duration",
2864  &e->max_duration))
2865  {
2866  fprintf (stderr, "Invalid %s", "max_duration");
2867  free_experiment (e);
2868  return NULL;
2869  }
2870  else
2871  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Experiment duration: `%s'\n",
2873  GNUNET_YES));
2874 
2875  if (GNUNET_SYSERR == load_episodes (e, cfg))
2876  {
2879  e = NULL;
2880  fprintf (stderr, "Failed to load experiment\n");
2881  return NULL;
2882  }
2884  "Loaded %u episodes with total duration %s\n",
2885  e->num_episodes,
2887  GNUNET_YES));
2888 
2890  return e;
2891 }
2892 
2893 
2898 static int
2899 free_all_it (void *cls,
2900  const struct GNUNET_PeerIdentity *key,
2901  void *value)
2902 {
2903  struct ATS_Address *address = value;
2904 
2906  sh->env.addresses,
2907  key, value));
2908  GNUNET_free (address);
2909 
2910  return GNUNET_OK;
2911 }
2912 
2913 
2914 void
2916 {
2918  GNUNET_NO);
2920  sh->sf = NULL;
2922 
2924  &free_all_it,
2925  NULL);
2927  GNUNET_free (sh->plugin);
2928  GNUNET_free (sh);
2929 }
2930 
2931 
2941 unsigned int
2943  unsigned long long *out_dest,
2944  unsigned long long *in_dest,
2945  int dest_length)
2946 {
2947  char *entry_in = NULL;
2948  char *entry_out = NULL;
2949  char *quota_out_str;
2950  char *quota_in_str;
2951  int c;
2952  int res;
2953 
2954  for (c = 0; (c < GNUNET_NT_COUNT) && (c < dest_length); c++)
2955  {
2956  in_dest[c] = 0;
2957  out_dest[c] = 0;
2958  GNUNET_asprintf (&entry_out,
2959  "%s_QUOTA_OUT",
2960  GNUNET_NT_to_string (c));
2961  GNUNET_asprintf (&entry_in,
2962  "%s_QUOTA_IN",
2963  GNUNET_NT_to_string (c));
2964 
2965  /* quota out */
2967  entry_out,
2968  &quota_out_str))
2969  {
2970  res = GNUNET_NO;
2971  if (0 == strcmp (quota_out_str, BIG_M_STRING))
2972  {
2973  out_dest[c] = GNUNET_ATS_MaxBandwidth;
2974  res = GNUNET_YES;
2975  }
2976  if ((GNUNET_NO == res) && (GNUNET_OK ==
2978  quota_out_str, &out_dest[c])))
2979  res = GNUNET_YES;
2980  if ((GNUNET_NO == res) && (GNUNET_OK ==
2982  "ats",
2983  entry_out,
2984  &
2985  out_dest
2986  [c])))
2987  res = GNUNET_YES;
2988 
2989  if (GNUNET_NO == res)
2990  {
2992  _ (
2993  "Could not load quota for network `%s': `%s', assigning default bandwidth %llu\n"),
2994  GNUNET_NT_to_string (c),
2995  quota_out_str,
2997  out_dest[c] = GNUNET_ATS_DefaultBandwidth;
2998  }
2999  else
3000  {
3002  "Outbound quota configure for network `%s' is %llu\n",
3003  GNUNET_NT_to_string (c),
3004  out_dest[c]);
3005  }
3006  GNUNET_free (quota_out_str);
3007  }
3008  else
3009  {
3011  _ (
3012  "No outbound quota configured for network `%s', assigning default bandwidth %llu\n"),
3013  GNUNET_NT_to_string (c),
3015  out_dest[c] = GNUNET_ATS_DefaultBandwidth;
3016  }
3017 
3018  /* quota in */
3020  entry_in,
3021  &quota_in_str))
3022  {
3023  res = GNUNET_NO;
3024  if (0 == strcmp (quota_in_str, BIG_M_STRING))
3025  {
3026  in_dest[c] = GNUNET_ATS_MaxBandwidth;
3027  res = GNUNET_YES;
3028  }
3029  if ((GNUNET_NO == res) && (GNUNET_OK ==
3031  quota_in_str, &in_dest[c])))
3032  res = GNUNET_YES;
3033  if ((GNUNET_NO == res) && (GNUNET_OK ==
3035  "ats",
3036  entry_in,
3037  &in_dest
3038  [c])))
3039  res = GNUNET_YES;
3040 
3041  if (GNUNET_NO == res)
3042  {
3044  _ (
3045  "Could not load quota for network `%s': `%s', assigning default bandwidth %llu\n"),
3046  GNUNET_NT_to_string (c),
3047  quota_in_str,
3049  in_dest[c] = GNUNET_ATS_DefaultBandwidth;
3050  }
3051  else
3052  {
3054  "Inbound quota configured for network `%s' is %llu\n",
3055  GNUNET_NT_to_string (c),
3056  in_dest[c]);
3057  }
3058  GNUNET_free (quota_in_str);
3059  }
3060  else
3061  {
3063  _ (
3064  "No outbound quota configure for network `%s', assigning default bandwidth %llu\n"),
3065  GNUNET_NT_to_string (c),
3067  out_dest[c] = GNUNET_ATS_DefaultBandwidth;
3068  }
3070  "Loaded quota for network `%s' (in/out): %llu %llu\n",
3071  GNUNET_NT_to_string (c),
3072  in_dest[c],
3073  out_dest[c]);
3074  GNUNET_free (entry_out);
3075  GNUNET_free (entry_in);
3076  }
3077  return GNUNET_NT_COUNT;
3078 }
3079 
3080 
3089 static void
3090 solver_info_cb (void *cls,
3091  enum GAS_Solver_Operation op,
3092  enum GAS_Solver_Status stat,
3094 {
3095  char *add_info;
3096 
3097  switch (add)
3098  {
3099  case GAS_INFO_NONE:
3100  add_info = "GAS_INFO_NONE";
3101  break;
3102 
3103  case GAS_INFO_FULL:
3104  add_info = "GAS_INFO_MLP_FULL";
3105  break;
3106 
3107  case GAS_INFO_UPDATED:
3108  add_info = "GAS_INFO_MLP_UPDATED";
3109  break;
3110 
3111  case GAS_INFO_PROP_ALL:
3112  add_info = "GAS_INFO_PROP_ALL";
3113  break;
3114 
3115  case GAS_INFO_PROP_SINGLE:
3116  add_info = "GAS_INFO_PROP_SINGLE";
3117  break;
3118 
3119  default:
3120  add_info = "INVALID";
3121  break;
3122  }
3123 
3124  switch (op)
3125  {
3126  case GAS_OP_SOLVE_START:
3128  "Solver notifies `%s' with result `%s' `%s'\n",
3129  "GAS_OP_SOLVE_START",
3130  (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL", add_info);
3131  return;
3132 
3133  case GAS_OP_SOLVE_STOP:
3135  "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_STOP",
3136  (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL", add_info);
3137  return;
3138 
3141  "Solver notifies `%s' with result `%s'\n",
3142  "GAS_OP_SOLVE_SETUP_START",
3143  (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL");
3144  return;
3145 
3148  "Solver notifies `%s' with result `%s'\n",
3149  "GAS_OP_SOLVE_SETUP_STOP",
3150  (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL");
3151  return;
3152 
3155  "Solver notifies `%s' with result `%s'\n",
3156  "GAS_OP_SOLVE_LP_START",
3157  (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL");
3158  return;
3159 
3162  "Solver notifies `%s' with result `%s'\n",
3163  "GAS_OP_SOLVE_LP_STOP",
3164  (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL");
3165  return;
3166 
3169  "Solver notifies `%s' with result `%s'\n",
3170  "GAS_OP_SOLVE_MLP_START",
3171  (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL");
3172  return;
3173 
3176  "Solver notifies `%s' with result `%s'\n",
3177  "GAS_OP_SOLVE_MLP_STOP",
3178  (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL");
3179  return;
3180 
3183  "Solver notifies `%s' with result `%s'\n",
3184  "GAS_OP_SOLVE_UPDATE_NOTIFICATION_START",
3185  (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL");
3186  return;
3187 
3190  "Solver notifies `%s' with result `%s'\n",
3191  "GAS_OP_SOLVE_UPDATE_NOTIFICATION_STOP",
3192  (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL");
3193  return;
3194 
3195  default:
3196  break;
3197  }
3198 }
3199 
3200 
3201 static void
3203 {
3205  struct TestPeer *p;
3206  static struct PreferenceGenerator *pg;
3207  uint32_t delta;
3208 
3209  if ((0 == address->assigned_bw_out) && (0 == address->assigned_bw_in))
3210  {
3212  "Solver notified to disconnect peer `%s'\n",
3213  GNUNET_i2s (&address->peer));
3214  }
3215  p = find_peer_by_pid (&address->peer);
3216  if (NULL == p)
3217  return;
3218  p->assigned_bw_out = address->assigned_bw_out;
3219  p->assigned_bw_in = address->assigned_bw_in;
3220 
3221  for (pg = pref_gen_head; NULL != pg; pg = pg->next)
3222  {
3223  if (pg->peer == p->id)
3224  {
3228  pg->feedback_bw_out_acc += delta;
3229 
3231  pg->feedback_bw_in_acc += delta;
3232 
3233  pg->last_assigned_bw_in = address->assigned_bw_in;
3234  pg->last_assigned_bw_out = address->assigned_bw_out;
3236  }
3237  }
3238 
3240  "Bandwidth changed addresses %s %p to %u Bps out / %u Bps in\n",
3241  GNUNET_i2s (&address->peer),
3242  address,
3243  address->assigned_bw_out,
3244  address->assigned_bw_in);
3245 
3246  if (NULL != l)
3248 
3249  return;
3250 }
3251 
3252 
3253 const double *
3254 get_preferences_cb (void *cls, const struct GNUNET_PeerIdentity *id)
3255 {
3256  struct TestPeer *p;
3257 
3259  {
3260  if (NULL == (p = find_peer_by_pid (id)))
3261  return NULL;
3262  return p->pref_abs;
3263  }
3264  else
3265  return GAS_preference_get_by_peer (NULL,
3266  id);
3267 }
3268 
3269 
3270 struct SolverHandle *
3272 {
3273  struct SolverHandle *sh;
3274  char *solver_str;
3275 
3276  switch (type)
3277  {
3279  solver_str = "proportional";
3280  break;
3281 
3282  case GNUNET_ATS_SOLVER_MLP:
3283  solver_str = "mlp";
3284  break;
3285 
3286  case GNUNET_ATS_SOLVER_RIL:
3287  solver_str = "ril";
3288  break;
3289 
3290  default:
3291  GNUNET_break (0);
3292  return NULL;
3293  break;
3294  }
3295 
3296  sh = GNUNET_new (struct SolverHandle);
3298  "libgnunet_plugin_ats_%s",
3299  solver_str);
3301 
3302  /* setup environment */
3303  sh->env.cfg = e->cfg;
3304  sh->env.stats = GNUNET_STATISTICS_create ("ats", e->cfg);
3305  sh->env.addresses = sh->addresses;
3311 
3312  /* start normalization */
3314 
3315  /* load quotas */
3317  sh->env.out_quota,
3318  sh->env.in_quota,
3319  GNUNET_NT_COUNT))
3320  {
3321  GNUNET_break (0);
3322  GNUNET_free (sh->plugin);
3323  GNUNET_free (sh);
3324  end_now ();
3325  return NULL;
3326  }
3327 
3328  sh->sf = GNUNET_PLUGIN_load (sh->plugin, &sh->env);
3329  if (NULL == sh->sf)
3330  {
3331  fprintf (stderr, "Failed to load solver `%s'\n", sh->plugin);
3332  GNUNET_break (0);
3333  GNUNET_free (sh->plugin);
3334  GNUNET_free (sh);
3335  end_now ();
3336  return NULL;
3337  }
3338  return sh;
3339 }
3340 
3341 
3342 static void
3344 {
3345  struct TestPeer *cur;
3346  struct TestPeer *next;
3347 
3348  struct TestAddress *cur_a;
3349  struct TestAddress *next_a;
3350 
3351  /* Stop logging */
3353 
3354  /* Stop all preference generation */
3356 
3357  /* Stop all property generation */
3359 
3360  if (opt_print)
3361  {
3362  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "== Printing log information \n");
3364  }
3365  if (opt_save)
3366  {
3367  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "== Saving log information \n");
3369  e->log_output_dir);
3370  }
3371 
3372  if (NULL != l)
3373  {
3375  l = NULL;
3376  }
3377 
3378  /* Clean up experiment */
3379  if (NULL != e)
3380  {
3382  e = NULL;
3383  }
3384 
3385  next = peer_head;
3386  while (NULL != (cur = next))
3387  {
3388  next = cur->next;
3390  next_a = cur->addr_head;
3391  while (NULL != (cur_a = next_a))
3392  {
3393  next_a = cur_a->next;
3394  GNUNET_CONTAINER_DLL_remove (cur->addr_head, cur->addr_tail, cur_a);
3395  GNUNET_free (cur_a);
3396  }
3397  GNUNET_free (cur);
3398  }
3399  if (NULL != sh)
3400  {
3402  sh = NULL;
3403  }
3404 
3405  /* Shutdown */
3406  end_now ();
3407 }
3408 
3409 
3410 static void
3412  int success)
3413 {
3414  if (GNUNET_OK == success)
3415  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Experiment done successful in %s\n",
3417  else
3418  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Experiment failed \n");
3419 
3420  GNUNET_SCHEDULER_add_now (&done, NULL);
3421 }
3422 
3423 
3424 static void
3426 {
3427  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Episode %u done\n", ep->id);
3428 }
3429 
3430 
3434 static void
3436 {
3437  if (NULL != e)
3438  {
3440  e = NULL;
3441  }
3442  if (NULL != sh)
3443  {
3445  sh = NULL;
3446  }
3447 }
3448 
3449 
3450 static void
3451 run (void *cls, char *const *args, const char *cfgfile,
3452  const struct GNUNET_CONFIGURATION_Handle *cfg)
3453 {
3454  enum GNUNET_ATS_Solvers solver;
3455  int c;
3456 
3457  if (NULL == opt_exp_file)
3458  {
3459  fprintf (stderr, "No experiment given ...\n");
3460  res = 1;
3461  end_now ();
3462  return;
3463  }
3464 
3465  if (NULL == opt_solver)
3466  {
3467  fprintf (stderr, "No solver given ...\n");
3468  res = 1;
3469  end_now ();
3470  return;
3471  }
3472 
3473  if (0 == strcmp (opt_solver, "mlp"))
3474  {
3475  solver = GNUNET_ATS_SOLVER_MLP;
3476  }
3477  else if (0 == strcmp (opt_solver, "proportional"))
3478  {
3480  }
3481  else if (0 == strcmp (opt_solver, "ril"))
3482  {
3483  solver = GNUNET_ATS_SOLVER_RIL;
3484  }
3485  else
3486  {
3487  fprintf (stderr, "No solver given ...");
3488  res = 1;
3489  end_now ();
3490  return;
3491  }
3492 
3493  for (c = 0; c < GNUNET_ATS_PropertyCount; c++)
3495 
3496  for (c = 0; c < GNUNET_ATS_PreferenceCount; c++)
3498 
3499  /* load experiment */
3500  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "=== Loading experiment\n");
3502  if (NULL == e)
3503  {
3504  fprintf (stderr, "Failed to load experiment ...\n");
3505  res = 1;
3506  end_now ();
3507  return;
3508  }
3509 
3510  /* load solver */
3511  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "=== Loading solver\n");
3513  if (NULL == sh)
3514  {
3515  fprintf (stderr, "Failed to start solver ...\n");
3516  end_now ();
3517  res = 1;
3518  return;
3519  }
3520 
3521  /* start logging */
3522  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "=== Start logging \n");
3524 
3525  /* run experiment */
3526  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "=== Running experiment \n");
3529 
3530  /* WAIT */
3531 }
3532 
3533 
3540 int
3541 main (int argc, char *argv[])
3542 {
3543  opt_exp_file = NULL;
3544  opt_solver = NULL;
3545  opt_log = GNUNET_NO;
3546  opt_save = GNUNET_NO;
3547 
3548  res = 0;
3549 
3550  static struct GNUNET_GETOPT_CommandLineOption options[] = {
3552  "solver",
3553  gettext_noop ("solver to use"),
3554  &opt_solver),
3555 
3557  "experiment"
3558  gettext_noop ("experiment to use"),
3559  &opt_exp_file),
3560 
3562 
3564  "print",
3565  gettext_noop ("print logging"),
3566  &opt_print),
3567 
3569  "file",
3570  gettext_noop ("save logging to disk"),
3571  &opt_save),
3572 
3574  "dn",
3575  gettext_noop ("disable normalization"),
3577 
3579  };
3580 
3581  GNUNET_PROGRAM_run (argc, argv, "gnunet-ats-solver-eval",
3582  NULL, options, &run, argv[0]);
3583 
3584  return res;
3585 }
3586 
3587 
3588 /* end of file ats-testing-experiment.c*/
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_OPTION_END
Definition: 002.c:13
struct GNUNET_GETOPT_CommandLineOption options[]
Definition: 002.c:5
#define gettext_noop(String)
Definition: gettext.h:69
static const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we are using.
Definition: gnunet-abd.c:36
static struct GNUNET_ARM_Operation * op
Current operation.
Definition: gnunet-arm.c:144
static void enforce_start_request(struct GNUNET_ATS_TEST_Operation *op)
static struct TestPeer * find_peer_by_id(int id)
static enum GNUNET_ATS_Property parse_property_string(const char *str)
static int opt_log
cmd option -l: enable logging
static struct TestAddress * find_address_by_id(struct TestPeer *peer, int aid)
static struct LoggingFileHandle * find_logging_file_handle(struct LoggingFileHandle *lf_head, struct LoggingFileHandle *lf_tail, int peer_id, int address_id)
static int opt_disable_normalization
cmd option -d: disable normalization
static struct TestPeer * peer_head
int main(int argc, char *argv[])
Main function of the benchmark.
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...
static int opt_save
cmd option -p: enable plots
static struct PreferenceGenerator * pref_gen_tail
void GNUNET_ATS_solver_generate_property_stop(struct PropertyGenerator *pg)
static void logging_task(void *cls)
static const char * print_op(enum OperationType op)
Experiments.
static struct TestAddress * find_active_address(struct TestPeer *p)
static struct TestPeer * peer_tail
static int free_all_it(void *cls, const struct GNUNET_PeerIdentity *key, void *value)
Solver.
static void free_experiment(struct Experiment *e)
static void solver_bandwidth_changed_cb(void *cls, struct ATS_Address *address)
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.
static struct PreferenceGenerator * find_pref_gen(unsigned int peer, enum GNUNET_ATS_PreferenceKind kind)
static struct TestPeer * find_peer_by_pid(const struct GNUNET_PeerIdentity *pid)
static void end_now()
Do shutdown.
const double * get_preferences_cb(void *cls, const struct GNUNET_PeerIdentity *id)
static struct Experiment * e
static double get_preference(struct PreferenceGenerator *pg)
void GNUNET_ATS_solver_logging_write_to_disk(struct LoggingHandle *l, int add_time_stamp, char *output_dir)
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)
void GNUNET_ATS_solver_generate_preferences_stop_all()
Stop all preferences generators.
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)
static int load_episode(struct Experiment *e, struct Episode *cur, struct GNUNET_CONFIGURATION_Handle *cfg)
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)
void GNUNET_ATS_solver_logging_free(struct LoggingHandle *l)
static double default_properties[GNUNET_ATS_PropertyCount]
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.
static void timeout_episode(void *cls)
struct GNUNET_STATISTICS_Handle * GSA_stats
Handle for statistics.
#define BIG_M_STRING
static int opt_verbose
cmd option -v: verbose logs
static struct LoggingHandle * l
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...
void GNUNET_ATS_solver_logging_eval(struct LoggingHandle *l)
struct LoggingHandle * GNUNET_ATS_solver_logging_start(struct GNUNET_TIME_Relative freq)
struct SolverHandle * GNUNET_ATS_solvers_solver_start(enum GNUNET_ATS_Solvers type)
static struct PropertyGenerator * prop_gen_tail
void GNUNET_ATS_solvers_solver_stop(struct SolverHandle *sh)
static void set_prop_task(void *cls)
static char * opt_solver
static void enforce_episode(struct Episode *ep)
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 void timeout_experiment(void *cls)
static void enforce_start_property(struct GNUNET_ATS_TEST_Operation *op)
static char * opt_exp_file
cmd option -e: experiment file
static int res
static void episode_done_cb(struct Episode *ep)
struct Experiment * GNUNET_ATS_solvers_experimentation_load(char *filename)
void GNUNET_ATS_solver_generate_preferences_stop(struct PreferenceGenerator *pg)
static int load_episodes(struct Experiment *e, struct GNUNET_CONFIGURATION_Handle *cfg)
static struct PropertyGenerator * prop_gen_head
Property Generators.
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)
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)
static void enforce_stop_preference(struct GNUNET_ATS_TEST_Operation *op)
static void enforce_stop_property(struct GNUNET_ATS_TEST_Operation *op)
void GNUNET_ATS_solver_logging_stop(struct LoggingHandle *l)
static void run(void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
static enum GNUNET_ATS_Property parse_preference_string(const char *str)
static int opt_print
cmd option -p: print logs
static struct Experiment * create_experiment()
void GNUNET_ATS_solvers_experimentation_stop(struct Experiment *e)
static void experiment_done_cb(struct Experiment *e, struct GNUNET_TIME_Relative duration, int success)
static char * print_generator_type(enum GeneratorType g)
static void set_pref_task(void *cls)
static void enforce_add_address(struct GNUNET_ATS_TEST_Operation *op)
static struct SolverHandle * sh
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)
static double default_preferences[GNUNET_ATS_PreferenceCount]
static void done()
static void enforce_start_preference(struct GNUNET_ATS_TEST_Operation *op)
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)
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)
static void set_feedback_task(void *cls)
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.
void GNUNET_ATS_solvers_experimentation_run(struct Experiment *e, GNUNET_ATS_TESTING_EpisodeDoneCallback ep_done_cb, GNUNET_ATS_TESTING_ExperimentDoneCallback e_done_cb)
static void enforce_del_address(struct GNUNET_ATS_TEST_Operation *op)
void GNUNET_ATS_solver_logging_now(struct LoggingHandle *l)
Logging.
void GNUNET_ATS_solver_generate_property_stop_all()
Stop all preferences generators.
static struct PreferenceGenerator * pref_gen_head
Preference Generators.
static double get_property(struct PropertyGenerator *pg)
static void enforce_stop_request(struct GNUNET_ATS_TEST_Operation *op)
void(* GNUNET_ATS_TESTING_ExperimentDoneCallback)(struct Experiment *e, struct GNUNET_TIME_Relative duration, int success)
GNUNET_ATS_Solvers
@ GNUNET_ATS_SOLVER_PROPORTIONAL
@ GNUNET_ATS_SOLVER_RIL
@ GNUNET_ATS_SOLVER_MLP
@ SOLVER_OP_STOP_SET_PREFERENCE
@ SOLVER_OP_DEL_ADDRESS
@ SOLVER_OP_START_REQUEST
@ SOLVER_OP_STOP_SET_PROPERTY
@ SOLVER_OP_START_SET_PREFERENCE
@ SOLVER_OP_STOP_REQUEST
@ SOLVER_OP_ADD_ADDRESS
@ SOLVER_OP_START_SET_PROPERTY
@ GNUNET_ATS_TEST_TG_RANDOM
@ GNUNET_ATS_TEST_TG_CONSTANT
@ GNUNET_ATS_TEST_TG_SINUS
@ GNUNET_ATS_TEST_TG_LINEAR
void(* GNUNET_ATS_TESTING_EpisodeDoneCallback)(struct Episode *e)
static char * peer_id
Option –peer.
Definition: gnunet-cadet.c:42
static struct GNUNET_HashCode session_id
static char * address
GNS address for this phone.
static void cleanup(void *cls)
Function scheduled as very last function, cleans up after us.
struct GNUNET_HashCode key
The key used in the DHT.
static char * filename
static char * value
Value of the record to add/remove.
static int add
Desired action is to add a record.
static struct GNUNET_TIME_Relative duration
How long do we run the test?
void GAS_normalization_stop()
Stop the normalization component and free all items.
void GAS_normalization_start()
Start the normalization component.
void GAS_normalization_update_property(struct ATS_Address *address)
Update and normalize atsi performance information.
ats service address: management of ATS properties and preferences normalization
#define DEFAULT_REL_QUALITY
Value we return for a normalized quality score if we have no data.
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.
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.
#define DEFAULT_ABS_PREFERENCE
Default preference value we assume if we know nothing.
#define DEFAULT_REL_PREFERENCE
Default relative preference value we assume if we know nothing.
static char * plugin_name
Name of our plugin.
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.
static struct GNUNET_PeerIdentity pid
Identity of the peer we transmit to / connect to.
static struct GNUNET_OS_Process * p
Helper process we started.
Definition: gnunet-uri.c:37
#define GNUNET_log(kind,...)
#define GNUNET_memcmp(a, b)
Compare memory in a and b, where both must be of the same pointer type.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
@ GNUNET_OK
Definition: gnunet_common.h:95
@ GNUNET_YES
Definition: gnunet_common.h:97
@ GNUNET_NO
Definition: gnunet_common.h:94
@ GNUNET_SYSERR
Definition: gnunet_common.h:93
#define GNUNET_NT_COUNT
GAS_Solver_Status
Status of a GAS_Solver_Operation operation.
GAS_Solver_Operation
Operation codes for solver information callback.
GAS_Solver_Additional_Information
Status of the operation.
@ GAS_STAT_SUCCESS
Success.
@ GAS_OP_SOLVE_UPDATE_NOTIFICATION_START
After the problem was finished, start notifications about changes to addresses.
@ GAS_OP_SOLVE_MLP_LP_STOP
Solving of the LP problem is done MLP solver only.
@ GAS_OP_SOLVE_START
A solution iteration has been started.
@ GAS_OP_SOLVE_UPDATE_NOTIFICATION_STOP
After the problem was finished, notifications about changes to addresses are done.
@ GAS_OP_SOLVE_MLP_LP_START
Solving of the LP problem was started MLP solver only.
@ GAS_OP_SOLVE_SETUP_STOP
The setup of the problem as a preparation to solve is finished.
@ GAS_OP_SOLVE_MLP_MLP_STOP
Solving of the MLP problem is done MLP solver only.
@ GAS_OP_SOLVE_SETUP_START
The setup of the problem as a preparation to solve it was started.
@ GAS_OP_SOLVE_MLP_MLP_START
Solving of the MLP problem was started MLP solver only.
@ GAS_OP_SOLVE_STOP
A solution iteration has been finished.
@ GAS_INFO_PROP_ALL
The proportional solver had to recalculate for all networks.
@ GAS_INFO_PROP_SINGLE
The proportional solver had to recalculate for a single network.
@ GAS_INFO_UPDATED
An existing solution was reused Quite specific to the MLP solver.
@ GAS_INFO_NONE
No more specific information.
@ GAS_INFO_FULL
A full solution process is performed Quite specific to the MLP solver.
#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.
#define GNUNET_ATS_MaxBandwidth
Maximum bandwidth assigned to a network : 4095 MB/s.
GNUNET_ATS_PreferenceKind
Enum defining all known preference categories.
#define GNUNET_ATS_PreferenceTypeString
ATS preference types as string array initializer.
@ GNUNET_ATS_PREFERENCE_BANDWIDTH
Change the peer's bandwidth value (value per byte of bandwidth in the goal function) to the given amo...
@ GNUNET_ATS_PREFERENCE_LATENCY
Change the peer's latency value to the given amount.
@ GNUNET_ATS_PREFERENCE_END
End of preference list.
enum GNUNET_GenericReturnValue 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.
enum GNUNET_GenericReturnValue 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.
struct GNUNET_CONFIGURATION_Handle * GNUNET_CONFIGURATION_create(void)
Create a new configuration object.
void GNUNET_CONFIGURATION_destroy(struct GNUNET_CONFIGURATION_Handle *cfg)
Destroy configuration object.
enum GNUNET_GenericReturnValue 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".
enum GNUNET_GenericReturnValue 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.
enum GNUNET_GenericReturnValue 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.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_load(struct GNUNET_CONFIGURATION_Handle *cfg, const char *filename)
Load configuration.
uint32_t GNUNET_CRYPTO_random_u32(enum GNUNET_CRYPTO_Quality mode, uint32_t i)
Produce a random value.
@ GNUNET_CRYPTO_QUALITY_WEAK
No good quality of the operation is needed (i.e., random numbers can be pseudo-random).
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:1235
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:686
enum GNUNET_GenericReturnValue GNUNET_DISK_file_close(struct GNUNET_DISK_FileHandle *h)
Close an open file.
Definition: disk.c:1306
enum GNUNET_GenericReturnValue GNUNET_DISK_directory_create_for_file(const char *filename)
Create the directory structure for storing a file.
Definition: disk.c:582
@ GNUNET_DISK_OPEN_TRUNCATE
Truncate file if it exists.
@ GNUNET_DISK_OPEN_CREATE
Create file if it doesn't exist.
@ GNUNET_DISK_OPEN_READWRITE
Open the file for both reading and writing.
@ GNUNET_DISK_PERM_USER_READ
Owner can read.
@ GNUNET_DISK_PERM_GROUP_READ
Group can read.
@ GNUNET_DISK_PERM_USER_WRITE
Owner can write.
@ GNUNET_DISK_PERM_OTHER_READ
Everybody can read.
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_verbose(unsigned int *level)
Define the '-V' verbosity option.
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.
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.
void GNUNET_CONTAINER_multipeermap_destroy(struct GNUNET_CONTAINER_MultiPeerMap *map)
Destroy a hash map.
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.
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 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).
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.
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.
@ GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE
Allow multiple values with the same key.
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
@ GNUNET_ERROR_TYPE_WARNING
@ GNUNET_ERROR_TYPE_ERROR
@ GNUNET_ERROR_TYPE_DEBUG
@ GNUNET_ERROR_TYPE_INFO
int int GNUNET_asprintf(char **buf, const char *format,...) __attribute__((format(printf
Like asprintf, just portable.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_malloc(size)
Wrapper around malloc.
#define GNUNET_free(ptr)
Wrapper around free.
const char * GNUNET_NT_to_string(enum GNUNET_NetworkType net)
Convert a enum GNUNET_NetworkType to a string.
Definition: nt.c:44
@ GNUNET_NT_WLAN
Wireless LAN (i.e.
Definition: gnunet_nt_lib.h:60
@ GNUNET_NT_WAN
Wide area network (i.e.
Definition: gnunet_nt_lib.h:55
@ GNUNET_NT_UNSPECIFIED
Category of last resort.
Definition: gnunet_nt_lib.h:40
@ GNUNET_NT_LAN
Local area network.
Definition: gnunet_nt_lib.h:50
@ GNUNET_NT_LOOPBACK
Loopback (same host).
Definition: gnunet_nt_lib.h:45
@ GNUNET_NT_BT
Bluetooth LAN.
Definition: gnunet_nt_lib.h:65
void * GNUNET_PLUGIN_unload(const char *library_name, void *arg)
Unload plugin (runs the "done" callback and returns whatever "done" returned).
Definition: plugin.c:269
void * GNUNET_PLUGIN_load(const char *library_name, void *arg)
Setup plugin (runs the "init" callback and returns whatever "init" returned).
Definition: plugin.c:217
enum GNUNET_GenericReturnValue 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,...
Definition: program.c:399
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:1281
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:957
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:1254
struct GNUNET_STATISTICS_Handle * GNUNET_STATISTICS_create(const char *subsystem, const struct GNUNET_CONFIGURATION_Handle *cfg)
Get handle for the statistics service.
void GNUNET_STATISTICS_destroy(struct GNUNET_STATISTICS_Handle *h, int sync_first)
Destroy a handle (free all state associated with it).
enum GNUNET_GenericReturnValue GNUNET_STRINGS_utf8_toupper(const char *input, char *output)
Convert the utf-8 input string to upper case.
Definition: strings.c:472
enum GNUNET_GenericReturnValue 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:237
#define GNUNET_TIME_UNIT_FOREVER_REL
Constant used to specify "forever".
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:435
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
Definition: time.c:110
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:584
#define GNUNET_TIME_UNIT_ZERO
Relative time zero.
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:570
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:420
#define DIR_SEPARATOR_STR
Definition: platform.h:165
#define _(String)
GNU gettext support macro.
Definition: platform.h:177
static struct GNUNET_TIME_Relative delta
Definition: speedup.c:35
Address with additional information.
uint32_t assigned_bw_in
Inbound bandwidth assigned by solver.
char * plugin
Plugin name.
struct GNUNET_PeerIdentity peer
Peer ID this address is for.
int active
Is this the active address for this peer?
uint32_t assigned_bw_out
Outbound bandwidth assigned by solver.
uint32_t session_id
Session ID, can never be 0.
size_t addr_len
Address length, number of bytes in addr.
uint32_t atsi_count
ATS performance information for this address, size of the atsi array.
const void * addr
Address (in plugin-specific binary format).
struct Episode * next
struct GNUNET_TIME_Relative duration
struct GNUNET_ATS_TEST_Operation * head
struct GNUNET_ATS_TEST_Operation * tail
struct GNUNET_SCHEDULER_Task * episode_timeout_task
GNUNET_ATS_TESTING_ExperimentDoneCallback e_done_cb
struct Episode * start
GNUNET_ATS_TESTING_EpisodeDoneCallback ep_done_cb
struct GNUNET_TIME_Relative max_duration
struct GNUNET_TIME_Relative total_duration
struct GNUNET_TIME_Absolute start_time
struct Episode * cur
unsigned int num_episodes
struct GNUNET_TIME_Relative log_freq
struct GNUNET_SCHEDULER_Task * experiment_timeout_task
struct GNUNET_CONFIGURATION_Handle * cfg
GAS_solver_information_callback info_cb
Callback for solver to call with status information, can be NULL.
GAS_get_preferences get_preferences
ATS addresses function to obtain preference values.
unsigned long long in_quota[6]
Array of configured inbound quotas Order according to networks in network array.
struct GNUNET_CONTAINER_MultiPeerMap * addresses
Hashmap containing all addresses available.
const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration handle to be used by the solver.
unsigned int network_count
Number of networks available, size of the out_quota and in_quota arrays.
GAS_bandwidth_changed_cb bandwidth_changed_cb
ATS addresses callback to be notified about bandwidth assignment changes.
struct GNUNET_STATISTICS_Handle * stats
Statistics handle to be used by the solver.
unsigned long long out_quota[6]
Array of configured outbound quotas Order according to networks in network array.
GAS_solver_address_feedback_preference s_feedback
Give feedback about the current assignment.
GAS_solver_address_property_changed s_address_update_property
Update the properties of an address in the solver.
GAS_solver_address_add s_add
Add a new address for a peer to the solver.
void * cls
Closure to pass to all solver functions in this struct.
GAS_solver_bulk_start s_bulk_start
Start a bulk operation.
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...
GAS_solver_bulk_stop s_bulk_stop
Bulk operation done.
GAS_solver_address_change_preference s_pref
Change relative preference for quality in solver.
GAS_solver_stop_get_preferred_address s_get_stop
Tell solver stop notifying ATS about changes for this peers.
GAS_solver_address_delete s_del
Delete an address in the solver.
An operation in an experiment.
struct GNUNET_TIME_Relative period
long long unsigned int peer_id
struct GNUNET_TIME_Relative feedback_delay
struct GNUNET_ATS_TEST_Operation * next
long long unsigned int address_id
long long unsigned int client_id
long long unsigned int max_rate
enum GNUNET_ATS_PreferenceKind pref_type
long long unsigned int base_rate
struct GNUNET_TIME_Relative frequency
long long unsigned int address_session
Definition of a command line option.
The identity of the host (wraps the signing key of the peer).
Handle for the service.
uint64_t abs_value_us
The actual value.
Time for relative time used by GNUnet, in microseconds.
uint64_t rel_value_us
The actual value.
long long unsigned int aid
double prop_abs[GNUNET_ATS_PropertyCount]
struct LoggingAddress * next
double prop_norm[GNUNET_ATS_PropertyCount]
struct GNUNET_DISK_FileHandle * f_hd
long long unsigned int pid
long long unsigned int aid
struct LoggingFileHandle * next
struct GNUNET_TIME_Relative log_freq
struct LoggingTimeStep * head
struct GNUNET_SCHEDULER_Task * logging_task
struct LoggingTimeStep * tail
struct GNUNET_PeerIdentity peer_id
struct LoggingAddress * addr_tail
struct LoggingAddress * addr_head
double pref_abs[GNUNET_ATS_PREFERENCE_END]
double pref_norm[GNUNET_ATS_PREFERENCE_END]
long long unsigned int id
struct LoggingPeer * next
struct LoggingTimeStep * next
struct GNUNET_TIME_Absolute timestamp
struct LoggingPeer * head
struct LoggingPeer * tail
struct LoggingTimeStep * prev
struct GNUNET_TIME_Relative delta
struct GNUNET_SCHEDULER_Task * feedback_task
struct GNUNET_TIME_Absolute feedback_last_delay_update
struct GNUNET_TIME_Relative frequency
struct GNUNET_SCHEDULER_Task * set_task
long long unsigned int peer
enum GNUNET_ATS_PreferenceKind kind
struct PreferenceGenerator * next
struct GNUNET_TIME_Absolute feedback_last
struct GNUNET_TIME_Relative duration_period
struct GNUNET_TIME_Absolute time_start
struct GNUNET_TIME_Relative feedback_frequency
struct GNUNET_TIME_Absolute feedback_last_bw_update
struct TestPeer * test_peer
struct GNUNET_TIME_Relative duration_period
struct GNUNET_TIME_Relative frequency
struct PropertyGenerator * next
struct GNUNET_TIME_Absolute time_start
struct GNUNET_SCHEDULER_Task * set_task
long long unsigned int address_id
long long unsigned int peer
struct TestAddress * test_address
enum GeneratorType type
struct GNUNET_ATS_PluginEnvironment env
Solver environment.
struct GNUNET_ATS_SolverFunctions * sf
Solver handle.
char * plugin
Solver plugin name.
struct GNUNET_CONTAINER_MultiPeerMap * addresses
Address hashmap.
struct TestAddress * next
double prop_norm[GNUNET_ATS_PropertyCount]
struct ATS_Address * ats_addr
long long unsigned int aid
double prop_abs[GNUNET_ATS_PropertyCount]
struct TestAddress * addr_head
double pref_norm[GNUNET_ATS_PreferenceCount]
struct GNUNET_PeerIdentity peer_id
double pref_abs[GNUNET_ATS_PreferenceCount]
struct TestAddress * addr_tail
struct TestPeer * next
long long unsigned int id
struct LinkProperty * props
list of link properties
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.