GNUnet  0.10.x
gnunet-ats-solver-eval.c
Go to the documentation of this file.
1 /*
2  This file is part of GNUnet.
3  Copyright (C) 2010-2013 GNUnet e.V.
4 
5  GNUnet is free software: you can redistribute it and/or modify it
6  under the terms of the GNU Affero General Public License as published
7  by the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  GNUnet is distributed in the hope that it will be useful, but
11  WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Affero General Public License for more details.
14 
15  You should have received a copy of the GNU Affero General Public License
16  along with this program. If not, see <http://www.gnu.org/licenses/>.
17 
18  SPDX-License-Identifier: AGPL3.0-or-later
19  */
26 #include "platform.h"
27 #include "gnunet_util_lib.h"
28 #include "gnunet-ats-solver-eval.h"
31 
32 #define BIG_M_STRING "unlimited"
33 
38 
39 
40 static struct Experiment *e;
41 
42 static struct LoggingHandle *l;
43 
44 static struct SolverHandle *sh;
45 
46 static struct TestPeer *peer_head;
47 
48 static struct TestPeer *peer_tail;
49 
50 static double default_properties[GNUNET_ATS_PropertyCount];
51 static double default_preferences[GNUNET_ATS_PreferenceCount];
52 
56 static char *opt_exp_file;
57 
58 static char *opt_solver;
59 
63 static int opt_log;
64 
68 static int opt_save;
69 
73 static int opt_verbose;
74 
78 static int opt_print;
79 
84 
85 static int res;
86 
87 static void
88 end_now();
89 
90 
91 static char *
93 {
94  switch (g)
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 static struct TestPeer *
128 {
129  struct TestPeer *cur;
130 
131  for (cur = peer_head; NULL != cur; cur = cur->next)
132  if (0 == GNUNET_memcmp(&cur->peer_id, pid))
133  return cur;
134  return NULL;
135 }
136 
137 static struct TestAddress *
139 {
140  struct TestAddress *cur;
141 
142  for (cur = peer->addr_head; NULL != cur; cur = cur->next)
143  if (cur->aid == aid)
144  return cur;
145  return NULL;
146 }
147 
148 
152 void
154 {
155  struct LoggingTimeStep *lts;
156  struct TestPeer *cur;
157  struct TestAddress *cur_addr;
158  struct LoggingPeer *log_p;
159  struct LoggingAddress *log_a;
160  int c;
161 
162  lts = GNUNET_new(struct LoggingTimeStep);
165  if (NULL == lts->prev)
167  else
169 
170  GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Logging %llu, delta %llu\n",
172 
173 
174  /* Store logging data here */
175  for (cur = peer_head; NULL != cur; cur = cur->next)
176  {
178  "Logging peer id %llu\n", cur->id);
179 
180  log_p = GNUNET_new(struct LoggingPeer);
181  log_p->id = cur->id;
182  log_p->peer_id = cur->peer_id;
183  log_p->is_requested = cur->is_requested;
184  for (c = 0; c < GNUNET_ATS_PreferenceCount; c++)
185  {
186  log_p->pref_abs[c] = cur->pref_abs[c];
187  log_p->pref_norm[c] = cur->pref_norm[c];
189  "\t %s = %.2f %.2f [abs/rel]\n",
191  log_p->pref_abs[c], log_p->pref_norm[c]);
192  }
193  GNUNET_CONTAINER_DLL_insert_tail(lts->head, lts->tail, log_p);
194 
195  for (cur_addr = cur->addr_head; NULL != cur_addr; cur_addr = cur_addr->next)
196  {
198  "Logging peer id %llu address %llu\n",
199  cur->id, cur_addr->aid);
200  log_a = GNUNET_new(struct LoggingAddress);
201  log_a->aid = cur_addr->aid;
202  log_a->active = cur_addr->ats_addr->active;
203  log_a->network = cur_addr->network;
204  log_a->assigned_bw_in = cur_addr->ats_addr->assigned_bw_in;
205  log_a->assigned_bw_out = cur_addr->ats_addr->assigned_bw_out;
206  for (c = 0; c < GNUNET_ATS_PropertyCount; c++)
207  {
208  log_a->prop_abs[c] = cur_addr->prop_abs[c];
209  log_a->prop_norm[c] = cur_addr->prop_norm[c];
211  "\t %s = %.2f %.2f [abs/rel]\n",
212  GNUNET_ATS_print_property_type(c),
213  log_a->prop_abs[c],
214  log_a->prop_norm[c]);
215  }
216  GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "\t Active = %i\n", log_a->active);
217  GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "\t BW in = %llu\n", log_a->assigned_bw_in);
218  GNUNET_log(GNUNET_ERROR_TYPE_INFO, "\t BW out = %llu\n", log_a->assigned_bw_out);
219 
221  }
222  }
223 }
224 
225 
226 static void
227 logging_task(void *cls)
228 {
229  struct LoggingHandle *l = cls;
230 
231  l->logging_task = NULL;
234  &logging_task,
235  l);
236 }
237 
238 struct LoggingHandle *
240 {
241  struct LoggingHandle *l;
242 
243  l = GNUNET_new(struct LoggingHandle);
244 
245  GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Start logging every %s\n",
247  l->log_freq = freq;
249  return l;
250 }
251 
252 void
254 {
255  if (NULL != l->logging_task)
257 
258  GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Stop logging\n");
259 
260  l->logging_task = NULL;
261 }
262 
263 static struct LoggingFileHandle *
265  struct LoggingFileHandle *lf_tail,
266  int peer_id, int address_id)
267 {
268  struct LoggingFileHandle *res;
269 
270  for (res = lf_head; NULL != res; res = res->next)
271  if ((res->pid == peer_id) && (res->aid == address_id))
272  return res;
273  return NULL;
274 }
275 
276 void
278  char *output_dir)
279 {
280  struct LoggingTimeStep *lts;
281  struct LoggingPeer *log_p;
282  struct LoggingAddress *log_a;
283  struct LoggingFileHandle *lf_head;
284  struct LoggingFileHandle *lf_tail;
285  struct LoggingFileHandle *cur;
286  struct LoggingFileHandle *next;
287  char * filename;
288  char * datastring;
289  char * propstring;
290  char * propstring_tmp;
291  char * prefstring;
292  char * prefstring_tmp;
293  int c;
294  int use_dir;
295 
296  use_dir = GNUNET_NO;
297  if (NULL != output_dir)
298  {
300  {
301  fprintf(stderr, "Failed to create directory `%s'\n", output_dir);
302  return;
303  }
304  else
305  {
306  fprintf(stderr, "Created directory `%s'\n", output_dir);
307  use_dir = GNUNET_YES;
308  }
309  }
310 
311  lf_head = NULL;
312  lf_tail = NULL;
313 
314  for (lts = l->head; NULL != lts; lts = lts->next)
315  {
316  GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Writing log step %llu\n",
317  (long long unsigned int)lts->timestamp.abs_value_us);
318 
319  for (log_p = lts->head; NULL != log_p; log_p = log_p->next)
320  {
321  for (log_a = log_p->addr_head; NULL != log_a; log_a = log_a->next)
322  {
323  cur = find_logging_file_handle(lf_head, lf_tail, log_p->id,
324  log_a->aid);
325  if (NULL == cur)
326  {
327  cur = GNUNET_new(struct LoggingFileHandle);
328  cur->aid = log_a->aid;
329  cur->pid = log_p->id;
330 
331  if (GNUNET_YES == add_time_stamp)
332  GNUNET_asprintf(&filename, "%s%s%s_%s_p%u_a%u_%llu.log",
333  (GNUNET_YES == use_dir) ? output_dir : "",
334  (GNUNET_YES == use_dir) ? DIR_SEPARATOR_STR : "",
335  e->log_prefix,
336  opt_solver,
337  cur->pid,
338  cur->aid,
340  else
341  GNUNET_asprintf(&filename, "%s%s%s_%s_p%u_a%u.log",
342  (GNUNET_YES == use_dir) ? output_dir : "",
343  (GNUNET_YES == use_dir) ? DIR_SEPARATOR_STR : "",
344  e->log_prefix,
345  opt_solver,
346  cur->pid,
347  cur->aid);
348 
349  fprintf(stderr, "Add writing log data for peer %llu address %llu to file `%s'\n",
350  cur->pid, cur->aid, filename);
351 
352 
353  cur->f_hd = GNUNET_DISK_file_open(filename,
361  if (NULL == cur->f_hd)
362  {
363  fprintf(stderr, "Cannot open `%s' to write log data!\n", filename);
364  GNUNET_free(filename);
365  GNUNET_free(cur);
366  goto cleanup;
367  }
368  GNUNET_free(filename);
369  GNUNET_CONTAINER_DLL_insert(lf_head, lf_tail, cur);
370 
371  GNUNET_asprintf(&datastring, "#time delta;log duration;peer_requested;addr net; addr_active; bw in; bw out; " \
372  "UTILIZATION_UP [abs/rel]; UTILIZATION_UP; UTILIZATION_DOWN; UTILIZATION_DOWN; " \
373  "UTILIZATION_PAYLOAD_UP; UTILIZATION_PAYLOAD_UP; UTILIZATION_PAYLOAD_DOWN; UTILIZATION_PAYLOAD_DOWN;" \
374  "DELAY; DELAY; " \
375  "DISTANCE ;DISTANCE ; COST_WAN; COST_WAN; COST_LAN; COST_LAN; " \
376  "COST_WLAN; COST_WLAN;COST_BT; COST_BT; PREF BW abs; PREF BW rel; PREF LATENCY abs; PREF LATENCY rel;\n");
377  GNUNET_DISK_file_write(cur->f_hd, datastring, strlen(datastring));
378  GNUNET_free(datastring);
379  }
380 
381  prefstring = GNUNET_strdup("");
382  for (c = 1; c < GNUNET_ATS_PreferenceCount; c++)
383  {
384  /*
385  fprintf(stderr,"\t %s = %.2f %.2f [abs/rel]\n",
386  GNUNET_ATS_print_preference_type(c),
387  log_p->pref_abs[c], log_p->pref_norm[c]);
388  */
389  GNUNET_asprintf(&prefstring_tmp, "%s;%.3f;%.3f",
390  prefstring, log_p->pref_abs[c], log_p->pref_norm[c]);
391 
392 
393  GNUNET_free(prefstring);
394  prefstring = GNUNET_strdup(prefstring_tmp);
395  GNUNET_free(prefstring_tmp);
396  }
397 
398 
399  propstring = GNUNET_strdup("");
400  for (c = 1; c < GNUNET_ATS_PropertyCount; c++)
401  {
402  if (GNUNET_ATS_NETWORK_TYPE == c)
403  continue;
404  /*
405  fprintf(stderr, "\t %s = %.2f %.2f [abs/rel]\n",
406  GNUNET_ATS_print_property_type(c),
407  log_a->prop_abs[c], log_a->prop_norm[c]);*/
408  GNUNET_asprintf(&propstring_tmp, "%s%.3f;%.3f;",
409  propstring,
410  log_a->prop_abs[c],
411  log_a->prop_norm[c]);
412  GNUNET_free(propstring);
413  propstring = GNUNET_strdup(propstring_tmp);
414  GNUNET_free(propstring_tmp);
415  }
416  GNUNET_asprintf(&datastring, "%llu;%llu;%u;%u;%i;%u;%u;%s;%s\n",
418  lts->timestamp).rel_value_us / 1000, lts->delta,
419  log_p->is_requested, log_a->network, log_a->active,
420  log_a->assigned_bw_in, log_a->assigned_bw_out, propstring,
421  prefstring);
422 
423  GNUNET_DISK_file_write(cur->f_hd, datastring, strlen(datastring));
424  GNUNET_free(datastring);
425  GNUNET_free(prefstring);
426  GNUNET_free(propstring);
427  }
428  }
429  }
430 
431 cleanup:
432  next = lf_head;
433  for (cur = next; NULL != cur; cur = next)
434  {
435  next = cur->next;
436  GNUNET_CONTAINER_DLL_remove(lf_head, lf_tail, cur);
437  if (NULL != cur->f_hd)
439  GNUNET_free(cur);
440  }
441 }
442 
443 void
445 {
446  struct LoggingTimeStep *lts;
447  struct LoggingPeer *log_p;
448  struct LoggingAddress *log_a;
449  int c;
450 
451  for (lts = l->head; NULL != lts; lts = lts->next)
452  {
453  fprintf(stderr, "Log step %llu %llu: \n",
454  (long long unsigned int)lts->timestamp.abs_value_us,
455  (long long unsigned int)lts->delta.rel_value_us);
456 
457  for (log_p = lts->head; NULL != log_p; log_p = log_p->next)
458  {
459  fprintf(stderr, "\tLogging peer pid %llu\n", log_p->id);
460  for (c = 1; c < GNUNET_ATS_PreferenceCount; c++)
461  {
462  fprintf(stderr, "\t %s = %.2f %.2f [abs/rel]\n",
464  log_p->pref_abs[c], log_p->pref_norm[c]);
465  }
466 
467  for (log_a = log_p->addr_head; NULL != log_a; log_a = log_a->next)
468  {
469  fprintf(stderr, "\tPeer pid %llu address %llu: %u %u %u\n",
470  log_p->id, log_a->aid, log_a->active,
471  log_a->assigned_bw_in,
472  log_a->assigned_bw_out);
473 
474  for (c = 1; c < GNUNET_ATS_PropertyCount; c++)
475  {
476  if (GNUNET_ATS_NETWORK_TYPE == c)
477  continue;
478  fprintf(stderr, "\t %s = %.2f %.2f [abs/rel]\n",
479  GNUNET_ATS_print_property_type(c),
480  log_a->prop_abs[c], log_a->prop_norm[c]);
481  }
482  }
483  }
484  }
485 }
486 
487 void
489 {
490  struct LoggingTimeStep *lts_cur;
491  struct LoggingTimeStep *lts_next;
492  struct LoggingPeer *log_p_cur;
493  struct LoggingPeer *log_p_next;
494  struct LoggingAddress *log_a_cur;
495  struct LoggingAddress *log_a_next;
496 
497  if (NULL != l->logging_task)
499  l->logging_task = NULL;
500 
501  lts_next = l->head;
502  while (NULL != (lts_cur = lts_next))
503  {
504  lts_next = lts_cur->next;
505 
506  log_p_next = lts_cur->head;
507  while (NULL != (log_p_cur = log_p_next))
508  {
509  log_p_next = log_p_cur->next;
510 
511  log_a_next = log_p_cur->addr_head;
512  while (NULL != (log_a_cur = log_a_next))
513  {
514  log_a_next = log_a_cur->next;
515 
516  GNUNET_CONTAINER_DLL_remove(log_p_cur->addr_head, log_p_cur->addr_tail, log_a_cur);
517  GNUNET_free(log_a_cur);
518  }
519 
520  GNUNET_CONTAINER_DLL_remove(lts_cur->head, lts_cur->tail, log_p_cur);
521  GNUNET_free(log_p_cur);
522  }
523 
524  GNUNET_CONTAINER_DLL_remove(l->head, l->tail, lts_cur);
525  GNUNET_free(lts_cur);
526  }
527 
528  GNUNET_free(l);
529 }
530 
536 
537 
538 static double
540 {
541  struct GNUNET_TIME_Relative time_delta;
542  double delta_value;
543  double pref_value;
544 
545  /* Calculate the current preference value */
546  switch (pg->type)
547  {
549  pref_value = pg->base_value;
550  break;
551 
554  /* Calculate point of time in the current period */
555  time_delta.rel_value_us = time_delta.rel_value_us %
557  delta_value = ((double)time_delta.rel_value_us /
559  if ((pg->max_value < pg->base_value) &&
560  ((pg->max_value - pg->base_value) > pg->base_value))
561  {
562  /* This will cause an underflow */
563  GNUNET_break(0);
564  }
565  pref_value = pg->base_value + delta_value;
566  break;
567 
570  10000 * (pg->max_value - pg->base_value)) / 10000;
571  pref_value = pg->base_value + delta_value;
572  break;
573 
576  /* Calculate point of time in the current period */
577  time_delta.rel_value_us = time_delta.rel_value_us %
579  if ((pg->max_value - pg->base_value) > pg->base_value)
580  {
581  /* This will cause an underflow for second half of sinus period,
582  * will be detected in general when experiments are loaded */
583  GNUNET_break(0);
584  }
585  delta_value = (pg->max_value - pg->base_value) *
586  sin((2 * M_PI) / ((double)pg->duration_period.rel_value_us) *
587  time_delta.rel_value_us);
588  pref_value = pg->base_value + delta_value;
589  break;
590 
591  default:
592  pref_value = 0.0;
593  break;
594  }
595  GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Current property value is %f\n",
596  pref_value);
597  return pref_value;
598 }
599 
600 
601 static void
602 set_prop_task(void *cls)
603 {
604  struct PropertyGenerator *pg = cls;
605  struct TestPeer *p;
606  struct TestAddress *a;
607  double prop_value;
608  struct GNUNET_ATS_Information atsi;
609 
610  pg->set_task = NULL;
611 
613  &pg->test_peer->peer_id, pg->test_address->ats_addr))
614  {
615  GNUNET_break(0);
617  "Setting property generation for unknown address [%u:%u]\n",
618  pg->peer, pg->address_id);
619  return;
620  }
621  if (NULL == (p = find_peer_by_id(pg->peer)))
622  {
623  GNUNET_break(0);
625  "Setting property generation for unknown peer %u\n",
626  pg->peer);
627  return;
628  }
629  if (NULL == (a = find_address_by_id(p, pg->address_id)))
630  {
631  GNUNET_break(0);
633  "Setting property generation for unknown peer %u\n",
634  pg->peer);
635  return;
636  }
637 
638  prop_value = get_property(pg);
639  a->prop_abs[pg->ats_property] = prop_value;
640 
642  "Setting property for peer [%u] address [%u] for %s to %f\n",
643  pg->peer, pg->address_id,
644  GNUNET_ATS_print_property_type(pg->ats_property), prop_value);
645 
646  atsi.type = htonl(pg->ats_property);
647  atsi.value = htonl((uint32_t)prop_value);
648 
649  /* set performance here! */
650  sh->sf->s_bulk_start(sh->sf->cls);
652  {
653  a->prop_abs[pg->ats_property] = prop_value;
654  a->prop_norm[pg->ats_property] = prop_value;
656  pg->ats_property, prop_value, prop_value);
657  }
658  else
660  sh->sf->s_bulk_stop(sh->sf->cls);
661 
663  &set_prop_task, pg);
664 }
665 
666 
670 static struct PropertyGenerator *
671 find_prop_gen(unsigned int peer, unsigned int address,
672  uint32_t ats_property)
673 {
674  struct PropertyGenerator *cur;
675 
676  for (cur = prop_gen_head; NULL != cur; cur = cur->next)
677  if ((cur->peer == peer) && (cur->address_id == address))
678  {
679  if ((cur->ats_property == ats_property) || (0 == ats_property))
680  return cur;
681  }
682  return NULL;
683 }
684 
685 void
687 {
688  GNUNET_CONTAINER_DLL_remove(prop_gen_head, prop_gen_tail, pg);
689 
690  if (NULL != pg->set_task)
691  {
693  pg->set_task = NULL;
694  }
696  "Removing old up preference generator peer [%u] address [%u] `%s'\n",
697  pg->peer, pg->address_id,
698  GNUNET_ATS_print_property_type(pg->ats_property));
699 
700  GNUNET_free(pg);
701 }
702 
703 
720 struct PropertyGenerator *
722  unsigned int address_id,
723  struct TestPeer *test_peer,
724  struct TestAddress *test_address,
725  enum GeneratorType type,
726  long int base_value,
727  long int value_rate,
728  struct GNUNET_TIME_Relative period,
730  uint32_t ats_property)
731 {
732  struct PropertyGenerator *pg;
733 
734  pg = GNUNET_new(struct PropertyGenerator);
735  GNUNET_CONTAINER_DLL_insert(prop_gen_head, prop_gen_tail, pg);
736  pg->type = type;
737  pg->peer = peer;
739  pg->test_peer = test_peer;
740  pg->address_id = address_id;
742  pg->base_value = base_value;
743  pg->max_value = value_rate;
744  pg->duration_period = period;
745  pg->frequency = frequency;
747 
748  switch (type)
749  {
752  "Setting up %s property generator peer [%u] address [%u] `%s'" \
753  "max %u Bips\n",
754  print_generator_type(type), pg->peer, pg->address_id,
755  GNUNET_ATS_print_property_type(ats_property),
756  base_value);
757  break;
758 
761  "Setting up %s property generator peer [%u] address [%u] `%s' " \
762  "min %u Bips max %u Bips\n",
763  print_generator_type(type), pg->peer, pg->address_id,
764  GNUNET_ATS_print_property_type(ats_property),
765  base_value, value_rate);
766  break;
767 
770  "Setting up %s property generator peer [%u] address [%u] `%s' " \
771  "baserate %u Bips, amplitude %u Bps\n",
772  print_generator_type(type), pg->peer, pg->address_id,
773  GNUNET_ATS_print_property_type(ats_property),
774  base_value, value_rate);
775  break;
776 
779  "Setting up %s property generator peer [%u] address [%u] `%s' " \
780  "min %u Bips max %u Bps\n",
781  print_generator_type(type), pg->peer, pg->address_id,
782  GNUNET_ATS_print_property_type(ats_property),
783  base_value, value_rate);
784  break;
785 
786  default:
787  break;
788  }
789 
791  return pg;
792 }
793 
794 
798 void
800 {
801  struct PropertyGenerator *cur;
802  struct PropertyGenerator *next;
803 
804  next = prop_gen_head;
805  for (cur = next; NULL != cur; cur = next)
806  {
807  next = cur->next;
809  }
810 }
811 
812 
818 
819 
820 static double
822 {
823  struct GNUNET_TIME_Relative time_delta;
824  double delta_value;
825  double pref_value;
826 
827  /* Calculate the current preference value */
828  switch (pg->type)
829  {
831  pref_value = pg->base_value;
832  break;
833 
836  /* Calculate point of time in the current period */
837  time_delta.rel_value_us = time_delta.rel_value_us %
839  delta_value = ((double)time_delta.rel_value_us /
841  if ((pg->max_value < pg->base_value) &&
842  ((pg->max_value - pg->base_value) > pg->base_value))
843  {
844  /* This will cause an underflow */
845  GNUNET_break(0);
846  }
847  pref_value = pg->base_value + delta_value;
848  break;
849 
852  10000 * (pg->max_value - pg->base_value)) / 10000;
853  pref_value = pg->base_value + delta_value;
854  break;
855 
858  /* Calculate point of time in the current period */
859  time_delta.rel_value_us = time_delta.rel_value_us %
861  if ((pg->max_value - pg->base_value) > pg->base_value)
862  {
863  /* This will cause an underflow for second half of sinus period,
864  * will be detected in general when experiments are loaded */
865  GNUNET_break(0);
866  }
867  delta_value = (pg->max_value - pg->base_value) *
868  sin((2 * M_PI) / ((double)pg->duration_period.rel_value_us) *
869  time_delta.rel_value_us);
870  pref_value = pg->base_value + delta_value;
871  break;
872 
873  default:
874  pref_value = 0.0;
875  break;
876  }
877  GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Current preference value is %f\n",
878  pref_value);
879  return pref_value;
880 }
881 
882 
883 static void
885 {
886  struct PreferenceGenerator *pg = cls;
887  struct TestPeer *p;
888  double feedback;
889  uint32_t bw_acc_out;
890  uint32_t bw_acc_in;
891  uint32_t delay_acc_in;
892  struct GNUNET_TIME_Relative dur;
893  double p_new;
894 
895  pg->feedback_task = NULL;
896 
897  if (NULL == (p = find_peer_by_id(pg->peer)))
898  {
899  GNUNET_break(0);
901  "Setting feedback for unknown peer %u\n", pg->peer);
902  return;
903  }
904 
905  switch (pg->kind)
906  {
909  bw_acc_in = dur.rel_value_us * pg->last_assigned_bw_in + pg->feedback_bw_in_acc;
910  pg->feedback_bw_in_acc = 0;
911 
912  bw_acc_out = dur.rel_value_us * pg->last_assigned_bw_out + pg->feedback_bw_out_acc;
913  p_new = get_preference(pg);
914  feedback = (p_new / pg->pref_bw_old) * (bw_acc_in + bw_acc_out) /
916 
917  break;
918 
921  delay_acc_in = dur.rel_value_us * pg->last_delay_value + pg->feedback_delay_acc;
922  pg->feedback_delay_acc = 0;
923 
924  p_new = get_preference(pg);
925  feedback = (p_new / pg->pref_latency_old) * (delay_acc_in) /
927 
928  break;
929 
930  default:
931  GNUNET_break(0);
932  feedback = 0.0;
933  break;
934  }
936  "Giving feedback for peer [%u] for client %p pref %s of %.3f\n",
937  pg->peer, NULL + (pg->client_id),
939  feedback);
940 
941  sh->sf->s_feedback(sh->sf->cls, NULL + (pg->client_id), &p->peer_id,
942  pg->feedback_frequency, pg->kind, feedback);
944 
945 
946  pg->feedback_bw_out_acc = 0;
947  pg->feedback_bw_in_acc = 0;
949 
950  pg->feedback_delay_acc = 0;
952 
953 
955  &set_feedback_task, pg);
956 }
957 
958 
959 static void
960 set_pref_task(void *cls)
961 {
962  struct PreferenceGenerator *pg = cls;
963  struct TestPeer *p;
964  double pref_value;
965 
966  pg->set_task = NULL;
967 
968  if (NULL == (p = find_peer_by_id(pg->peer)))
969  {
970  GNUNET_break(0);
972  "Setting preference for unknown peer %u\n", pg->peer);
973  return;
974  }
975 
976  pref_value = get_preference(pg);
977  switch (pg->kind)
978  {
980  pg->pref_bw_old = pref_value;
981  break;
982 
984  pg->pref_latency_old = pref_value;
985  break;
986 
987  default:
988  break;
989  }
990 
991  p->pref_abs[pg->kind] = pref_value;
992 
994  "Setting preference for peer [%u] for client %p pref %s to %f\n",
995  pg->peer, NULL + (pg->client_id),
996  GNUNET_ATS_print_preference_type(pg->kind), pref_value);
997 
999  {
1000  p->pref_abs[pg->kind] = pref_value;
1001  p->pref_norm[pg->kind] = pref_value;
1002  sh->sf->s_pref(sh->sf->cls, &p->peer_id, pg->kind, pref_value);
1003  }
1004  else
1005  update_preference(NULL + (pg->client_id),
1006  &p->peer_id,
1007  pg->kind,
1008  pref_value);
1009 
1011  &set_pref_task,
1012  pg);
1013 }
1014 
1015 
1016 static struct PreferenceGenerator *
1018 {
1019  struct PreferenceGenerator *cur;
1020 
1021  for (cur = pref_gen_head; NULL != cur; cur = cur->next)
1022  if (cur->peer == peer)
1023  {
1024  if ((cur->kind == kind) || (GNUNET_ATS_PREFERENCE_END == kind))
1025  return cur;
1026  }
1027  return NULL;
1028 }
1029 
1030 void
1032 {
1033  GNUNET_CONTAINER_DLL_remove(pref_gen_head, pref_gen_tail, pg);
1034 
1035  if (NULL != pg->feedback_task)
1036  {
1038  pg->feedback_task = NULL;
1039  }
1040 
1041  if (NULL != pg->set_task)
1042  {
1044  pg->set_task = NULL;
1045  }
1047  "Removing old up preference generator peer [%u] `%s'\n",
1049 
1050  GNUNET_free(pg);
1051 }
1052 
1053 
1054 static struct TestAddress*
1056 {
1057  struct TestAddress *cur;
1058 
1059  for (cur = p->addr_head; NULL != cur; cur = cur->next)
1060  if (GNUNET_YES == cur->ats_addr->active)
1061  return cur;
1062  return NULL;
1063 }
1064 
1065 
1082 struct PreferenceGenerator *
1084  unsigned int address_id,
1085  unsigned int client_id,
1086  enum GeneratorType type,
1087  long int base_value,
1088  long int value_rate,
1089  struct GNUNET_TIME_Relative period,
1093 {
1094  struct PreferenceGenerator *pg;
1095  struct TestPeer *p;
1096 
1097  if (NULL == (p = find_peer_by_id(peer)))
1098  {
1099  GNUNET_break(0);
1101  "Starting preference for unknown peer %u\n", peer);
1102  return NULL;
1103  }
1104 
1105  pg = GNUNET_new(struct PreferenceGenerator);
1106  GNUNET_CONTAINER_DLL_insert(pref_gen_head, pref_gen_tail, pg);
1107  pg->type = type;
1108  pg->peer = peer;
1109  pg->client_id = client_id;
1110  pg->kind = kind;
1111  pg->base_value = base_value;
1112  pg->max_value = value_rate;
1113  pg->duration_period = period;
1114  pg->frequency = frequency;
1116  pg->feedback_frequency = feedback_frequency;
1117 
1118  switch (type)
1119  {
1122  "Setting up %s preference generator peer [%u] `%s' max %u Bips\n",
1123  print_generator_type(type), pg->peer,
1125  base_value);
1126  break;
1127 
1130  "Setting up %s preference generator peer [%u] `%s' min %u Bips max %u Bips\n",
1132  base_value, value_rate);
1133  break;
1134 
1137  "Setting up %s preference generator peer [%u] `%s' baserate %u Bips, amplitude %u Bps\n",
1139  base_value, value_rate);
1140  break;
1141 
1144  "Setting up %s preference generator peer [%u] `%s' min %u Bips max %u Bps\n",
1146  base_value, value_rate);
1147  break;
1148 
1149  default:
1150  break;
1151  }
1152 
1154  if (GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us != feedback_frequency.rel_value_us)
1155  {
1156  struct TestAddress * addr = find_active_address(p);
1157 
1160  pg->feedback_bw_in_acc = 0;
1161  pg->feedback_bw_out_acc = 0;
1162  pg->last_delay_value = addr->prop_norm[GNUNET_ATS_QUALITY_NET_DELAY];
1163  pg->feedback_delay_acc = 0;
1164 
1168  pg->feedback_task = GNUNET_SCHEDULER_add_delayed(feedback_frequency,
1169  &set_feedback_task, pg);
1170  }
1171 
1172  return pg;
1173 }
1174 
1175 
1176 
1180 void
1182 {
1183  struct PreferenceGenerator *cur;
1184  struct PreferenceGenerator *next;
1185 
1186  next = pref_gen_head;
1187  for (cur = next; NULL != cur; cur = next)
1188  {
1189  next = cur->next;
1191  }
1192 }
1193 
1194 
1195 
1199 static const char *
1201 {
1202  switch (op)
1203  {
1204  case SOLVER_OP_ADD_ADDRESS:
1205  return "ADD_ADDRESS";
1206 
1207  case SOLVER_OP_DEL_ADDRESS:
1208  return "DEL_ADDRESS";
1209 
1211  return "START_SET_PREFERENCE";
1212 
1214  return "STOP_STOP_PREFERENCE";
1215 
1217  return "START_SET_PROPERTY";
1218 
1220  return "STOP_SET_PROPERTY";
1221 
1223  return "START_REQUEST";
1224 
1226  return "STOP_REQUEST";
1227 
1228  default:
1229  break;
1230  }
1231  return "";
1232 }
1233 
1234 
1235 static struct Experiment *
1237 {
1238  struct Experiment *e;
1239 
1240  e = GNUNET_new(struct Experiment);
1241  e->name = NULL;
1242  e->start = NULL;
1244  return e;
1245 }
1246 
1247 
1248 static void
1250 {
1251  struct Episode *cur;
1252  struct Episode *next;
1253  struct GNUNET_ATS_TEST_Operation *cur_o;
1254  struct GNUNET_ATS_TEST_Operation *next_o;
1255 
1256  next = e->start;
1257  for (cur = next; NULL != cur; cur = next)
1258  {
1259  next = cur->next;
1260 
1261  next_o = cur->head;
1262  for (cur_o = next_o; NULL != cur_o; cur_o = next_o)
1263  {
1264  next_o = cur_o->next;
1265  GNUNET_free_non_null(cur_o->address);
1266  GNUNET_free_non_null(cur_o->plugin);
1267  GNUNET_free(cur_o);
1268  }
1269  GNUNET_free(cur);
1270  }
1271 
1276  GNUNET_free(e);
1277 }
1278 
1279 
1280 static int
1282  struct Episode *e,
1283  int op_counter,
1284  char *sec_name,
1285  const struct GNUNET_CONFIGURATION_Handle *cfg)
1286 {
1287  char *op_name;
1288  char *op_network;
1289 
1290  /* peer pid */
1291  GNUNET_asprintf(&op_name, "op-%u-peer-id", op_counter);
1293  sec_name, op_name, &o->peer_id))
1294  {
1295  fprintf(stderr, "Missing peer-id in operation %u `%s' in episode `%s'\n",
1296  op_counter, "ADD_ADDRESS", op_name);
1297  GNUNET_free(op_name);
1298  return GNUNET_SYSERR;
1299  }
1300  GNUNET_free(op_name);
1301 
1302  /* address pid */
1303  GNUNET_asprintf(&op_name, "op-%u-address-id", op_counter);
1305  sec_name, op_name, &o->address_id))
1306  {
1307  fprintf(stderr, "Missing address-id in operation %u `%s' in episode `%s'\n",
1308  op_counter, "ADD_ADDRESS", op_name);
1309  GNUNET_free(op_name);
1310  return GNUNET_SYSERR;
1311  }
1312  GNUNET_free(op_name);
1313 
1314  /* plugin */
1315  GNUNET_asprintf(&op_name, "op-%u-plugin", op_counter);
1317  sec_name, op_name, &o->plugin))
1318  {
1319  fprintf(stderr, "Missing plugin in operation %u `%s' in episode `%s'\n",
1320  op_counter, "ADD_ADDRESS", op_name);
1321  GNUNET_free(op_name);
1322  return GNUNET_SYSERR;
1323  }
1324  GNUNET_free(op_name);
1325 
1326  /* address */
1327  GNUNET_asprintf(&op_name, "op-%u-address", op_counter);
1329  sec_name, op_name, &o->address))
1330  {
1331  fprintf(stderr, "Missing address in operation %u `%s' in episode `%s'\n",
1332  op_counter, "ADD_ADDRESS", op_name);
1333  GNUNET_free(op_name);
1334  return GNUNET_SYSERR;
1335  }
1336  GNUNET_free(op_name);
1337 
1338  /* session */
1339  GNUNET_asprintf(&op_name, "op-%u-address-session", op_counter);
1341  sec_name, op_name, &o->address_session))
1342  {
1343  fprintf(stderr, "Missing address-session in operation %u `%s' in episode `%s'\n",
1344  op_counter, "ADD_ADDRESS", op_name);
1345  GNUNET_free(op_name);
1346  return GNUNET_SYSERR;
1347  }
1348  GNUNET_free(op_name);
1349 
1350  /* network */
1351  GNUNET_asprintf(&op_name, "op-%u-address-network", op_counter);
1353  sec_name, op_name, &op_network))
1354  {
1355  fprintf(stderr, "Missing address-network 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  else
1361  {
1362  GNUNET_STRINGS_utf8_toupper(op_network, op_network);
1363  if (0 == strcmp(op_network, "UNSPECIFIED"))
1364  {
1366  }
1367  else if (0 == strcmp(op_network, "LOOPBACK"))
1368  {
1370  }
1371  else if (0 == strcmp(op_network, "LAN"))
1372  {
1374  }
1375  else if (0 == strcmp(op_network, "WAN"))
1376  {
1378  }
1379  else if (0 == strcmp(op_network, "WLAN"))
1380  {
1382  }
1383  else if (0 == strcmp(op_network, "BT"))
1384  {
1386  }
1387  else
1388  {
1389  fprintf(stderr, "Invalid address-network in operation %u `%s' in episode `%s': `%s'\n",
1390  op_counter, "ADD_ADDRESS", op_name, op_network);
1391  GNUNET_free(op_network);
1392  GNUNET_free(op_name);
1393  return GNUNET_SYSERR;
1394  }
1395  }
1396  GNUNET_free(op_network);
1397  GNUNET_free(op_name);
1398 
1400  "Found operation %s: [%llu:%llu] address `%s' plugin `%s' \n",
1401  "ADD_ADDRESS", o->peer_id, o->address_id, o->address, o->plugin);
1402 
1403  return GNUNET_OK;
1404 }
1405 
1406 
1407 static int
1409  struct Episode *e,
1410  int op_counter,
1411  char *sec_name,
1412  const struct GNUNET_CONFIGURATION_Handle *cfg)
1413 {
1414  char *op_name;
1415 
1416  //char *op_network;
1417 
1418  /* peer pid */
1419  GNUNET_asprintf(&op_name, "op-%u-peer-id", op_counter);
1421  sec_name, op_name, &o->peer_id))
1422  {
1423  fprintf(stderr, "Missing peer-id in operation %u `%s' in episode `%s'\n",
1424  op_counter, "DEL_ADDRESS", op_name);
1425  GNUNET_free(op_name);
1426  return GNUNET_SYSERR;
1427  }
1428  GNUNET_free(op_name);
1429 
1430  /* address pid */
1431  GNUNET_asprintf(&op_name, "op-%u-address-id", op_counter);
1433  sec_name, op_name, &o->address_id))
1434  {
1435  fprintf(stderr, "Missing address-id in operation %u `%s' in episode `%s'\n",
1436  op_counter, "DEL_ADDRESS", op_name);
1437  GNUNET_free(op_name);
1438  return GNUNET_SYSERR;
1439  }
1440  GNUNET_free(op_name);
1441 
1442 #if 0
1443  /* plugin */
1444  GNUNET_asprintf(&op_name, "op-%u-plugin", op_counter);
1446  sec_name, op_name, &o->plugin))
1447  {
1448  fprintf(stderr, "Missing plugin in operation %u `%s' in episode `%s'\n",
1449  op_counter, "DEL_ADDRESS", op_name);
1450  GNUNET_free(op_name);
1451  return GNUNET_SYSERR;
1452  }
1453  GNUNET_free(op_name);
1454 
1455  /* address */
1456  GNUNET_asprintf(&op_name, "op-%u-address", op_counter);
1458  sec_name, op_name, &o->address))
1459  {
1460  fprintf(stderr, "Missing address in operation %u `%s' in episode `%s'\n",
1461  op_counter, "DEL_ADDRESS", op_name);
1462  GNUNET_free(op_name);
1463  return GNUNET_SYSERR;
1464  }
1465  GNUNET_free(op_name);
1466 
1467  /* session */
1468  GNUNET_asprintf(&op_name, "op-%u-address-session", op_counter);
1470  sec_name, op_name, &o->address_session))
1471  {
1472  fprintf(stderr, "Missing address-session in operation %u `%s' in episode `%s'\n",
1473  op_counter, "DEL_ADDRESS", op_name);
1474  GNUNET_free(op_name);
1475  return GNUNET_SYSERR;
1476  }
1477  GNUNET_free(op_name);
1478 #endif
1479 
1481  "Found operation %s: [%llu:%llu] address `%s' plugin `%s' \n",
1482  "DEL_ADDRESS", o->peer_id, o->address_id, o->address, o->plugin);
1483 
1484  return GNUNET_OK;
1485 }
1486 
1487 
1488 static enum GNUNET_ATS_Property
1489 parse_preference_string(const char * str)
1490 {
1491  int c = 0;
1492  char *props[GNUNET_ATS_PreferenceCount] = GNUNET_ATS_PreferenceTypeString;
1493 
1494  for (c = 0; c < GNUNET_ATS_PreferenceCount; c++)
1495  if (0 == strcmp(str, props[c]))
1496  return c;
1497  return 0;
1498 }
1499 
1500 
1501 static int
1503  struct Episode *e,
1504  int op_counter,
1505  char *sec_name,
1506  const struct GNUNET_CONFIGURATION_Handle *cfg)
1507 {
1508  char *op_name;
1509  char *type;
1510  char *pref;
1511 
1512  /* peer pid */
1513  GNUNET_asprintf(&op_name, "op-%u-peer-id", op_counter);
1515  sec_name, op_name, &o->peer_id))
1516  {
1517  fprintf(stderr, "Missing peer-id in operation %u `%s' in episode `%s'\n",
1518  op_counter, "START_SET_PREFERENCE", op_name);
1519  GNUNET_free(op_name);
1520  return GNUNET_SYSERR;
1521  }
1522  GNUNET_free(op_name);
1523 
1524  /* address pid */
1525  GNUNET_asprintf(&op_name, "op-%u-client-id", op_counter);
1527  sec_name, op_name, &o->client_id))
1528  {
1529  fprintf(stderr, "Missing client-id in operation %u `%s' in episode `%s'\n",
1530  op_counter, "START_SET_PREFERENCE", op_name);
1531  GNUNET_free(op_name);
1532  return GNUNET_SYSERR;
1533  }
1534  GNUNET_free(op_name);
1535 
1536  /* generator */
1537  GNUNET_asprintf(&op_name, "op-%u-gen-type", op_counter);
1539  sec_name, op_name, &type)))
1540  {
1541  fprintf(stderr, "Missing type in operation %u `%s' in episode `%s'\n",
1542  op_counter, "START_SET_PREFERENCE", op_name);
1543  GNUNET_free(op_name);
1544  return GNUNET_SYSERR;
1545  }
1546 
1547  /* Load arguments for set_rate, start_send, set_preference */
1548  if (0 == strcmp(type, "constant"))
1549  {
1551  }
1552  else if (0 == strcmp(type, "linear"))
1553  {
1555  }
1556  else if (0 == strcmp(type, "sinus"))
1557  {
1559  }
1560  else if (0 == strcmp(type, "random"))
1561  {
1563  }
1564  else
1565  {
1566  fprintf(stderr, "Invalid generator type %u `%s' in episode %u\n",
1567  op_counter, op_name, e->id);
1568  GNUNET_free(type);
1569  GNUNET_free(op_name);
1570  return GNUNET_SYSERR;
1571  }
1572  GNUNET_free(type);
1573  GNUNET_free(op_name);
1574 
1575 
1576  /* Get base rate */
1577  GNUNET_asprintf(&op_name, "op-%u-base-rate", op_counter);
1579  sec_name, op_name, &o->base_rate))
1580  {
1581  fprintf(stderr, "Missing base rate in operation %u `%s' in episode %u\n",
1582  op_counter, op_name, e->id);
1583  GNUNET_free(op_name);
1584  return GNUNET_SYSERR;
1585  }
1586  GNUNET_free(op_name);
1587 
1588 
1589  /* Get max rate */
1590  GNUNET_asprintf(&op_name, "op-%u-max-rate", op_counter);
1592  sec_name, op_name, &o->max_rate))
1593  {
1594  if ((GNUNET_ATS_TEST_TG_LINEAR == o->gen_type) ||
1597  {
1598  fprintf(stderr, "Missing max rate in operation %u `%s' in episode %u\n",
1599  op_counter, op_name, e->id);
1600  GNUNET_free(op_name);
1601  return GNUNET_SYSERR;
1602  }
1603  }
1604  GNUNET_free(op_name);
1605 
1606  /* Get period */
1607  GNUNET_asprintf(&op_name, "op-%u-period", op_counter);
1609  sec_name, op_name, &o->period))
1610  {
1611  o->period = e->duration;
1612  }
1613  GNUNET_free(op_name);
1614 
1615  /* Get frequency */
1616  GNUNET_asprintf(&op_name, "op-%u-frequency", op_counter);
1618  sec_name, op_name, &o->frequency))
1619  {
1620  fprintf(stderr, "Missing frequency in operation %u `%s' in episode %u\n",
1621  op_counter, op_name, e->id);
1622  GNUNET_free(op_name);
1623  return GNUNET_SYSERR;
1624  }
1625  GNUNET_free(op_name);
1626 
1627  /* Get preference */
1628  GNUNET_asprintf(&op_name, "op-%u-pref", op_counter);
1630  sec_name, op_name, &pref))
1631  {
1632  fprintf(stderr, "Missing preference in operation %u `%s' in episode %u\n",
1633  op_counter, op_name, e->id);
1634  GNUNET_free(op_name);
1635  return GNUNET_SYSERR;
1636  }
1637 
1638  if (0 == (o->pref_type = parse_preference_string(pref)))
1639  {
1640  fprintf(stderr, "Invalid preference in operation %u `%s' in episode %u\n",
1641  op_counter, op_name, e->id);
1642  GNUNET_free(op_name);
1643  GNUNET_free(pref);
1644  return GNUNET_SYSERR;
1645  }
1646  GNUNET_free(pref);
1647  GNUNET_free(op_name);
1648 
1649  /* Get feedback delay */
1650  GNUNET_asprintf(&op_name, "op-%u-feedback_delay", op_counter);
1652  sec_name, op_name, &o->feedback_delay))
1653  {
1654  fprintf(stderr, "Using feedback delay %llu in operation %u `%s' in episode %u\n",
1655  (long long unsigned int)o->feedback_delay.rel_value_us,
1656  op_counter, op_name, e->id);
1657  }
1658  else
1660  GNUNET_free(op_name);
1661 
1663  "Found operation %s: [%llu:%llu]: %s = %llu\n",
1664  "START_SET_PREFERENCE", o->peer_id, o->address_id,
1666 
1667  return GNUNET_OK;
1668 }
1669 
1670 
1671 static int
1673  struct Episode *e,
1674  int op_counter,
1675  char *sec_name,
1676  const struct GNUNET_CONFIGURATION_Handle *cfg)
1677 {
1678  char *op_name;
1679  char *pref;
1680 
1681  /* peer pid */
1682  GNUNET_asprintf(&op_name, "op-%u-peer-id", op_counter);
1684  sec_name, op_name, &o->peer_id))
1685  {
1686  fprintf(stderr, "Missing peer-id in operation %u `%s' in episode `%s'\n",
1687  op_counter, "STOP_SET_PREFERENCE", op_name);
1688  GNUNET_free(op_name);
1689  return GNUNET_SYSERR;
1690  }
1691  GNUNET_free(op_name);
1692 
1693  /* address pid */
1694  GNUNET_asprintf(&op_name, "op-%u-address-id", op_counter);
1696  sec_name, op_name, &o->address_id))
1697  {
1698  fprintf(stderr, "Missing address-id in operation %u `%s' in episode `%s'\n",
1699  op_counter, "STOP_SET_PREFERENCE", op_name);
1700  GNUNET_free(op_name);
1701  return GNUNET_SYSERR;
1702  }
1703  GNUNET_free(op_name);
1704 
1705  /* Get preference */
1706  GNUNET_asprintf(&op_name, "op-%u-pref", op_counter);
1708  sec_name, op_name, &pref))
1709  {
1710  fprintf(stderr, "Missing preference in operation %u `%s' in episode `%s'\n",
1711  op_counter, "STOP_SET_PREFERENCE", op_name);
1712  GNUNET_free(op_name);
1713  return GNUNET_SYSERR;
1714  }
1715 
1716  if (0 == (o->pref_type = parse_preference_string(pref)))
1717  {
1718  fprintf(stderr, "Invalid preference in operation %u `%s' in episode %u\n",
1719  op_counter, op_name, e->id);
1720  GNUNET_free(op_name);
1721  GNUNET_free(pref);
1722  return GNUNET_SYSERR;
1723  }
1724  GNUNET_free(pref);
1725  GNUNET_free(op_name);
1726 
1728  "Found operation %s: [%llu:%llu]: %s\n",
1729  "STOP_SET_PREFERENCE", o->peer_id, o->address_id,
1731  return GNUNET_OK;
1732 }
1733 
1734 
1735 static enum GNUNET_ATS_Property
1736 parse_property_string(const char *str)
1737 {
1738  enum GNUNET_ATS_Property c;
1739 
1740  for (c = 0; c < GNUNET_ATS_PropertyCount; c++)
1741  if (0 == strcmp(str,
1742  GNUNET_ATS_print_property_type(c)))
1743  return c;
1744  return 0;
1745 }
1746 
1747 
1748 static int
1750  struct Episode *e,
1751  int op_counter,
1752  char *sec_name,
1753  const struct GNUNET_CONFIGURATION_Handle *cfg)
1754 {
1755  char *op_name;
1756  char *type;
1757  char *prop;
1758 
1759  /* peer pid */
1760  GNUNET_asprintf(&op_name, "op-%u-peer-id", op_counter);
1762  sec_name, op_name, &o->peer_id))
1763  {
1764  fprintf(stderr, "Missing peer-id in operation %u `%s' in episode `%s'\n",
1765  op_counter, "START_SET_PROPERTY", op_name);
1766  GNUNET_free(op_name);
1767  return GNUNET_SYSERR;
1768  }
1769  GNUNET_free(op_name);
1770 
1771  /* address pid */
1772  GNUNET_asprintf(&op_name, "op-%u-address-id", op_counter);
1774  sec_name, op_name, &o->address_id))
1775  {
1776  fprintf(stderr, "Missing address-id in operation %u `%s' in episode `%s'\n",
1777  op_counter, "START_SET_PROPERTY", op_name);
1778  GNUNET_free(op_name);
1779  return GNUNET_SYSERR;
1780  }
1781  GNUNET_free(op_name);
1782 
1783  /* generator */
1784  GNUNET_asprintf(&op_name, "op-%u-gen-type", op_counter);
1786  sec_name, op_name, &type)))
1787  {
1788  fprintf(stderr, "Missing type in operation %u `%s' in episode `%s'\n",
1789  op_counter, "START_SET_PROPERTY", op_name);
1790  GNUNET_free(op_name);
1791  return GNUNET_SYSERR;
1792  }
1793 
1794  /* Load arguments for set_rate, start_send, set_preference */
1795  if (0 == strcmp(type, "constant"))
1796  {
1798  }
1799  else if (0 == strcmp(type, "linear"))
1800  {
1802  }
1803  else if (0 == strcmp(type, "sinus"))
1804  {
1806  }
1807  else if (0 == strcmp(type, "random"))
1808  {
1810  }
1811  else
1812  {
1813  fprintf(stderr, "Invalid generator type %u `%s' in episode %u\n",
1814  op_counter, op_name, e->id);
1815  GNUNET_free(type);
1816  GNUNET_free(op_name);
1817  return GNUNET_SYSERR;
1818  }
1819  GNUNET_free(type);
1820  GNUNET_free(op_name);
1821 
1822 
1823  /* Get base rate */
1824  GNUNET_asprintf(&op_name, "op-%u-base-rate", op_counter);
1826  sec_name, op_name, &o->base_rate))
1827  {
1828  fprintf(stderr, "Missing base rate in operation %u `%s' in episode %u\n",
1829  op_counter, op_name, e->id);
1830  GNUNET_free(op_name);
1831  return GNUNET_SYSERR;
1832  }
1833  GNUNET_free(op_name);
1834 
1835 
1836  /* Get max rate */
1837  GNUNET_asprintf(&op_name, "op-%u-max-rate", op_counter);
1839  sec_name, op_name, &o->max_rate))
1840  {
1841  if ((GNUNET_ATS_TEST_TG_LINEAR == o->gen_type) ||
1844  {
1845  fprintf(stderr, "Missing max rate in operation %u `%s' in episode %u\n",
1846  op_counter, op_name, e->id);
1847  GNUNET_free(op_name);
1848  return GNUNET_SYSERR;
1849  }
1850  }
1851  GNUNET_free(op_name);
1852 
1853  /* Get period */
1854  GNUNET_asprintf(&op_name, "op-%u-period", op_counter);
1856  sec_name, op_name, &o->period))
1857  {
1858  o->period = e->duration;
1859  }
1860  GNUNET_free(op_name);
1861 
1862  /* Get frequency */
1863  GNUNET_asprintf(&op_name, "op-%u-frequency", op_counter);
1865  sec_name, op_name, &o->frequency))
1866  {
1867  fprintf(stderr, "Missing frequency in operation %u `%s' in episode %u\n",
1868  op_counter, op_name, e->id);
1869  GNUNET_free(op_name);
1870  return GNUNET_SYSERR;
1871  }
1872  GNUNET_free(op_name);
1873 
1874  /* Get preference */
1875  GNUNET_asprintf(&op_name, "op-%u-property", op_counter);
1877  sec_name, op_name, &prop))
1878  {
1879  fprintf(stderr, "Missing property in operation %u `%s' in episode %u\n",
1880  op_counter, op_name, e->id);
1881  GNUNET_free(op_name);
1882  GNUNET_free_non_null(prop);
1883  return GNUNET_SYSERR;
1884  }
1885 
1886  if (0 == (o->prop_type = parse_property_string(prop)))
1887  {
1888  fprintf(stderr, "Invalid property in operation %u `%s' in episode %u\n",
1889  op_counter, op_name, e->id);
1890  GNUNET_free(op_name);
1891  GNUNET_free(prop);
1892  return GNUNET_SYSERR;
1893  }
1894 
1895  GNUNET_free(prop);
1896  GNUNET_free(op_name);
1897 
1899  "Found operation %s: [%llu:%llu] %s = %llu\n",
1900  "START_SET_PROPERTY", o->peer_id, o->address_id,
1901  GNUNET_ATS_print_property_type(o->prop_type), o->base_rate);
1902 
1903  return GNUNET_OK;
1904 }
1905 
1906 static int
1908  struct Episode *e,
1909  int op_counter,
1910  char *sec_name,
1911  const struct GNUNET_CONFIGURATION_Handle *cfg)
1912 {
1913  char *op_name;
1914  char *pref;
1915 
1916  /* peer pid */
1917  GNUNET_asprintf(&op_name, "op-%u-peer-id", op_counter);
1919  sec_name, op_name, &o->peer_id))
1920  {
1921  fprintf(stderr, "Missing peer-id in operation %u `%s' in episode `%s'\n",
1922  op_counter, "STOP_SET_PROPERTY", op_name);
1923  GNUNET_free(op_name);
1924  return GNUNET_SYSERR;
1925  }
1926  GNUNET_free(op_name);
1927 
1928  /* address pid */
1929  GNUNET_asprintf(&op_name, "op-%u-address-id", op_counter);
1931  sec_name, op_name, &o->address_id))
1932  {
1933  fprintf(stderr, "Missing address-id in operation %u `%s' in episode `%s'\n",
1934  op_counter, "STOP_SET_PROPERTY", op_name);
1935  GNUNET_free(op_name);
1936  return GNUNET_SYSERR;
1937  }
1938  GNUNET_free(op_name);
1939 
1940  /* Get property */
1941  GNUNET_asprintf(&op_name, "op-%u-property", op_counter);
1943  sec_name, op_name, &pref))
1944  {
1945  fprintf(stderr, "Missing property in operation %u `%s' in episode `%s'\n",
1946  op_counter, "STOP_SET_PROPERTY", op_name);
1947  GNUNET_free(op_name);
1948  GNUNET_free_non_null(pref);
1949  return GNUNET_SYSERR;
1950  }
1951 
1952  if (0 == (o->prop_type = parse_property_string(pref)))
1953  {
1954  fprintf(stderr, "Invalid property in operation %u `%s' in episode %u\n",
1955  op_counter, op_name, e->id);
1956  GNUNET_free(op_name);
1957  GNUNET_free_non_null(pref);
1958  return GNUNET_SYSERR;
1959  }
1960 
1961  GNUNET_free(pref);
1962  GNUNET_free(op_name);
1963 
1965  "Found operation %s: [%llu:%llu] %s\n",
1966  "STOP_SET_PROPERTY", o->peer_id, o->address_id,
1967  GNUNET_ATS_print_property_type(o->prop_type));
1968 
1969  return GNUNET_OK;
1970 }
1971 
1972 
1973 static int
1975  struct Episode *e,
1976  int op_counter,
1977  char *sec_name,
1978  const struct GNUNET_CONFIGURATION_Handle *cfg)
1979 {
1980  char *op_name;
1981 
1982  /* peer pid */
1983  GNUNET_asprintf(&op_name, "op-%u-peer-id", op_counter);
1985  sec_name, op_name, &o->peer_id))
1986  {
1987  fprintf(stderr, "Missing peer-id in operation %u `%s' in episode `%s'\n",
1988  op_counter, "START_REQUEST", op_name);
1989  GNUNET_free(op_name);
1990  return GNUNET_SYSERR;
1991  }
1992  GNUNET_free(op_name);
1993  return GNUNET_OK;
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 
2005  /* peer pid */
2006  GNUNET_asprintf(&op_name, "op-%u-peer-id", op_counter);
2008  sec_name, op_name, &o->peer_id))
2009  {
2010  fprintf(stderr, "Missing peer-id in operation %u `%s' in episode `%s'\n",
2011  op_counter, "STOP_REQUEST", op_name);
2012  GNUNET_free(op_name);
2013  return GNUNET_SYSERR;
2014  }
2015  GNUNET_free(op_name);
2016  return GNUNET_OK;
2017 }
2018 
2019 
2020 static int
2021 load_episode(struct Experiment *e, struct Episode *cur,
2023 {
2024  struct GNUNET_ATS_TEST_Operation *o;
2025  char *sec_name;
2026  char *op_name;
2027  char *op;
2028  int op_counter = 0;
2029  int res;
2030 
2031  GNUNET_log(GNUNET_ERROR_TYPE_INFO, "=== Parsing episode %u\n", cur->id);
2032  GNUNET_asprintf(&sec_name, "episode-%u", cur->id);
2033 
2034  while (1)
2035  {
2036  /* Load operation */
2037  GNUNET_asprintf(&op_name, "op-%u-operation", op_counter);
2039  sec_name, op_name, &op))
2040  {
2041  GNUNET_free(op_name);
2042  break;
2043  }
2045  GNUNET_log(GNUNET_ERROR_TYPE_INFO, "==== Parsing operation %u: `%s'\n",
2046  cur->id, op_name);
2047 
2048  /* operations = set_rate, start_send, stop_send, set_preference */
2049  if (0 == strcmp(op, "address_add"))
2050  {
2052  res = load_op_add_address(o, cur,
2053  op_counter, sec_name, cfg);
2054  }
2055  else if (0 == strcmp(op, "address_del"))
2056  {
2058  res = load_op_del_address(o, cur,
2059  op_counter, sec_name, cfg);
2060  }
2061  else if (0 == strcmp(op, "start_set_property"))
2062  {
2064  res = load_op_start_set_property(o, cur,
2065  op_counter, sec_name, cfg);
2066  }
2067  else if (0 == strcmp(op, "stop_set_property"))
2068  {
2070  res = load_op_stop_set_property(o, cur,
2071  op_counter, sec_name, cfg);
2072  }
2073  else if (0 == strcmp(op, "start_set_preference"))
2074  {
2076  res = load_op_start_set_preference(o, cur,
2077  op_counter, sec_name, cfg);
2078  }
2079  else if (0 == strcmp(op, "stop_set_preference"))
2080  {
2082  res = load_op_stop_set_preference(o, cur,
2083  op_counter, sec_name, cfg);
2084  }
2085  else if (0 == strcmp(op, "start_request"))
2086  {
2088  res = load_op_start_request(o, cur,
2089  op_counter, sec_name, cfg);
2090  }
2091  else if (0 == strcmp(op, "stop_request"))
2092  {
2094  res = load_op_stop_request(o, cur,
2095  op_counter, sec_name, cfg);
2096  }
2097  else
2098  {
2099  fprintf(stderr, "Invalid operation %u `%s' in episode %u\n",
2100  op_counter, op, cur->id);
2101  res = GNUNET_SYSERR;
2102  }
2103 
2104  GNUNET_free(op);
2105  GNUNET_free(op_name);
2106 
2107  if (GNUNET_SYSERR == res)
2108  {
2109  GNUNET_free(o);
2110  GNUNET_free(sec_name);
2111  return GNUNET_SYSERR;
2112  }
2113 
2115  op_counter++;
2116  }
2117  GNUNET_free(sec_name);
2118  return GNUNET_OK;
2119 }
2120 
2121 static int
2123 {
2124  int e_counter = 0;
2125  char *sec_name;
2126  struct GNUNET_TIME_Relative e_duration;
2127  struct Episode *cur;
2128  struct Episode *last;
2129 
2130  e_counter = 0;
2131  last = NULL;
2132  while (1)
2133  {
2134  GNUNET_asprintf(&sec_name, "episode-%u", e_counter);
2136  sec_name, "duration", &e_duration))
2137  {
2138  GNUNET_free(sec_name);
2139  break;
2140  }
2141 
2142  cur = GNUNET_new(struct Episode);
2143  cur->duration = e_duration;
2144  cur->id = e_counter;
2145 
2146  if (GNUNET_OK != load_episode(e, cur, cfg))
2147  {
2148  GNUNET_free(sec_name);
2149  GNUNET_free(cur);
2150  return GNUNET_SYSERR;
2151  }
2152 
2153  GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Found episode %u with duration %s \n",
2154  e_counter,
2156 
2157  /* Update experiment */
2158  e->num_episodes++;
2160  /* Put in linked list */
2161  if (NULL == last)
2162  e->start = cur;
2163  else
2164  last->next = cur;
2165 
2166  GNUNET_free(sec_name);
2167  e_counter++;
2168  last = cur;
2169  }
2170  return e_counter;
2171 }
2172 
2173 
2174 static void
2176 {
2177  struct Experiment *e = cls;
2178 
2179  e->experiment_timeout_task = NULL;
2180  fprintf(stderr, "Experiment timeout!\n");
2181 
2182  if (NULL != e->episode_timeout_task)
2183  {
2185  e->episode_timeout_task = NULL;
2186  }
2187 
2189  GNUNET_SYSERR);
2190 }
2191 
2192 struct ATS_Address *
2194  const char *plugin_name,
2195  const void *plugin_addr,
2196  size_t plugin_addr_len,
2197  uint32_t session_id,
2198  uint32_t network)
2199 {
2200  struct ATS_Address *aa = NULL;
2201 
2202  aa = GNUNET_malloc(sizeof(struct ATS_Address) + plugin_addr_len + strlen(plugin_name) + 1);
2203  aa->atsi = GNUNET_new(struct GNUNET_ATS_Information);
2204  aa->atsi[0].type = htonl(GNUNET_ATS_NETWORK_TYPE);
2205  aa->atsi[0].value = htonl(network);
2206  aa->atsi_count = 1;
2207 
2208  aa->peer = *peer;
2209  aa->addr_len = plugin_addr_len;
2210  aa->addr = &aa[1];
2211  aa->plugin = (char *)&aa[1] + plugin_addr_len;
2212  GNUNET_memcpy(&aa[1], plugin_addr, plugin_addr_len);
2213  GNUNET_memcpy(aa->plugin, plugin_name, strlen(plugin_name) + 1);
2214  aa->session_id = session_id;
2215 
2216  return aa;
2217 }
2218 
2219 
2220 
2221 static void
2223 {
2224  struct TestPeer *p;
2225  struct TestAddress *a;
2226  int c;
2227 
2228  if (NULL == (p = find_peer_by_id(op->peer_id)))
2229  {
2230  p = GNUNET_new(struct TestPeer);
2231  p->id = op->peer_id;
2232  p->assigned_bw_in = 0;
2233  p->assigned_bw_out = 0;
2234  memset(&p->peer_id, op->peer_id, sizeof(p->peer_id));
2235  for (c = 0; c < GNUNET_ATS_PreferenceCount; c++)
2236  {
2239  }
2240 
2241  GNUNET_CONTAINER_DLL_insert(peer_head, peer_tail, p);
2242  }
2243 
2244  if (NULL != (find_address_by_id(p, op->address_id)))
2245  {
2246  GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Duplicate address %u for peer %u\n",
2247  op->address_id, op->peer_id);
2248  return;
2249  }
2250 
2251  a = GNUNET_new(struct TestAddress);
2252  a->aid = op->address_id;
2253  a->network = op->address_network;
2254  a->ats_addr = create_ats_address(&p->peer_id, op->plugin, op->address,
2255  strlen(op->address) + 1, op->address_session, op->address_network);
2256  memset(&p->peer_id, op->peer_id, sizeof(p->peer_id));
2258 
2259  for (c = 0; c < GNUNET_ATS_PropertyCount; c++)
2261 
2264 
2265  GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Adding address %u for peer %u in network `%s'\n",
2267 
2268  sh->sf->s_add(sh->sf->cls, a->ats_addr, op->address_network);
2269 }
2270 
2271 
2272 static void
2274 {
2275  struct TestPeer *p;
2276  struct TestAddress *a;
2277  struct PropertyGenerator *pg;
2278 
2279  if (NULL == (p = find_peer_by_id(op->peer_id)))
2280  {
2281  GNUNET_break(0);
2283  "Deleting address for unknown peer %u\n", op->peer_id);
2284  return;
2285  }
2286 
2287  if (NULL == (a = find_address_by_id(p, op->address_id)))
2288  {
2289  GNUNET_break(0);
2291  "Deleting address for unknown peer %u\n", op->peer_id);
2292  return;
2293  }
2294 
2295  while (NULL != (pg = find_prop_gen(p->id, a->aid, 0)))
2296  {
2298  }
2299 
2302  &p->peer_id,
2303  a->ats_addr));
2305  "Removing address %u for peer %u\n",
2306  op->address_id,
2307  op->peer_id);
2308 
2309  sh->sf->s_del(sh->sf->cls, a->ats_addr);
2310 
2311  if (NULL != l)
2312  {
2314  }
2316 
2317  GNUNET_free_non_null(a->ats_addr->atsi);
2318  GNUNET_free(a->ats_addr);
2319  GNUNET_free(a);
2320 }
2321 
2322 static void
2324 {
2325  struct PropertyGenerator *pg;
2326  struct TestPeer *p;
2327  struct TestAddress *a;
2328 
2329  if (NULL != (pg = find_prop_gen(op->peer_id, op->address_id, op->prop_type)))
2330  {
2332  GNUNET_free(pg);
2333  }
2334 
2335  if (NULL == (p = find_peer_by_id(op->peer_id)))
2336  {
2337  GNUNET_break(0);
2339  "Starting property generation for unknown peer %u\n", op->peer_id);
2340  return;
2341  }
2342 
2343  if (NULL == (a = find_address_by_id(p, op->address_id)))
2344  {
2345  GNUNET_break(0);
2347  "Setting property for unknown address %u\n", op->peer_id);
2348  return;
2349  }
2350 
2352  op->address_id,
2353  p, a,
2354  op->gen_type,
2355  op->base_rate,
2356  op->max_rate,
2357  op->period,
2358  op->frequency,
2359  op->prop_type);
2360 }
2361 
2362 static void
2364 {
2365  struct PropertyGenerator *pg = find_prop_gen(op->peer_id, op->address_id,
2366  op->prop_type);
2367 
2368  if (NULL != pg)
2369  {
2371  "Stopping preference generation for peer %u address %u\n", op->peer_id,
2372  op->address_id);
2374  }
2375  else
2376  {
2378  "Cannot find preference generator for peer %u address %u\n",
2379  op->peer_id, op->address_id);
2380  GNUNET_break(0);
2381  }
2382 }
2383 
2384 static void
2386 {
2387  struct PreferenceGenerator *pg;
2388 
2389  if (NULL != (pg = find_pref_gen(op->peer_id, op->pref_type)))
2390  {
2392  GNUNET_free(pg);
2393  }
2394 
2395  if (NULL == (find_peer_by_id(op->peer_id)))
2396  {
2397  GNUNET_break(0);
2399  "Starting preference generation for unknown peer %u\n", op->peer_id);
2400  return;
2401  }
2402 
2404  op->address_id,
2405  op->client_id,
2406  op->gen_type,
2407  op->base_rate,
2408  op->max_rate,
2409  op->period,
2410  op->frequency,
2411  op->pref_type,
2412  op->frequency);
2413 }
2414 
2415 static void
2417 {
2418  struct PreferenceGenerator *pg = find_pref_gen(op->peer_id,
2419  op->pref_type);
2420 
2421  if (NULL != pg)
2422  {
2424  "Stopping property generation for peer %u address %u\n", op->peer_id,
2425  op->address_id);
2427  }
2428  else
2429  {
2431  "Cannot find preference generator for peer %u address %u\n",
2432  op->peer_id, op->address_id);
2433  GNUNET_break(0);
2434  }
2435 }
2436 
2437 
2438 static void
2440 {
2441  struct TestPeer *p;
2442 
2443  if (NULL == (p = find_peer_by_id(op->peer_id)))
2444  {
2445  GNUNET_break(0);
2447  "Requesting address for unknown peer %u\n", op->peer_id);
2448  return;
2449  }
2450 
2451  GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Requesting address for peer %u\n",
2452  op->peer_id);
2453  p->is_requested = GNUNET_YES;
2454 
2455  sh->sf->s_get(sh->sf->cls, &p->peer_id);
2456 }
2457 
2458 
2459 static void
2461 {
2462  struct TestPeer *p;
2463 
2464  if (NULL == (p = find_peer_by_id(op->peer_id)))
2465  {
2466  GNUNET_break(0);
2468  "Requesting address for unknown peer %u\n", op->peer_id);
2469  return;
2470  }
2471 
2473  "Stop requesting address for peer %u\n",
2474  op->peer_id);
2475  p->is_requested = GNUNET_NO;
2476  p->assigned_bw_in = 0;
2477  p->assigned_bw_out = 0;
2478  sh->sf->s_get_stop(sh->sf->cls, &p->peer_id);
2479 
2480  if (NULL != l)
2481  {
2483  }
2484 }
2485 
2486 static void enforce_episode(struct Episode *ep)
2487 {
2488  struct GNUNET_ATS_TEST_Operation *cur;
2489 
2490  for (cur = ep->head; NULL != cur; cur = cur->next)
2491  {
2492  switch (cur->type)
2493  {
2494  case SOLVER_OP_ADD_ADDRESS:
2495  fprintf(stderr, "Enforcing operation: %s [%llu:%llu]\n",
2496  print_op(cur->type), cur->peer_id, cur->address_id);
2497  enforce_add_address(cur);
2498  break;
2499 
2500  case SOLVER_OP_DEL_ADDRESS:
2501  fprintf(stderr, "Enforcing operation: %s [%llu:%llu]\n",
2502  print_op(cur->type), cur->peer_id, cur->address_id);
2503  enforce_del_address(cur);
2504  break;
2505 
2507  fprintf(stderr, "Enforcing operation: %s [%llu:%llu] == %llu\n",
2508  print_op(cur->type), cur->peer_id, cur->address_id, cur->base_rate);
2510  break;
2511 
2513  fprintf(stderr, "Enforcing operation: %s [%llu:%llu] == %llu\n",
2514  print_op(cur->type), cur->peer_id, cur->address_id, cur->base_rate);
2515  enforce_stop_property(cur);
2516  break;
2517 
2519  fprintf(stderr, "Enforcing operation: %s [%llu:%llu] == %llu\n",
2520  print_op(cur->type), cur->peer_id, cur->address_id, cur->base_rate);
2522  break;
2523 
2525  fprintf(stderr, "Enforcing operation: %s [%llu:%llu] == %llu\n",
2526  print_op(cur->type), cur->peer_id, cur->address_id, cur->base_rate);
2528  break;
2529 
2531  fprintf(stderr, "Enforcing operation: %s [%llu]\n",
2532  print_op(cur->type), cur->peer_id);
2533  enforce_start_request(cur);
2534  break;
2535 
2537  fprintf(stderr, "Enforcing operation: %s [%llu]\n",
2538  print_op(cur->type), cur->peer_id);
2539  enforce_stop_request(cur);
2540  break;
2541 
2542  default:
2543  break;
2544  }
2545  }
2546 }
2547 
2548 
2549 static void
2551 {
2552  struct Experiment *e = cls;
2553 
2554  e->episode_timeout_task = NULL;
2555  if (NULL != e->ep_done_cb)
2556  e->ep_done_cb(e->cur);
2557 
2558  /* Scheduling next */
2559  e->cur = e->cur->next;
2560  if (NULL == e->cur)
2561  {
2562  /* done */
2563  fprintf(stderr, "Last episode done!\n");
2564  if (NULL != e->experiment_timeout_task)
2565  {
2567  e->experiment_timeout_task = NULL;
2568  }
2570  return;
2571  }
2572 
2573  fprintf(stderr, "Running episode %u with timeout %s\n",
2574  e->cur->id,
2577  &timeout_episode, e);
2578  enforce_episode(e->cur);
2579 }
2580 
2581 
2582 void
2586 {
2587  fprintf(stderr, "Running experiment `%s' with timeout %s\n", e->name,
2589  e->e_done_cb = e_done_cb;
2590  e->ep_done_cb = ep_done_cb;
2592 
2593  /* Start total time out */
2595  &timeout_experiment, e);
2596 
2597  /* Start */
2598  if (NULL == e->start)
2599  {
2600  GNUNET_break(0);
2601  return;
2602  }
2603 
2604  e->cur = e->start;
2605  fprintf(stderr, "Running episode %u with timeout %s\n",
2606  e->cur->id,
2609  &timeout_episode, e);
2610  enforce_episode(e->cur);
2611 }
2612 
2613 void
2615 {
2616  if (NULL != e->experiment_timeout_task)
2617  {
2619  e->experiment_timeout_task = NULL;
2620  }
2621  if (NULL != e->episode_timeout_task)
2622  {
2624  e->episode_timeout_task = NULL;
2625  }
2626  if (NULL != e->cfg)
2627  {
2629  e->cfg = NULL;
2630  }
2631  free_experiment(e);
2632 }
2633 
2634 
2635 struct Experiment *
2637 {
2638  struct Experiment *e;
2640 
2641  e = NULL;
2642 
2644  if (GNUNET_SYSERR == GNUNET_CONFIGURATION_load(cfg, filename))
2645  {
2646  fprintf(stderr, "Failed to load `%s'\n", filename);
2648  return NULL;
2649  }
2650 
2651  e = create_experiment();
2652 
2653  if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string(cfg, "experiment",
2654  "name", &e->name))
2655  {
2656  fprintf(stderr, "Invalid %s \n", "name");
2657  free_experiment(e);
2658  return NULL;
2659  }
2660  else
2661  GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Experiment name: `%s'\n", e->name);
2662 
2663  if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string(cfg, "experiment",
2664  "log_prefix", &e->log_prefix))
2665  {
2666  fprintf(stderr, "Invalid %s \n", "log_prefix");
2667  free_experiment(e);
2668  return NULL;
2669  }
2670  else
2671  GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Experiment logging prefix: `%s'\n",
2672  e->log_prefix);
2673 
2674  if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_filename(cfg, "experiment",
2675  "log_output_dir", &e->log_output_dir))
2676  {
2677  e->log_output_dir = NULL;
2678  }
2679  else
2680  GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Experiment logging output directory: `%s'\n",
2681  e->log_output_dir);
2682 
2683 
2685  "experiment", "log_append_time_stamp")))
2687  GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Experiment logging append timestamp: `%s'\n",
2688  (GNUNET_YES == e->log_append_time_stamp) ? "yes" : "no");
2689 
2690 
2691  if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_filename(cfg, "experiment",
2692  "cfg_file", &e->cfg_file))
2693  {
2694  fprintf(stderr, "Invalid %s \n", "cfg_file");
2695  free_experiment(e);
2696  return NULL;
2697  }
2698  else
2699  {
2700  GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Experiment configuration: `%s'\n", e->cfg_file);
2703  {
2704  fprintf(stderr, "Invalid configuration %s \n", "cfg_file");
2705  free_experiment(e);
2706  return NULL;
2707  }
2708  }
2709 
2710  if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_time(cfg, "experiment",
2711  "log_freq", &e->log_freq))
2712  {
2713  fprintf(stderr, "Invalid %s \n", "log_freq");
2714  free_experiment(e);
2715  return NULL;
2716  }
2717  else
2718  GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Experiment logging frequency: `%s'\n",
2720 
2721  if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_time(cfg, "experiment",
2722  "max_duration", &e->max_duration))
2723  {
2724  fprintf(stderr, "Invalid %s", "max_duration");
2725  free_experiment(e);
2726  return NULL;
2727  }
2728  else
2729  GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Experiment duration: `%s'\n",
2731 
2732  if (GNUNET_SYSERR == load_episodes(e, cfg))
2733  {
2736  e = NULL;
2737  fprintf(stderr, "Failed to load experiment\n");
2738  return NULL;
2739  }
2740  GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Loaded %u episodes with total duration %s\n",
2741  e->num_episodes,
2743 
2745  return e;
2746 }
2747 
2748 
2749 
2754 static int
2755 free_all_it(void *cls,
2756  const struct GNUNET_PeerIdentity *key,
2757  void *value)
2758 {
2759  struct ATS_Address *address = value;
2760 
2762  key, value));
2763  GNUNET_free(address);
2764 
2765  return GNUNET_OK;
2766 }
2767 
2768 void
2770 {
2772  GNUNET_NO);
2773  GNUNET_PLUGIN_unload(sh->plugin, sh->sf);
2774  sh->sf = NULL;
2776 
2778  &free_all_it,
2779  NULL);
2781  GNUNET_free(sh->plugin);
2782  GNUNET_free(sh);
2783 }
2784 
2785 
2795 unsigned int
2797  unsigned long long *out_dest,
2798  unsigned long long *in_dest,
2799  int dest_length)
2800 {
2801  char * entry_in = NULL;
2802  char * entry_out = NULL;
2803  char * quota_out_str;
2804  char * quota_in_str;
2805  int c;
2806  int res;
2807 
2808  for (c = 0; (c < GNUNET_NT_COUNT) && (c < dest_length); c++)
2809  {
2810  in_dest[c] = 0;
2811  out_dest[c] = 0;
2812  GNUNET_asprintf(&entry_out,
2813  "%s_QUOTA_OUT",
2814  GNUNET_NT_to_string(c));
2815  GNUNET_asprintf(&entry_in,
2816  "%s_QUOTA_IN",
2817  GNUNET_NT_to_string(c));
2818 
2819  /* quota out */
2820  if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string(cfg, "ats", entry_out, &quota_out_str))
2821  {
2822  res = GNUNET_NO;
2823  if (0 == strcmp(quota_out_str, BIG_M_STRING))
2824  {
2825  out_dest[c] = GNUNET_ATS_MaxBandwidth;
2826  res = GNUNET_YES;
2827  }
2828  if ((GNUNET_NO == res) && (GNUNET_OK == GNUNET_STRINGS_fancy_size_to_bytes(quota_out_str, &out_dest[c])))
2829  res = GNUNET_YES;
2830  if ((GNUNET_NO == res) && (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number(cfg, "ats", entry_out, &out_dest[c])))
2831  res = GNUNET_YES;
2832 
2833  if (GNUNET_NO == res)
2834  {
2836  _("Could not load quota for network `%s': `%s', assigning default bandwidth %llu\n"),
2838  quota_out_str,
2840  out_dest[c] = GNUNET_ATS_DefaultBandwidth;
2841  }
2842  else
2843  {
2845  "Outbound quota configure for network `%s' is %llu\n",
2847  out_dest[c]);
2848  }
2849  GNUNET_free(quota_out_str);
2850  }
2851  else
2852  {
2854  _("No outbound quota configured for network `%s', assigning default bandwidth %llu\n"),
2857  out_dest[c] = GNUNET_ATS_DefaultBandwidth;
2858  }
2859 
2860  /* quota in */
2861  if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string(cfg, "ats", entry_in, &quota_in_str))
2862  {
2863  res = GNUNET_NO;
2864  if (0 == strcmp(quota_in_str, BIG_M_STRING))
2865  {
2866  in_dest[c] = GNUNET_ATS_MaxBandwidth;
2867  res = GNUNET_YES;
2868  }
2869  if ((GNUNET_NO == res) && (GNUNET_OK == GNUNET_STRINGS_fancy_size_to_bytes(quota_in_str, &in_dest[c])))
2870  res = GNUNET_YES;
2871  if ((GNUNET_NO == res) && (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number(cfg, "ats", entry_in, &in_dest[c])))
2872  res = GNUNET_YES;
2873 
2874  if (GNUNET_NO == res)
2875  {
2877  _("Could not load quota for network `%s': `%s', assigning default bandwidth %llu\n"),
2879  quota_in_str,
2881  in_dest[c] = GNUNET_ATS_DefaultBandwidth;
2882  }
2883  else
2884  {
2886  "Inbound quota configured for network `%s' is %llu\n",
2888  in_dest[c]);
2889  }
2890  GNUNET_free(quota_in_str);
2891  }
2892  else
2893  {
2895  _("No outbound quota configure for network `%s', assigning default bandwidth %llu\n"),
2898  out_dest[c] = GNUNET_ATS_DefaultBandwidth;
2899  }
2901  "Loaded quota for network `%s' (in/out): %llu %llu\n",
2903  in_dest[c],
2904  out_dest[c]);
2905  GNUNET_free(entry_out);
2906  GNUNET_free(entry_in);
2907  }
2908  return GNUNET_NT_COUNT;
2909 }
2910 
2911 
2920 static void
2921 solver_info_cb(void *cls,
2922  enum GAS_Solver_Operation op,
2923  enum GAS_Solver_Status stat,
2925 {
2926  char *add_info;
2927 
2928  switch (add)
2929  {
2930  case GAS_INFO_NONE:
2931  add_info = "GAS_INFO_NONE";
2932  break;
2933 
2934  case GAS_INFO_FULL:
2935  add_info = "GAS_INFO_MLP_FULL";
2936  break;
2937 
2938  case GAS_INFO_UPDATED:
2939  add_info = "GAS_INFO_MLP_UPDATED";
2940  break;
2941 
2942  case GAS_INFO_PROP_ALL:
2943  add_info = "GAS_INFO_PROP_ALL";
2944  break;
2945 
2946  case GAS_INFO_PROP_SINGLE:
2947  add_info = "GAS_INFO_PROP_SINGLE";
2948  break;
2949 
2950  default:
2951  add_info = "INVALID";
2952  break;
2953  }
2954 
2955  switch (op)
2956  {
2957  case GAS_OP_SOLVE_START:
2959  "Solver notifies `%s' with result `%s' `%s'\n", "GAS_OP_SOLVE_START",
2960  (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL", add_info);
2961  return;
2962 
2963  case GAS_OP_SOLVE_STOP:
2965  "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_STOP",
2966  (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL", add_info);
2967  return;
2968 
2971  "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_SETUP_START",
2972  (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL");
2973  return;
2974 
2977  "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_SETUP_STOP",
2978  (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL");
2979  return;
2980 
2983  "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_LP_START",
2984  (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL");
2985  return;
2986 
2989  "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_LP_STOP",
2990  (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL");
2991  return;
2992 
2995  "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_MLP_START",
2996  (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL");
2997  return;
2998 
3001  "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_MLP_STOP",
3002  (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL");
3003  return;
3004 
3007  "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_UPDATE_NOTIFICATION_START",
3008  (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL");
3009  return;
3010 
3013  "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_UPDATE_NOTIFICATION_STOP",
3014  (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL");
3015  return;
3016 
3017  default:
3018  break;
3019  }
3020 }
3021 
3022 static void
3024 {
3025  struct GNUNET_TIME_Relative duration;
3026  struct TestPeer *p;
3027  static struct PreferenceGenerator *pg;
3028  uint32_t delta;
3029 
3030  if ((0 == address->assigned_bw_out) && (0 == address->assigned_bw_in))
3031  {
3033  "Solver notified to disconnect peer `%s'\n",
3034  GNUNET_i2s(&address->peer));
3035  }
3036  p = find_peer_by_pid(&address->peer);
3037  if (NULL == p)
3038  return;
3039  p->assigned_bw_out = address->assigned_bw_out;
3040  p->assigned_bw_in = address->assigned_bw_in;
3041 
3042  for (pg = pref_gen_head; NULL != pg; pg = pg->next)
3043  {
3044  if (pg->peer == p->id)
3045  {
3047  delta = duration.rel_value_us * pg->last_assigned_bw_out;
3048  pg->feedback_bw_out_acc += delta;
3049 
3050  delta = duration.rel_value_us * pg->last_assigned_bw_in;
3051  pg->feedback_bw_in_acc += delta;
3052 
3053  pg->last_assigned_bw_in = address->assigned_bw_in;
3054  pg->last_assigned_bw_out = address->assigned_bw_out;
3056  }
3057  }
3058 
3060  "Bandwidth changed addresses %s %p to %u Bps out / %u Bps in\n",
3061  GNUNET_i2s(&address->peer),
3062  address,
3063  address->assigned_bw_out,
3064  address->assigned_bw_in);
3065 
3066  if (NULL != l)
3068 
3069  return;
3070 }
3071 
3072 const double *
3073 get_preferences_cb(void *cls, const struct GNUNET_PeerIdentity *id)
3074 {
3075  struct TestPeer *p;
3076 
3078  {
3079  if (NULL == (p = find_peer_by_pid(id)))
3080  return NULL;
3081  return p->pref_abs;
3082  }
3083  else
3084  return GAS_preference_get_by_peer(NULL,
3085  id);
3086 }
3087 
3088 
3089 struct SolverHandle *
3091 {
3092  struct SolverHandle *sh;
3093  char * solver_str;
3094 
3095  switch (type)
3096  {
3098  solver_str = "proportional";
3099  break;
3100 
3101  case GNUNET_ATS_SOLVER_MLP:
3102  solver_str = "mlp";
3103  break;
3104 
3105  case GNUNET_ATS_SOLVER_RIL:
3106  solver_str = "ril";
3107  break;
3108 
3109  default:
3110  GNUNET_break(0);
3111  return NULL;
3112  break;
3113  }
3114 
3115  sh = GNUNET_new(struct SolverHandle);
3116  GNUNET_asprintf(&sh->plugin,
3117  "libgnunet_plugin_ats_%s",
3118  solver_str);
3120 
3121  /* setup environment */
3122  sh->env.cfg = e->cfg;
3123  sh->env.stats = GNUNET_STATISTICS_create("ats", e->cfg);
3124  sh->env.addresses = sh->addresses;
3128  sh->env.info_cb = &solver_info_cb;
3130 
3131  /* start normalization */
3133 
3134  /* load quotas */
3137  {
3138  GNUNET_break(0);
3139  GNUNET_free(sh->plugin);
3140  GNUNET_free(sh);
3141  end_now();
3142  return NULL;
3143  }
3144 
3145  sh->sf = GNUNET_PLUGIN_load(sh->plugin, &sh->env);
3146  if (NULL == sh->sf)
3147  {
3148  fprintf(stderr, "Failed to load solver `%s'\n", sh->plugin);
3149  GNUNET_break(0);
3150  GNUNET_free(sh->plugin);
3151  GNUNET_free(sh);
3152  end_now();
3153  return NULL;
3154  }
3155  return sh;
3156 }
3157 
3158 
3159 static void
3161 {
3162  struct TestPeer *cur;
3163  struct TestPeer *next;
3164 
3165  struct TestAddress *cur_a;
3166  struct TestAddress *next_a;
3167 
3168  /* Stop logging */
3170 
3171  /* Stop all preference generation */
3173 
3174  /* Stop all property generation */
3176 
3177  if (opt_print)
3178  {
3179  GNUNET_log(GNUNET_ERROR_TYPE_INFO, "== Printing log information \n");
3181  }
3182  if (opt_save)
3183  {
3184  GNUNET_log(GNUNET_ERROR_TYPE_INFO, "== Saving log information \n");
3186  e->log_output_dir);
3187  }
3188 
3189  if (NULL != l)
3190  {
3192  l = NULL;
3193  }
3194 
3195  /* Clean up experiment */
3196  if (NULL != e)
3197  {
3199  e = NULL;
3200  }
3201 
3202  next = peer_head;
3203  while (NULL != (cur = next))
3204  {
3205  next = cur->next;
3206  GNUNET_CONTAINER_DLL_remove(peer_head, peer_tail, cur);
3207  next_a = cur->addr_head;
3208  while (NULL != (cur_a = next_a))
3209  {
3210  next_a = cur_a->next;
3211  GNUNET_CONTAINER_DLL_remove(cur->addr_head, cur->addr_tail, cur_a);
3212  GNUNET_free(cur_a);
3213  }
3214  GNUNET_free(cur);
3215  }
3216  if (NULL != sh)
3217  {
3219  sh = NULL;
3220  }
3221 
3222  /* Shutdown */
3223  end_now();
3224 }
3225 
3226 static void
3228 {
3229  if (GNUNET_OK == success)
3230  GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Experiment done successful in %s\n",
3232  else
3233  GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Experiment failed \n");
3234 
3236 }
3237 
3238 static void
3240 {
3241  GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Episode %u done\n", ep->id);
3242 }
3243 
3244 
3245 
3249 static void
3251 {
3252  if (NULL != e)
3253  {
3255  e = NULL;
3256  }
3257  if (NULL != sh)
3258  {
3260  sh = NULL;
3261  }
3262 }
3263 
3264 static void
3265 run(void *cls, char * const *args, const char *cfgfile,
3266  const struct GNUNET_CONFIGURATION_Handle *cfg)
3267 {
3268  enum GNUNET_ATS_Solvers solver;
3269  int c;
3270 
3271  if (NULL == opt_exp_file)
3272  {
3273  fprintf(stderr, "No experiment given ...\n");
3274  res = 1;
3275  end_now();
3276  return;
3277  }
3278 
3279  if (NULL == opt_solver)
3280  {
3281  fprintf(stderr, "No solver given ...\n");
3282  res = 1;
3283  end_now();
3284  return;
3285  }
3286 
3287  if (0 == strcmp(opt_solver, "mlp"))
3288  {
3289  solver = GNUNET_ATS_SOLVER_MLP;
3290  }
3291  else if (0 == strcmp(opt_solver, "proportional"))
3292  {
3294  }
3295  else if (0 == strcmp(opt_solver, "ril"))
3296  {
3297  solver = GNUNET_ATS_SOLVER_RIL;
3298  }
3299  else
3300  {
3301  fprintf(stderr, "No solver given ...");
3302  res = 1;
3303  end_now();
3304  return;
3305  }
3306 
3307  for (c = 0; c < GNUNET_ATS_PropertyCount; c++)
3309 
3310  for (c = 0; c < GNUNET_ATS_PreferenceCount; c++)
3312 
3313  /* load experiment */
3314  GNUNET_log(GNUNET_ERROR_TYPE_INFO, "=== Loading experiment\n");
3316  if (NULL == e)
3317  {
3318  fprintf(stderr, "Failed to load experiment ...\n");
3319  res = 1;
3320  end_now();
3321  return;
3322  }
3323 
3324  /* load solver */
3325  GNUNET_log(GNUNET_ERROR_TYPE_INFO, "=== Loading solver\n");
3326  sh = GNUNET_ATS_solvers_solver_start(solver);
3327  if (NULL == sh)
3328  {
3329  fprintf(stderr, "Failed to start solver ...\n");
3330  end_now();
3331  res = 1;
3332  return;
3333  }
3334 
3335  /* start logging */
3336  GNUNET_log(GNUNET_ERROR_TYPE_INFO, "=== Start logging \n");
3338 
3339  /* run experiment */
3340  GNUNET_log(GNUNET_ERROR_TYPE_INFO, "=== Running experiment \n");
3343 
3344  /* WAIT */
3345 }
3346 
3347 
3354 int
3355 main(int argc, char *argv[])
3356 {
3357  opt_exp_file = NULL;
3358  opt_solver = NULL;
3359  opt_log = GNUNET_NO;
3360  opt_save = GNUNET_NO;
3361 
3362  res = 0;
3363 
3364  static struct GNUNET_GETOPT_CommandLineOption options[] =
3365  {
3367  "solver",
3368  gettext_noop("solver to use"),
3369  &opt_solver),
3370 
3372  "experiment"
3373  gettext_noop("experiment to use"),
3374  &opt_exp_file),
3375 
3377 
3379  "print",
3380  gettext_noop("print logging"),
3381  &opt_print),
3382 
3384  "file",
3385  gettext_noop("save logging to disk"),
3386  &opt_save),
3387 
3389  "dn",
3390  gettext_noop("disable normalization"),
3392 
3394  };
3395 
3396  GNUNET_PROGRAM_run(argc, argv, "gnunet-ats-solver-eval",
3397  NULL, options, &run, argv[0]);
3398 
3399  return res;
3400 }
3401 /* end of file ats-testing-experiment.c*/
void GNUNET_ATS_solver_generate_preferences_stop(struct PreferenceGenerator *pg)
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
struct LoggingPeer * head
void GAS_normalization_stop()
Stop the normalization component and free all items.
struct GNUNET_ATS_TEST_Operation * next
GAS_solver_stop_get_preferred_address s_get_stop
Tell solver stop notifying ATS about changes for this peers.
Local area network.
Definition: gnunet_nt_lib.h:49
static void enforce_start_property(struct GNUNET_ATS_TEST_Operation *op)
double prop_abs[GNUNET_ATS_PropertyCount]
Solving of the LP problem was started MLP solver only.
After the problem was finished, start notifications about changes to addresses.
static void done()
struct Episode * start
Create file if it doesn&#39;t exist.
void GNUNET_ATS_solvers_solver_stop(struct SolverHandle *sh)
struct PreferenceGenerator * next
struct LoggingHandle * GNUNET_ATS_solver_logging_start(struct GNUNET_TIME_Relative freq)
struct LoggingTimeStep * tail
struct GNUNET_TIME_Absolute time_start
int GNUNET_CONFIGURATION_get_value_time(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, struct GNUNET_TIME_Relative *time)
Get a configuration value that should be a relative time.
static void set_feedback_task(void *cls)
GNUNET_ATS_TESTING_EpisodeDoneCallback ep_done_cb
GAS_solver_address_add s_add
Add a new address for a peer to the solver.
static void enforce_add_address(struct GNUNET_ATS_TEST_Operation *op)
int GNUNET_DISK_file_close(struct GNUNET_DISK_FileHandle *h)
Close an open file.
Definition: disk.c:1339
long long unsigned int peer_id
GNUNET_ATS_TESTING_ExperimentDoneCallback e_done_cb
int GNUNET_CONFIGURATION_get_value_number(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, unsigned long long *number)
Get a configuration value that should be a number.
uint64_t rel_value_us
The actual value.
The proportional solver had to recalculate for a single network.
const char * GNUNET_NT_to_string(enum GNUNET_NetworkType net)
Convert a enum GNUNET_NetworkType to a string.
Definition: nt.c:43
static struct GNUNET_TIME_Relative delta
Definition: speedup.c:35
uint32_t session_id
Session ID, can never be 0.
struct Episode * next
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
The setup of the problem as a preparation to solve it was started.
struct GNUNET_STATISTICS_Handle * stats
Statistics handle to be used by the solver.
void GNUNET_ATS_solver_logging_free(struct LoggingHandle *l)
static void enforce_del_address(struct GNUNET_ATS_TEST_Operation *op)
double pref_abs[GNUNET_ATS_PreferenceCount]
struct GNUNET_TIME_Relative total_duration
struct LoggingTimeStep * prev
int active
Is this the active address for this peer?
GAS_get_preferences get_preferences
ATS addresses function to obtain preference values.
static int load_episodes(struct Experiment *e, struct GNUNET_CONFIGURATION_Handle *cfg)
static int load_op_start_set_property(struct GNUNET_ATS_TEST_Operation *o, struct Episode *e, int op_counter, char *sec_name, const struct GNUNET_CONFIGURATION_Handle *cfg)
struct GNUNET_PeerIdentity peer
Peer ID this address is for.
struct GNUNET_STATISTICS_Handle * GNUNET_STATISTICS_create(const char *subsystem, const struct GNUNET_CONFIGURATION_Handle *cfg)
Get handle for the statistics service.
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_verbose(unsigned int *level)
Define the &#39;-V&#39; verbosity option.
struct LoggingAddress * addr_tail
long long unsigned int peer
GAS_Solver_Status
Status of a GAS_Solver_Operation operation.
struct GNUNET_TIME_Relative duration_period
static int load_op_stop_set_property(struct GNUNET_ATS_TEST_Operation *o, struct Episode *e, int op_counter, char *sec_name, const struct GNUNET_CONFIGURATION_Handle *cfg)
uint32_t GNUNET_CRYPTO_random_u32(enum GNUNET_CRYPTO_Quality mode, uint32_t i)
Produce a random value.
static int opt_log
cmd option -l: enable logging
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
The proportional solver had to recalculate for all networks.
No more specific information.
const void * addr
Address (in plugin-specific binary format).
static char * opt_exp_file
cmd option -e: experiment file
struct PropertyGenerator * GNUNET_ATS_solver_generate_property_start(unsigned int peer, unsigned int address_id, struct TestPeer *test_peer, struct TestAddress *test_address, enum GeneratorType type, long int base_value, long int value_rate, struct GNUNET_TIME_Relative period, struct GNUNET_TIME_Relative frequency, uint32_t ats_property)
Generate between the source master and the partner and set property with a value depending on the gen...
long long unsigned int aid
struct LoggingTimeStep * next
static void solver_info_cb(void *cls, enum GAS_Solver_Operation op, enum GAS_Solver_Status stat, enum GAS_Solver_Additional_Information add)
Information callback for the solver.
long long unsigned int address_id
#define DEFAULT_REL_QUALITY
Value we return for a normalized quality score if we have no data.
static void logging_task(void *cls)
long long unsigned int id
static struct TestPeer * find_peer_by_pid(const struct GNUNET_PeerIdentity *pid)
struct GNUNET_PeerIdentity peer_id
GAS_solver_address_feedback_preference s_feedback
Give feedback about the current assignment.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
struct LoggingTimeStep * head
static struct Experiment * e
int GNUNET_DISK_directory_create_for_file(const char *filename)
Create the directory structure for storing a file.
Definition: disk.c:681
ats service address: management of ATS properties and preferences normalization
GAS_solver_address_property_changed s_address_update_property
Update the properties of an address in the solver.
static struct GNUNET_HashCode session_id
int GNUNET_STRINGS_fancy_size_to_bytes(const char *fancy_size, unsigned long long *size)
Convert a given fancy human-readable size to bytes.
Definition: strings.c:318
int GNUNET_CONTAINER_multipeermap_remove(struct GNUNET_CONTAINER_MultiPeerMap *map, const struct GNUNET_PeerIdentity *key, const void *value)
Remove the given key-value pair from the map.
static char * peer_id
Option –peer.
Definition: gnunet-cadet.c:42
Wide area network (i.e.
Definition: gnunet_nt_lib.h:54
#define GNUNET_NO
Definition: gnunet_common.h:78
struct GNUNET_TIME_Absolute feedback_last_delay_update
int main(int argc, char *argv[])
Main function of the benchmark.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
A full solution process is performed Quite specific to the MLP solver.
static struct TestAddress * find_active_address(struct TestPeer *p)
Wireless LAN (i.e.
Definition: gnunet_nt_lib.h:59
#define GNUNET_free_non_null(ptr)
Free the memory pointed to by ptr if ptr is not NULL.
char * plugin
Plugin name.
size_t addr_len
Address length, number of bytes in addr.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
Definition of a command line option.
unsigned int num_episodes
struct GNUNET_TIME_Relative period
long long unsigned int client_id
struct GNUNET_CONFIGURATION_Handle * GNUNET_CONFIGURATION_create(void)
Create a new configuration object.
long long unsigned int pid
Solving of the LP problem is done MLP solver only.
void GNUNET_ATS_solver_logging_eval(struct LoggingHandle *l)
void GNUNET_STATISTICS_destroy(struct GNUNET_STATISTICS_Handle *h, int sync_first)
Destroy a handle (free all state associated with it).
struct GNUNET_CONTAINER_MultiPeerMap * GNUNET_CONTAINER_multipeermap_create(unsigned int len, int do_not_copy_keys)
Create a multi peer map (hash map for public keys of peers).
Handle for the service.
struct LoggingAddress * next
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
manage preferences expressed by clients
static void update_preference(struct GNUNET_SERVICE_Client *client, const struct GNUNET_PeerIdentity *peer, enum GNUNET_ATS_PreferenceKind kind, float score_abs)
Update the absolute preference and calculate the new relative preference value.
struct GNUNET_STATISTICS_Handle * GSA_stats
Handle for statistics.
uint64_t abs_value_us
The actual value.
GNUNET_ATS_Solvers
static struct TestPeer * peer_tail
struct TestAddress * addr_tail
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
End of preference list.
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_OPTION_END
Definition: 002.c:13
struct ATS_Address * ats_addr
void GNUNET_CONTAINER_multipeermap_destroy(struct GNUNET_CONTAINER_MultiPeerMap *map)
Destroy a hash map.
struct PropertyGenerator * next
static enum GNUNET_ATS_Property parse_preference_string(const char *str)
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_string(char shortName, const char *name, const char *argumentHelp, const char *description, char **str)
Allow user to specify a string.
int GNUNET_CONFIGURATION_load(struct GNUNET_CONFIGURATION_Handle *cfg, const char *filename)
Load configuration.
#define _(String)
GNU gettext support macro.
Definition: platform.h:181
enum GNUNET_ATS_PreferenceKind kind
struct SolverHandle * GNUNET_ATS_solvers_solver_start(enum GNUNET_ATS_Solvers type)
GAS_Solver_Operation
Operation codes for solver information callback.
void * GNUNET_PLUGIN_unload(const char *library_name, void *arg)
Unload plugin (runs the "done" callback and returns whatever "done" returned).
Definition: plugin.c:255
uint32_t assigned_bw_in
Inbound bandwidth assigned by solver.
struct LoggingPeer * tail
static char * opt_solver
struct GNUNET_SCHEDULER_Task * experiment_timeout_task
struct LoggingPeer * next
static struct LoggingHandle * l
static struct PropertyGenerator * find_prop_gen(unsigned int peer, unsigned int address, uint32_t ats_property)
Set ats_property to 0 to find all pgs.
Solving of the MLP problem is done MLP solver only.
double pref_abs[GNUNET_ATS_PREFERENCE_END]
struct GNUNET_TIME_Relative log_freq
void GAS_normalization_update_property(struct ATS_Address *address)
Update and normalize atsi performance information.
int GNUNET_asprintf(char **buf, const char *format,...)
Like asprintf, just portable.
Bluetooth LAN.
Definition: gnunet_nt_lib.h:64
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:1237
struct GNUNET_TIME_Absolute feedback_last_bw_update
struct LoggingAddress * addr_head
struct GNUNET_SCHEDULER_Task * set_task
A solution iteration has been started.
static void end_now()
Do shutdown.
void GNUNET_STRINGS_utf8_toupper(const char *input, char *output)
Convert the utf-8 input string to upper case.
Definition: strings.c:577
static int opt_save
cmd option -p: enable plots
static void enforce_stop_property(struct GNUNET_ATS_TEST_Operation *op)
static struct GNUNET_OS_Process * p
Helper process we started.
Definition: gnunet-qr.c:59
static void experiment_done_cb(struct Experiment *e, struct GNUNET_TIME_Relative duration, int success)
void(* GNUNET_ATS_TESTING_ExperimentDoneCallback)(struct Experiment *e, struct GNUNET_TIME_Relative duration, int success)
static struct LoggingFileHandle * find_logging_file_handle(struct LoggingFileHandle *lf_head, struct LoggingFileHandle *lf_tail, int peer_id, int address_id)
enum GeneratorType type
static char * value
Value of the record to add/remove.
struct LoggingFileHandle * next
double prop_norm[GNUNET_ATS_PropertyCount]
struct Episode * cur
Truncate file if it exists.
ssize_t GNUNET_DISK_file_write(const struct GNUNET_DISK_FileHandle *h, const void *buffer, size_t n)
Write a buffer to a file.
Definition: disk.c:817
static int free_all_it(void *cls, const struct GNUNET_PeerIdentity *key, void *value)
Solver.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_now(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run as soon as possible.
Definition: scheduler.c:1264
#define DIR_SEPARATOR_STR
Definition: platform.h:168
static char * print_generator_type(enum GeneratorType g)
static struct PropertyGenerator * prop_gen_tail
void GNUNET_ATS_solver_logging_now(struct LoggingHandle *l)
Logging.
static int load_op_stop_set_preference(struct GNUNET_ATS_TEST_Operation *o, struct Episode *e, int op_counter, char *sec_name, const struct GNUNET_CONFIGURATION_Handle *cfg)
static struct SolverHandle * sh
GAS_Solver_Additional_Information
Status of the operation.
const char * GNUNET_STRINGS_relative_time_to_string(struct GNUNET_TIME_Relative delta, int do_round)
Give relative time in human-readable fancy format.
Definition: strings.c:686
struct ATS_Address * create_ats_address(const struct GNUNET_PeerIdentity *peer, const char *plugin_name, const void *plugin_addr, size_t plugin_addr_len, uint32_t session_id, uint32_t network)
GAS_solver_address_delete s_del
Delete an address in the solver.
long long unsigned int aid
Solving of the MLP problem was started MLP solver only.
static int load_op_start_request(struct GNUNET_ATS_TEST_Operation *o, struct Episode *e, int op_counter, char *sec_name, const struct GNUNET_CONFIGURATION_Handle *cfg)
long long unsigned int base_rate
static const char * print_op(enum OperationType op)
Experiments.
void GNUNET_CONFIGURATION_destroy(struct GNUNET_CONFIGURATION_Handle *cfg)
Destroy configuration object.
const double * get_preferences_cb(void *cls, const struct GNUNET_PeerIdentity *id)
static char * filename
uint32_t assigned_bw_in
void GNUNET_ATS_solver_generate_property_stop(struct PropertyGenerator *pg)
static void cleanup(void *cls)
Function scheduled as very last function, cleans up after us.
enum GNUNET_ATS_PreferenceKind pref_type
struct GNUNET_TIME_Relative frequency
static void timeout_experiment(void *cls)
void(* GNUNET_ATS_TESTING_EpisodeDoneCallback)(struct Episode *e)
#define GNUNET_TIME_UNIT_FOREVER_REL
Constant used to specify "forever".
long long unsigned int address_id
static char * plugin_name
Solver plugin name as string.
static int load_op_add_address(struct GNUNET_ATS_TEST_Operation *o, struct Episode *e, int op_counter, char *sec_name, const struct GNUNET_CONFIGURATION_Handle *cfg)
#define GNUNET_ATS_DefaultBandwidth
Default bandwidth assigned to a network : 64 KB/s.
const char * GNUNET_ATS_print_preference_type(enum GNUNET_ATS_PreferenceKind type)
Convert a enum GNUNET_ATS_PreferenceType to a string.
struct GNUNET_SCHEDULER_Task * episode_timeout_task
GAS_solver_address_change_preference s_pref
Change relative preference for quality in solver.
void GNUNET_ATS_solvers_experimentation_run(struct Experiment *e, GNUNET_ATS_TESTING_EpisodeDoneCallback ep_done_cb, GNUNET_ATS_TESTING_ExperimentDoneCallback e_done_cb)
struct GNUNET_SCHEDULER_Task * set_task
static void enforce_start_request(struct GNUNET_ATS_TEST_Operation *op)
void GNUNET_ATS_solvers_experimentation_stop(struct Experiment *e)
static int res
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
Definition: time.c:118
struct GNUNET_TIME_Relative duration
Entry for a benchmark peer.
struct GNUNET_TIME_Absolute start_time
struct LinkProperty * props
list of link properties
static struct PreferenceGenerator * pref_gen_head
Preference Generators.
static int load_op_stop_request(struct GNUNET_ATS_TEST_Operation *o, struct Episode *e, int op_counter, char *sec_name, const struct GNUNET_CONFIGURATION_Handle *cfg)
int GNUNET_CONFIGURATION_get_value_string(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, char **value)
Get a configuration value that should be a string.
void GNUNET_ATS_solver_generate_property_stop_all()
Stop all preferences generators.
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
Definition: gnunet-arm.c:104
An operation in an experiment.
struct TestAddress * test_address
static double get_property(struct PropertyGenerator *pg)
#define GNUNET_ATS_MaxBandwidth
Maximum bandwidth assigned to a network : 4095 MB/s.
Address with additional information.
static int opt_print
cmd option -p: print logs
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
struct GNUNET_HashCode key
The key used in the DHT.
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
struct GNUNET_TIME_Absolute time_start
static int opt_disable_normalization
cmd option -d: disable normalization
static struct TestPeer * peer_head
struct GNUNET_TIME_Relative delta
static struct Experiment * create_experiment()
void GNUNET_ATS_solver_generate_preferences_stop_all()
Stop all preferences generators.
static void solver_bandwidth_changed_cb(void *cls, struct ATS_Address *address)
struct GNUNET_TIME_Absolute timestamp
void * cls
Closure to pass to all solver functions in this struct.
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
Change the peer&#39;s latency value to the given amount.
#define DEFAULT_REL_PREFERENCE
Default relative preference value we assume if we know nothing.
Loopback (same host).
Definition: gnunet_nt_lib.h:44
struct GNUNET_TIME_Absolute feedback_last
static int opt_verbose
cmd option -v: verbose logs
struct GNUNET_ATS_SolverFunctions * sf
Solver handle.
static int add
Desired action is to add a record.
static void set_prop_task(void *cls)
struct GNUNET_DISK_FileHandle * f_hd
#define GNUNET_TIME_UNIT_ZERO
Relative time zero.
#define GNUNET_memcmp(a, b)
Compare memory in a and b, where both must be of the same pointer type.
struct GNUNET_CONFIGURATION_Handle * cfg
unsigned int GNUNET_ATS_solvers_load_quotas(const struct GNUNET_CONFIGURATION_Handle *cfg, unsigned long long *out_dest, unsigned long long *in_dest, int dest_length)
Load quotas for networks from configuration.
static double default_properties[GNUNET_ATS_PropertyCount]
#define BIG_M_STRING
GAS_solver_get_preferred_address s_get
Tell solver to notify ATS if the address to use changes for a specific peer using the bandwidth chang...
unsigned long long in_quota[6]
Array of configured inbound quotas Order according to networks in network array.
A solution iteration has been finished.
static int load_op_start_set_preference(struct GNUNET_ATS_TEST_Operation *o, struct Episode *e, int op_counter, char *sec_name, const struct GNUNET_CONFIGURATION_Handle *cfg)
Allow multiple values with the same key.
struct GNUNET_ATS_TEST_Operation * head
static void episode_done_cb(struct Episode *ep)
int GNUNET_CONTAINER_multipeermap_put(struct GNUNET_CONTAINER_MultiPeerMap *map, const struct GNUNET_PeerIdentity *key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt)
Store a key-value pair in the map.
struct GNUNET_ATS_TEST_Operation * tail
struct TestAddress * next
static int load_episode(struct Experiment *e, struct Episode *cur, struct GNUNET_CONFIGURATION_Handle *cfg)
struct GNUNET_SCHEDULER_Task * feedback_task
static void enforce_stop_request(struct GNUNET_ATS_TEST_Operation *op)
int GNUNET_CONTAINER_multipeermap_iterate(struct GNUNET_CONTAINER_MultiPeerMap *map, GNUNET_CONTAINER_PeerMapIterator it, void *it_cls)
Iterate over all entries in the map.
struct PreferenceGenerator * GNUNET_ATS_solver_generate_preferences_start(unsigned int peer, unsigned int address_id, unsigned int client_id, enum GeneratorType type, long int base_value, long int value_rate, struct GNUNET_TIME_Relative period, struct GNUNET_TIME_Relative frequency, enum GNUNET_ATS_PreferenceKind kind, struct GNUNET_TIME_Relative feedback_frequency)
Generate between the source master and the partner and set property with a value depending on the gen...
Everybody can read.
GAS_solver_bulk_start s_bulk_start
Start a bulk operation.
struct GNUNET_TIME_Relative GNUNET_TIME_relative_add(struct GNUNET_TIME_Relative a1, struct GNUNET_TIME_Relative a2)
Add relative times together.
Definition: time.c:577
double prop_abs[GNUNET_ATS_PropertyCount]
void GNUNET_ATS_solver_logging_stop(struct LoggingHandle *l)
The identity of the host (wraps the signing key of the peer).
static void run(void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
int GNUNET_CONTAINER_multipeermap_contains_value(const struct GNUNET_CONTAINER_MultiPeerMap *map, const struct GNUNET_PeerIdentity *key, const void *value)
Check if the map contains the given value under the given key.
static struct PreferenceGenerator * find_pref_gen(unsigned int peer, enum GNUNET_ATS_PreferenceKind kind)
uint32_t assigned_bw_out
Outbound bandwidth assigned by solver.
struct Experiment * GNUNET_ATS_solvers_experimentation_load(char *filename)
long long unsigned int peer
void GNUNET_ATS_solver_logging_write_to_disk(struct LoggingHandle *l, int add_time_stamp, char *output_dir)
static int load_op_del_address(struct GNUNET_ATS_TEST_Operation *o, struct Episode *e, int op_counter, char *sec_name, const struct GNUNET_CONFIGURATION_Handle *cfg)
configuration data
Definition: configuration.c:83
struct TestAddress * addr_head
static void enforce_start_preference(struct GNUNET_ATS_TEST_Operation *op)
struct GNUNET_TIME_Relative GNUNET_TIME_absolute_get_duration(struct GNUNET_TIME_Absolute whence)
Get the duration of an operation as the difference of the current time and the given start time "henc...
Definition: time.c:373
void GAS_normalization_start()
Start the normalization component.
static enum GNUNET_ATS_Property parse_property_string(const char *str)
struct GNUNET_TIME_Relative frequency
static void timeout_episode(void *cls)
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_flag(char shortName, const char *name, const char *description, int *val)
Allow user to specify a flag (which internally means setting an integer to 1/GNUNET_YES/GNUNET_OK.
static double get_preference(struct PreferenceGenerator *pg)
const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration handle to be used by the solver.
#define GNUNET_log(kind,...)
GAS_solver_information_callback info_cb
Callback for solver to call with status information, can be NULL.
long long unsigned int aid
Open the file for both reading and writing.
Change the peer&#39;s bandwidth value (value per byte of bandwidth in the goal function) to the given amo...
uint32_t assigned_bw_out
static int test_address(void *cls, const struct GNUNET_HELLO_Address *address, struct GNUNET_TIME_Absolute expiration)
Test for checking whether HELLO message is empty.
int GNUNET_CONFIGURATION_get_value_filename(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, char **value)
Get a configuration value that should be the name of a file or directory.
The setup of the problem as a preparation to solve is finished.
unsigned long long out_quota[6]
Array of configured outbound quotas Order according to networks in network array. ...
static struct GNUNET_TIME_Relative duration
How long do we run the test?
struct TestPeer * next
static struct TestPeer * find_peer_by_id(int id)
int GNUNET_PROGRAM_run(int argc, char *const *argv, const char *binaryName, const char *binaryHelp, const struct GNUNET_GETOPT_CommandLineOption *options, GNUNET_PROGRAM_Main task, void *task_cls)
Run a standard GNUnet command startup sequence (initialize loggers and configuration, parse options).
Definition: program.c:367
An existing solution was reused Quite specific to the MLP solver.
struct GNUNET_TIME_Relative feedback_delay
struct TestPeer * test_peer
struct GNUNET_TIME_Relative frequency
static struct PreferenceGenerator * pref_gen_tail
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
#define GNUNET_YES
Definition: gnunet_common.h:77
static void free_experiment(struct Experiment *e)
struct GNUNET_TIME_Relative GNUNET_TIME_absolute_get_difference(struct GNUNET_TIME_Absolute start, struct GNUNET_TIME_Absolute end)
Compute the time difference between the given start and end times.
Definition: time.c:353
void * GNUNET_PLUGIN_load(const char *library_name, void *arg)
Setup plugin (runs the "init" callback and returns whatever "init" returned).
Definition: plugin.c:206
#define GNUNET_ATS_PreferenceTypeString
ATS preference types as string array initializer.
static void set_pref_task(void *cls)
#define DEFAULT_ABS_PREFERENCE
Default preference value we assume if we know nothing.
struct GNUNET_TIME_Relative log_freq
struct GNUNET_CONTAINER_MultiPeerMap * addresses
Address hashmap.
struct GNUNET_ATS_PluginEnvironment env
Solver environment.
GNUNET_ATS_PreferenceKind
Enum defining all known preference categories.
struct GNUNET_TIME_Relative feedback_frequency
double pref_norm[GNUNET_ATS_PREFERENCE_END]
static struct GNUNET_ARM_Operation * op
Current operation.
Definition: gnunet-arm.c:139
struct GNUNET_CONTAINER_MultiPeerMap * addresses
Hashmap containing all addresses available.
static double default_preferences[GNUNET_ATS_PreferenceCount]
static struct GNUNET_PeerIdentity pid
Identity of the peer we transmit to / connect to.
struct GNUNET_SCHEDULER_Task * logging_task
long long unsigned int max_rate
int GNUNET_CONFIGURATION_get_value_yesno(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option)
Get a configuration value that should be in a set of "YES" or "NO".
double prop_norm[GNUNET_ATS_PropertyCount]
struct GNUNET_DISK_FileHandle * GNUNET_DISK_file_open(const char *fn, enum GNUNET_DISK_OpenFlags flags, enum GNUNET_DISK_AccessPermissions perm)
Open a file.
Definition: disk.c:1262
uint32_t atsi_count
ATS performance information for this address, size of the atsi array.
struct GNUNET_TIME_Relative max_duration
GAS_solver_bulk_stop s_bulk_stop
Bulk operation done.
static char * address
GNS address for this phone.
GAS_bandwidth_changed_cb bandwidth_changed_cb
ATS addresses callback to be notified about bandwidth assignment changes.
After the problem was finished, notifications about changes to addresses are done.
long long unsigned int address_session
const double * GAS_preference_get_by_peer(void *cls, const struct GNUNET_PeerIdentity *id)
Get the normalized preference values for a specific peer or the default values if.
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
#define GNUNET_NT_COUNT
struct GNUNET_TIME_Relative duration_period
unsigned int network_count
Number of networks available, size of the out_quota and in_quota arrays.
static struct TestAddress * find_address_by_id(struct TestPeer *peer, int aid)
No good quality of the operation is needed (i.e., random numbers can be pseudo-random).
double pref_norm[GNUNET_ATS_PreferenceCount]
#define GNUNET_malloc(size)
Wrapper around malloc.
static void enforce_episode(struct Episode *ep)
static void enforce_stop_preference(struct GNUNET_ATS_TEST_Operation *op)
#define GNUNET_free(ptr)
Wrapper around free.
static struct PropertyGenerator * prop_gen_head
Property Generators.
long long unsigned int id
Time for relative time used by GNUnet, in microseconds.
char * plugin
Solver plugin name.
#define gettext_noop(String)
Definition: gettext.h:69
Category of last resort.
Definition: gnunet_nt_lib.h:39
struct GNUNET_PeerIdentity peer_id
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:956