GNUnet  0.11.x
ats-testing-experiment.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 "ats-testing.h"
29 
30 const char *
32 {
33  switch (op)
34  {
35  case START_SEND:
36  return "START_SEND";
37 
38  case STOP_SEND:
39  return "STOP_SEND";
40 
41  case START_PREFERENCE:
42  return "START_PREFERENCE";
43 
44  case STOP_PREFERENCE:
45  return "STOP_PREFERENCE";
46 
47  default:
48  break;
49  }
50  return "";
51 }
52 
53 
54 static struct Experiment *
56 {
57  struct Experiment *e;
58 
59  e = GNUNET_new (struct Experiment);
60  e->name = NULL;
61  e->num_masters = 0;
62  e->num_slaves = 0;
63  e->start = NULL;
65  return e;
66 }
67 
68 
69 static void
71 {
72  struct Episode *cur;
73  struct Episode *next;
74  struct GNUNET_ATS_TEST_Operation *cur_o;
75  struct GNUNET_ATS_TEST_Operation *next_o;
76 
77  next = e->start;
78  for (cur = next; NULL != cur; cur = next)
79  {
80  next = cur->next;
81 
82  next_o = cur->head;
83  for (cur_o = next_o; NULL != cur_o; cur_o = next_o)
84  {
85  next_o = cur_o->next;
86  GNUNET_free (cur_o);
87  }
88  GNUNET_free (cur);
89  }
90 
93  GNUNET_free (e);
94 }
95 
96 
97 static int
99  struct Episode *cur,
101 {
102  struct GNUNET_ATS_TEST_Operation *o;
103  char *sec_name;
104  char *op_name;
105  char *op;
106  char *type;
107  char *pref;
108  int op_counter = 0;
109 
110  fprintf (stderr, "Parsing episode %u\n", cur->id);
111  GNUNET_asprintf (&sec_name, "episode-%u", cur->id);
112 
113  while (1)
114  {
115  /* Load operation */
116  GNUNET_asprintf (&op_name, "op-%u-operation", op_counter);
118  sec_name,
119  op_name, &op))
120  {
121  GNUNET_free (op_name);
122  break;
123  }
125  /* operations = set_rate, start_send, stop_send, set_preference */
126  if (0 == strcmp (op, "start_send"))
127  {
128  o->type = START_SEND;
129  }
130  else if (0 == strcmp (op, "stop_send"))
131  {
132  o->type = STOP_SEND;
133  }
134  else if (0 == strcmp (op, "start_preference"))
135  {
136  o->type = START_PREFERENCE;
137  }
138  else if (0 == strcmp (op, "stop_preference"))
139  {
140  o->type = STOP_PREFERENCE;
141  }
142  else
143  {
144  fprintf (stderr, "Invalid operation %u `%s' in episode %u\n",
145  op_counter, op, cur->id);
146  GNUNET_free (op);
147  GNUNET_free (op_name);
148  GNUNET_free (o);
149  GNUNET_free (sec_name);
150  return GNUNET_SYSERR;
151  }
152  GNUNET_free (op_name);
153 
154  /* Get source */
155  GNUNET_asprintf (&op_name, "op-%u-src", op_counter);
157  sec_name,
158  op_name,
159  &o->src_id))
160  {
161  fprintf (stderr, "Missing src in operation %u `%s' in episode %u\n",
162  op_counter, op, cur->id);
163  GNUNET_free (op);
164  GNUNET_free (op_name);
165  GNUNET_free (o);
166  GNUNET_free (sec_name);
167  return GNUNET_SYSERR;
168  }
169  if (o->src_id > (e->num_masters - 1))
170  {
171  fprintf (stderr, "Invalid src %llu in operation %u `%s' in episode %u\n",
172  o->src_id, op_counter, op, cur->id);
173  GNUNET_free (op);
174  GNUNET_free (op_name);
175  GNUNET_free (o);
176  GNUNET_free (sec_name);
177  return GNUNET_SYSERR;
178  }
179  GNUNET_free (op_name);
180 
181  /* Get destination */
182  GNUNET_asprintf (&op_name, "op-%u-dest", op_counter);
184  sec_name,
185  op_name,
186  &o->dest_id))
187  {
188  fprintf (stderr, "Missing src in operation %u `%s' in episode %u\n",
189  op_counter, op, cur->id);
190  GNUNET_free (op);
191  GNUNET_free (op_name);
192  GNUNET_free (o);
193  GNUNET_free (sec_name);
194  return GNUNET_SYSERR;
195  }
196  if (o->dest_id > (e->num_slaves - 1))
197  {
198  fprintf (stderr,
199  "Invalid destination %llu in operation %u `%s' in episode %u\n",
200  o->dest_id, op_counter, op, cur->id);
201  GNUNET_free (op);
202  GNUNET_free (op_name);
203  GNUNET_free (o);
204  GNUNET_free (sec_name);
205  return GNUNET_SYSERR;
206  }
207  GNUNET_free (op_name);
208 
209  GNUNET_asprintf (&op_name, "op-%u-type", op_counter);
211  sec_name,
212  op_name,
213  &type)) &&
214  (STOP_SEND != o->type) &&
215  (STOP_PREFERENCE != o->type))
216  {
217  /* Load arguments for set_rate, start_send, set_preference */
218  if (0 == strcmp (type, "constant"))
219  {
221  }
222  else if (0 == strcmp (type, "linear"))
223  {
225  }
226  else if (0 == strcmp (type, "sinus"))
227  {
229  }
230  else if (0 == strcmp (type, "random"))
231  {
233  }
234  else
235  {
236  fprintf (stderr, "Invalid type %u `%s' in episode %u\n",
237  op_counter, op, cur->id);
238  GNUNET_free (type);
239  GNUNET_free (op);
240  GNUNET_free (op_name);
241  GNUNET_free (sec_name);
242  GNUNET_free (o);
243  return GNUNET_SYSERR;
244  }
245  GNUNET_free (op_name);
246 
247  /* Get base rate */
248  GNUNET_asprintf (&op_name, "op-%u-base-rate", op_counter);
250  sec_name,
251  op_name,
252  &o->base_rate))
253  {
254  fprintf (stderr,
255  "Missing base rate in operation %u `%s' in episode %u\n",
256  op_counter, op, cur->id);
257  GNUNET_free (type);
258  GNUNET_free (op);
259  GNUNET_free (op_name);
260  GNUNET_free (sec_name);
261  GNUNET_free (o);
262  return GNUNET_SYSERR;
263  }
264  GNUNET_free (op_name);
265 
266  /* Get max rate */
267  GNUNET_asprintf (&op_name, "op-%u-max-rate", op_counter);
269  sec_name,
270  op_name,
271  &o->max_rate))
272  {
273  if ((GNUNET_ATS_TEST_TG_LINEAR == o->gen_type) ||
276  {
277  fprintf (stderr,
278  "Missing max rate in operation %u `%s' in episode %u\n",
279  op_counter, op, cur->id);
280  GNUNET_free (type);
281  GNUNET_free (op_name);
282  GNUNET_free (op);
283  GNUNET_free (o);
284  GNUNET_free (sec_name);
285  return GNUNET_SYSERR;
286  }
287  }
288  GNUNET_free (op_name);
289 
290  /* Get period */
291  GNUNET_asprintf (&op_name, "op-%u-period", op_counter);
293  sec_name,
294  op_name,
295  &o->period))
296  {
297  o->period = cur->duration;
298  }
299  GNUNET_free (op_name);
300 
301  if (START_PREFERENCE == o->type)
302  {
303  /* Get frequency */
304  GNUNET_asprintf (&op_name, "op-%u-frequency", op_counter);
306  sec_name,
307  op_name,
308  &o->frequency))
309  {
310  fprintf (stderr,
311  "Missing frequency in operation %u `%s' in episode %u\n",
312  op_counter, op, cur->id);
313  GNUNET_free (type);
314  GNUNET_free (op_name);
315  GNUNET_free (op);
316  GNUNET_free (o);
317  GNUNET_free (sec_name);
318  return GNUNET_SYSERR;
319  }
320  GNUNET_free (op_name);
321 
322  /* Get preference */
323  GNUNET_asprintf (&op_name, "op-%u-pref", op_counter);
325  sec_name,
326  op_name,
327  &pref))
328  {
329  fprintf (stderr,
330  "Missing preference in operation %u `%s' in episode %u\n",
331  op_counter, op, cur->id);
332  GNUNET_free (type);
333  GNUNET_free (op_name);
334  GNUNET_free (op);
335  GNUNET_free_non_null (pref);
336  GNUNET_free (o);
337  GNUNET_free (sec_name);
338  return GNUNET_SYSERR;
339  }
340 
341  if (0 == strcmp (pref, "bandwidth"))
343  else if (0 == strcmp (pref, "latency"))
345  else
346  {
347  fprintf (stderr,
348  "Invalid preference in operation %u `%s' in episode %u\n",
349  op_counter, op, cur->id);
350  GNUNET_free (type);
351  GNUNET_free (op_name);
352  GNUNET_free (op);
353  GNUNET_free_non_null (pref);
354  GNUNET_free (o);
355  GNUNET_free (sec_name);
356  return GNUNET_SYSERR;
357  }
358  GNUNET_free (pref);
359  GNUNET_free (op_name);
360  }
361  }
362 
363  /* Safety checks */
364  if ((GNUNET_ATS_TEST_TG_LINEAR == o->gen_type) ||
366  {
367  if ((o->max_rate - o->base_rate) > o->base_rate)
368  {
369  /* This will cause an underflow */
370  GNUNET_break (0);
371  }
372  fprintf (stderr,
373  "Selected max rate and base rate cannot be used for desired traffic form!\n");
374  }
375 
376  if ((START_SEND == o->type) || (START_PREFERENCE == o->type))
377  fprintf (stderr,
378  "Found operation %u in episode %u: %s [%llu]->[%llu] == %s, %llu -> %llu in %s\n",
379  op_counter, cur->id, print_op (o->type), o->src_id,
380  o->dest_id, (NULL != type) ? type : "",
381  o->base_rate, o->max_rate,
383  else
384  fprintf (stderr, "Found operation %u in episode %u: %s [%llu]->[%llu]\n",
385  op_counter, cur->id, print_op (o->type), o->src_id, o->dest_id);
386 
387  GNUNET_free_non_null (type);
388  GNUNET_free (op);
389 
390  GNUNET_CONTAINER_DLL_insert (cur->head, cur->tail, o);
391  op_counter++;
392  }
393  GNUNET_free (sec_name);
394 
395  return GNUNET_OK;
396 }
397 
398 
399 static int
401 {
402  int e_counter = 0;
403  char *sec_name;
404  struct GNUNET_TIME_Relative e_duration;
405  struct Episode *cur;
406  struct Episode *last;
407 
408  e_counter = 0;
409  last = NULL;
410  while (1)
411  {
412  GNUNET_asprintf (&sec_name, "episode-%u", e_counter);
414  sec_name,
415  "duration",
416  &e_duration))
417  {
418  GNUNET_free (sec_name);
419  break;
420  }
421 
422  cur = GNUNET_new (struct Episode);
423  cur->duration = e_duration;
424  cur->id = e_counter;
425 
426  if (GNUNET_OK != load_episode (e, cur, cfg))
427  {
428  GNUNET_free (sec_name);
429  GNUNET_free (cur);
430  return GNUNET_SYSERR;
431  }
432 
433  fprintf (stderr, "Found episode %u with duration %s \n",
434  e_counter,
436  GNUNET_YES));
437 
438  /* Update experiment */
439  e->num_episodes++;
441  cur->duration);
442  /* Put in linked list */
443  if (NULL == last)
444  e->start = cur;
445  else
446  last->next = cur;
447 
448  GNUNET_free (sec_name);
449  e_counter++;
450  last = cur;
451  }
452  return e_counter;
453 }
454 
455 
456 static void
458 {
459  struct Experiment *e = cls;
460 
461  e->experiment_timeout_task = NULL;
462  fprintf (stderr, "Experiment timeout!\n");
463 
464  if (NULL != e->episode_timeout_task)
465  {
467  e->episode_timeout_task = NULL;
468  }
469 
471  GNUNET_SYSERR);
472 }
473 
474 
475 static void
477 {
478  struct BenchmarkPeer *peer;
479  struct BenchmarkPartner *partner;
480 
481  peer = GNUNET_ATS_TEST_get_peer (op->src_id);
482  if (NULL == peer)
483  {
484  GNUNET_break (0);
485  return;
486  }
487 
488  partner = GNUNET_ATS_TEST_get_partner (op->src_id, op->dest_id);
489  if (NULL == partner)
490  {
491  GNUNET_break (0);
492  return;
493  }
494 
495  fprintf (stderr, "Found master %llu slave %llu\n", op->src_id, op->dest_id);
496 
497  if (NULL != partner->tg)
498  {
499  fprintf (stderr, "Stopping traffic between master %llu slave %llu\n",
500  op->src_id, op->dest_id);
502  partner->tg = NULL;
503  }
504 
505  partner->tg = GNUNET_ATS_TEST_generate_traffic_start (peer, partner,
506  op->gen_type,
507  op->base_rate,
508  op->max_rate,
509  op->period,
511 }
512 
513 
514 static void
516 {
517  struct BenchmarkPartner *p;
518 
520  if (NULL == p)
521  {
522  GNUNET_break (0);
523  return;
524  }
525 
526  fprintf (stderr, "Found master %llu slave %llu\n", op->src_id, op->dest_id);
527 
528  if (NULL != p->tg)
529  {
530  fprintf (stderr, "Stopping traffic between master %llu slave %llu\n",
531  op->src_id, op->dest_id);
533  p->tg = NULL;
534  }
535 }
536 
537 
538 static void
540 {
541  struct BenchmarkPeer *peer;
542  struct BenchmarkPartner *partner;
543 
544  peer = GNUNET_ATS_TEST_get_peer (op->src_id);
545  if (NULL == peer)
546  {
547  GNUNET_break (0);
548  return;
549  }
550 
551  partner = GNUNET_ATS_TEST_get_partner (op->src_id, op->dest_id);
552  if (NULL == partner)
553  {
554  GNUNET_break (0);
555  return;
556  }
557 
558  fprintf (stderr, "Found master %llu slave %llu\n", op->src_id, op->dest_id);
559 
560  if (NULL != partner->pg)
561  {
562  fprintf (stderr, "Stopping traffic between master %llu slave %llu\n",
563  op->src_id, op->dest_id);
565  partner->pg = NULL;
566  }
567 
568  partner->pg = GNUNET_ATS_TEST_generate_preferences_start (peer, partner,
569  op->gen_type,
570  op->base_rate,
571  op->max_rate,
572  op->period,
573  op->frequency,
574  op->pref_type);
575 }
576 
577 
578 static void
580 {
581  struct BenchmarkPartner *p;
582 
584  if (NULL == p)
585  {
586  GNUNET_break (0);
587  return;
588  }
589 
590  fprintf (stderr, "Found master %llu slave %llu\n", op->src_id, op->dest_id);
591 
592  if (NULL != p->pg)
593  {
594  fprintf (stderr, "Stopping preference between master %llu slave %llu\n",
595  op->src_id, op->dest_id);
597  p->pg = NULL;
598  }
599 }
600 
601 
602 static void
604 {
605  struct GNUNET_ATS_TEST_Operation *cur;
606 
607  for (cur = ep->head; NULL != cur; cur = cur->next)
608  {
609  fprintf (stderr, "Enforcing operation: %s [%llu]->[%llu] == %llu\n",
610  print_op (cur->type), cur->src_id, cur->dest_id, cur->base_rate);
611  switch (cur->type)
612  {
613  case START_SEND:
614  enforce_start_send (cur);
615  break;
616 
617  case STOP_SEND:
618  enforce_stop_send (cur);
619  break;
620 
621  case START_PREFERENCE:
623  break;
624 
625  case STOP_PREFERENCE:
627  break;
628 
629  default:
630  break;
631  }
632  }
633 }
634 
635 
636 static void
637 timeout_episode (void *cls)
638 {
639  struct Experiment *e = cls;
640 
641  e->episode_timeout_task = NULL;
642  if (NULL != e->ep_done_cb)
643  e->ep_done_cb (e->cur);
644 
645  /* Scheduling next */
646  e->cur = e->cur->next;
647  if (NULL == e->cur)
648  {
649  /* done */
650  fprintf (stderr, "Last episode done!\n");
651  if (NULL != e->experiment_timeout_task)
652  {
654  e->experiment_timeout_task = NULL;
655  }
657  GNUNET_OK);
658  return;
659  }
660 
661  fprintf (stderr, "Running episode %u with timeout %s\n",
662  e->cur->id,
664  GNUNET_YES));
665  enforce_episode (e->cur);
666 
668  &timeout_episode, e);
669 }
670 
671 
672 void
675  ep_done_cb,
677  e_done_cb)
678 {
679  fprintf (stderr, "Running experiment `%s' with timeout %s\n", e->name,
681  GNUNET_YES));
682  e->e_done_cb = e_done_cb;
683  e->ep_done_cb = ep_done_cb;
685 
686  /* Start total time out */
689  e);
690 
691  /* Start */
692  e->cur = e->start;
693  fprintf (stderr, "Running episode %u with timeout %s\n",
694  e->cur->id,
696  GNUNET_YES));
697  enforce_episode (e->cur);
699  &timeout_episode, e);
700 }
701 
702 
703 struct Experiment *
705 {
706  struct Experiment *e;
708 
709  e = NULL;
710 
712  if (GNUNET_SYSERR == GNUNET_CONFIGURATION_load (cfg, filename))
713  {
714  fprintf (stderr, "Failed to load `%s'\n", filename);
716  return NULL;
717  }
718 
719  e = create_experiment ();
720 
721  if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string (cfg, "experiment",
722  "name", &e->name))
723  {
724  fprintf (stderr, "Invalid %s", "name");
725  free_experiment (e);
726  return NULL;
727  }
728  else
729  fprintf (stderr, "Experiment name: `%s'\n", e->name);
730 
732  "experiment",
733  "cfg_file",
734  &e->cfg_file))
735  {
736  fprintf (stderr, "Invalid %s", "cfg_file");
737  free_experiment (e);
738  return NULL;
739  }
740  else
741  fprintf (stderr, "Experiment name: `%s'\n", e->cfg_file);
742 
743  if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (cfg, "experiment",
744  "masters",
745  &e->num_masters))
746  {
747  fprintf (stderr, "Invalid %s", "masters");
748  free_experiment (e);
749  return NULL;
750  }
751  else
752  fprintf (stderr, "Experiment masters: `%llu'\n",
753  e->num_masters);
754 
755  if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (cfg, "experiment",
756  "slaves",
757  &e->num_slaves))
758  {
759  fprintf (stderr, "Invalid %s", "slaves");
760  free_experiment (e);
761  return NULL;
762  }
763  else
764  fprintf (stderr, "Experiment slaves: `%llu'\n",
765  e->num_slaves);
766 
767  if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_time (cfg, "experiment",
768  "log_freq",
769  &e->log_freq))
770  {
771  fprintf (stderr, "Invalid %s", "log_freq");
772  free_experiment (e);
773  return NULL;
774  }
775  else
776  fprintf (stderr, "Experiment logging frequency: `%s'\n",
778 
779  if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_time (cfg, "experiment",
780  "max_duration",
781  &e->max_duration))
782  {
783  fprintf (stderr, "Invalid %s", "max_duration");
784  free_experiment (e);
785  return NULL;
786  }
787  else
788  fprintf (stderr, "Experiment duration: `%s'\n",
790  GNUNET_YES));
791 
792  load_episodes (e, cfg);
793  fprintf (stderr, "Loaded %u episodes with total duration %s\n",
794  e->num_episodes,
796  GNUNET_YES));
797 
799  return e;
800 }
801 
802 
803 void
805 {
806  if (NULL != e->experiment_timeout_task)
807  {
809  e->experiment_timeout_task = NULL;
810  }
811  if (NULL != e->episode_timeout_task)
812  {
814  e->episode_timeout_task = NULL;
815  }
816  free_experiment (e);
817 }
818 
819 
820 /* end of file ats-testing-experiment.c*/
static struct Experiment * create_experiment()
struct GNUNET_ATS_TEST_Operation * next
struct Episode * start
void GNUNET_ATS_TEST_experimentation_run(struct Experiment *e, GNUNET_ATS_TESTING_EpisodeDoneCallback ep_done_cb, GNUNET_ATS_TESTING_ExperimentDoneCallback e_done_cb)
Execute the specified experiment.
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.
GNUNET_ATS_TESTING_EpisodeDoneCallback ep_done_cb
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.
static const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we are using.
Definition: gnunet-abd.c:36
struct Episode * next
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
struct Experiment * GNUNET_ATS_TEST_experimentation_load(const char *filename)
Load an experiment from a file.
unsigned long long int num_masters
Definition: ats-testing.h:525
struct GNUNET_TIME_Relative total_duration
static void timeout_experiment(void *cls)
struct PreferenceGenerator * pg
Handle for preference generator.
Definition: ats-testing.h:300
long long unsigned int src_id
Definition: ats-testing.h:497
static void enforce_stop_send(struct GNUNET_ATS_TEST_Operation *op)
static struct Experiment * e
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
#define GNUNET_free_non_null(ptr)
Free the memory pointed to by ptr if ptr is not NULL.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
unsigned int num_episodes
struct GNUNET_TIME_Relative period
struct GNUNET_CONFIGURATION_Handle * GNUNET_CONFIGURATION_create(void)
Create a new configuration object.
static int load_episodes(struct Experiment *e, struct GNUNET_CONFIGURATION_Handle *cfg)
const char * print_op(enum OperationType op)
struct TrafficGenerator * GNUNET_ATS_TEST_generate_traffic_start(struct BenchmarkPeer *src, struct BenchmarkPartner *dest, enum GeneratorType type, unsigned int base_rate, unsigned int max_rate, struct GNUNET_TIME_Relative period, struct GNUNET_TIME_Relative duration)
Generate between the source master and the partner and send traffic with a maximum rate...
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
static int load_episode(struct Experiment *e, struct Episode *cur, struct GNUNET_CONFIGURATION_Handle *cfg)
static void free_experiment(struct Experiment *e)
int GNUNET_CONFIGURATION_load(struct GNUNET_CONFIGURATION_Handle *cfg, const char *filename)
Load configuration.
struct GNUNET_SCHEDULER_Task * experiment_timeout_task
struct TrafficGenerator * tg
Handle for traffic generator.
Definition: ats-testing.h:295
struct GNUNET_TIME_Relative log_freq
int GNUNET_asprintf(char **buf, const char *format,...)
Like asprintf, just portable.
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:1253
static struct GNUNET_OS_Process * p
Helper process we started.
Definition: gnunet-qr.c:59
void(* GNUNET_ATS_TESTING_ExperimentDoneCallback)(struct Experiment *e, struct GNUNET_TIME_Relative duration, int success)
Information we track for a peer in the testbed.
Definition: ats-testing.h:111
struct Episode * cur
long long unsigned int dest_id
Definition: ats-testing.h:498
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:687
long long unsigned int base_rate
void GNUNET_CONFIGURATION_destroy(struct GNUNET_CONFIGURATION_Handle *cfg)
Destroy configuration object.
unsigned long long int num_slaves
Definition: ats-testing.h:526
static char * filename
Information about a benchmarking partner.
Definition: ats-testing.h:275
enum GNUNET_ATS_PreferenceKind pref_type
struct PreferenceGenerator * GNUNET_ATS_TEST_generate_preferences_start(struct BenchmarkPeer *src, struct BenchmarkPartner *dest, enum GeneratorType type, unsigned int base_value, unsigned int value_rate, struct GNUNET_TIME_Relative period, struct GNUNET_TIME_Relative frequency, enum GNUNET_ATS_PreferenceKind kind)
Generate between the source master and the partner and set preferences with a value depending on the ...
void(* GNUNET_ATS_TESTING_EpisodeDoneCallback)(struct Episode *e)
#define GNUNET_TIME_UNIT_FOREVER_REL
Constant used to specify "forever".
ats testing library: setup topology and provide logging to test ats
struct GNUNET_SCHEDULER_Task * episode_timeout_task
static void enforce_start_preference(struct GNUNET_ATS_TEST_Operation *op)
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
Definition: time.c:118
struct GNUNET_TIME_Relative duration
struct GNUNET_TIME_Absolute start_time
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.
An operation in an experiment.
void GNUNET_ATS_TEST_generate_preferences_stop(struct PreferenceGenerator *pg)
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
Change the peer&#39;s latency value to the given amount.
#define GNUNET_TIME_UNIT_ZERO
Relative time zero.
struct GNUNET_ATS_TEST_Operation * head
void GNUNET_ATS_TEST_experimentation_stop(struct Experiment *e)
Stop an experiment.
struct BenchmarkPartner * GNUNET_ATS_TEST_get_partner(int src, int dest)
Definition: ats-testing.c:903
struct GNUNET_ATS_TEST_Operation * tail
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:579
static void enforce_episode(struct Episode *ep)
static void enforce_stop_preference(struct GNUNET_ATS_TEST_Operation *op)
configuration data
Definition: configuration.c:85
struct BenchmarkPeer * GNUNET_ATS_TEST_get_peer(int src)
Topology related functions.
Definition: ats-testing.c:894
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:375
static void timeout_episode(void *cls)
Change the peer&#39;s bandwidth value (value per byte of bandwidth in the goal function) to the given amo...
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.
void GNUNET_ATS_TEST_generate_traffic_stop(struct TrafficGenerator *tg)
struct GNUNET_TIME_Relative frequency
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
#define GNUNET_YES
Definition: gnunet_common.h:77
static struct GNUNET_ARM_Operation * op
Current operation.
Definition: gnunet-arm.c:144
long long unsigned int max_rate
static void enforce_start_send(struct GNUNET_ATS_TEST_Operation *op)
struct GNUNET_TIME_Relative max_duration
#define GNUNET_free(ptr)
Wrapper around free.
Time for relative time used by GNUnet, in microseconds.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:966