GNUnet  0.10.x
Functions
ats-testing-experiment.c File Reference

ats benchmark: controlled experiment execution More...

#include "platform.h"
#include "gnunet_util_lib.h"
#include "ats-testing.h"
Include dependency graph for ats-testing-experiment.c:

Go to the source code of this file.

Functions

const char * print_op (enum OperationType op)
 
static struct Experimentcreate_experiment ()
 
static void free_experiment (struct Experiment *e)
 
static int load_episode (struct Experiment *e, struct Episode *cur, struct GNUNET_CONFIGURATION_Handle *cfg)
 
static int load_episodes (struct Experiment *e, struct GNUNET_CONFIGURATION_Handle *cfg)
 
static void timeout_experiment (void *cls)
 
static void enforce_start_send (struct GNUNET_ATS_TEST_Operation *op)
 
static void enforce_stop_send (struct GNUNET_ATS_TEST_Operation *op)
 
static void enforce_start_preference (struct GNUNET_ATS_TEST_Operation *op)
 
static void enforce_stop_preference (struct GNUNET_ATS_TEST_Operation *op)
 
static void enforce_episode (struct Episode *ep)
 
static void timeout_episode (void *cls)
 
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. More...
 
struct ExperimentGNUNET_ATS_TEST_experimentation_load (const char *filename)
 Load an experiment from a file. More...
 
void GNUNET_ATS_TEST_experimentation_stop (struct Experiment *e)
 Stop an experiment. More...
 

Detailed Description

ats benchmark: controlled experiment execution

Author
Christian Grothoff
Matthias Wachs

Definition in file ats-testing-experiment.c.

Function Documentation

◆ print_op()

const char* print_op ( enum OperationType  op)

Definition at line 31 of file ats-testing-experiment.c.

References START_PREFERENCE, START_SEND, STOP_PREFERENCE, and STOP_SEND.

Referenced by enforce_episode(), and load_episode().

32 {
33  switch (op) {
34  case START_SEND:
35  return "START_SEND";
36  case STOP_SEND:
37  return "STOP_SEND";
38  case START_PREFERENCE:
39  return "START_PREFERENCE";
40  case STOP_PREFERENCE:
41  return "STOP_PREFERENCE";
42  default:
43  break;
44  }
45  return "";
46 }
static struct GNUNET_ARM_Operation * op
Current operation.
Definition: gnunet-arm.c:139
Here is the caller graph for this function:

◆ create_experiment()

static struct Experiment* create_experiment ( )
static

Definition at line 50 of file ats-testing-experiment.c.

References e, GNUNET_new, GNUNET_TIME_UNIT_ZERO, Experiment::name, Experiment::num_masters, Experiment::num_slaves, Experiment::start, and Experiment::total_duration.

Referenced by GNUNET_ATS_TEST_experimentation_load().

51 {
52  struct Experiment *e;
53  e = GNUNET_new (struct Experiment);
54  e->name = NULL;
55  e->num_masters = 0;
56  e->num_slaves = 0;
57  e->start = NULL;
59  return e;
60 }
struct Episode * start
unsigned long long int num_masters
Definition: ats-testing.h:525
struct GNUNET_TIME_Relative total_duration
static struct Experiment * e
#define GNUNET_new(type)
Allocate a struct or union of the given type.
unsigned long long int num_slaves
Definition: ats-testing.h:526
#define GNUNET_TIME_UNIT_ZERO
Relative time zero.
Here is the caller graph for this function:

◆ free_experiment()

static void free_experiment ( struct Experiment e)
static

Definition at line 63 of file ats-testing-experiment.c.

References Experiment::cfg_file, GNUNET_free, GNUNET_free_non_null, Episode::head, Experiment::name, GNUNET_ATS_TEST_Operation::next, Episode::next, and Experiment::start.

Referenced by GNUNET_ATS_TEST_experimentation_load(), and GNUNET_ATS_TEST_experimentation_stop().

64 {
65  struct Episode *cur;
66  struct Episode *next;
67  struct GNUNET_ATS_TEST_Operation *cur_o;
68  struct GNUNET_ATS_TEST_Operation *next_o;
69 
70  next = e->start;
71  for (cur = next; NULL != cur; cur = next)
72  {
73  next = cur->next;
74 
75  next_o = cur->head;
76  for (cur_o = next_o; NULL != cur_o; cur_o = next_o)
77  {
78  next_o = cur_o->next;
79  GNUNET_free (cur_o);
80  }
81  GNUNET_free (cur);
82  }
83 
86  GNUNET_free (e);
87 }
struct GNUNET_ATS_TEST_Operation * next
struct Episode * start
struct Episode * next
#define GNUNET_free_non_null(ptr)
Free the memory pointed to by ptr if ptr is not NULL.
An operation in an experiment.
struct GNUNET_ATS_TEST_Operation * head
#define GNUNET_free(ptr)
Wrapper around free.
Here is the caller graph for this function:

◆ load_episode()

static int load_episode ( struct Experiment e,
struct Episode cur,
struct GNUNET_CONFIGURATION_Handle cfg 
)
static

Definition at line 91 of file ats-testing-experiment.c.

References GNUNET_ATS_TEST_Operation::base_rate, GNUNET_ATS_TEST_Operation::dest_id, Episode::duration, GNUNET_ATS_TEST_Operation::frequency, GNUNET_ATS_TEST_Operation::gen_type, GNUNET_asprintf(), GNUNET_ATS_PREFERENCE_BANDWIDTH, GNUNET_ATS_PREFERENCE_LATENCY, GNUNET_ATS_TEST_TG_CONSTANT, GNUNET_ATS_TEST_TG_LINEAR, GNUNET_ATS_TEST_TG_RANDOM, GNUNET_ATS_TEST_TG_SINUS, GNUNET_break, GNUNET_CONFIGURATION_get_value_number(), GNUNET_CONFIGURATION_get_value_string(), GNUNET_CONFIGURATION_get_value_time(), GNUNET_CONTAINER_DLL_insert, GNUNET_free, GNUNET_free_non_null, GNUNET_new, GNUNET_OK, GNUNET_STRINGS_relative_time_to_string(), GNUNET_SYSERR, GNUNET_YES, Episode::head, Episode::id, GNUNET_ATS_TEST_Operation::max_rate, Experiment::num_masters, Experiment::num_slaves, op, GNUNET_ATS_TEST_Operation::period, GNUNET_ATS_TEST_Operation::pref_type, print_op(), GNUNET_ATS_TEST_Operation::src_id, START_PREFERENCE, START_SEND, STOP_PREFERENCE, STOP_SEND, Episode::tail, type, and GNUNET_ATS_TEST_Operation::type.

Referenced by load_episodes().

94 {
95  struct GNUNET_ATS_TEST_Operation *o;
96  char *sec_name;
97  char *op_name;
98  char *op;
99  char *type;
100  char *pref;
101  int op_counter = 0;
102 
103  fprintf (stderr, "Parsing episode %u\n",cur->id);
104  GNUNET_asprintf (&sec_name, "episode-%u", cur->id);
105 
106  while (1)
107  {
108  /* Load operation */
109  GNUNET_asprintf (&op_name, "op-%u-operation", op_counter);
111  sec_name, op_name, &op))
112  {
113  GNUNET_free (op_name);
114  break;
115  }
117  /* operations = set_rate, start_send, stop_send, set_preference */
118  if (0 == strcmp (op, "start_send"))
119  {
120  o->type = START_SEND;
121  }
122  else if (0 == strcmp (op, "stop_send"))
123  {
124  o->type = STOP_SEND;
125  }
126  else if (0 == strcmp (op, "start_preference"))
127  {
128  o->type = START_PREFERENCE;
129  }
130  else if (0 == strcmp (op, "stop_preference"))
131  {
132  o->type = STOP_PREFERENCE;
133  }
134  else
135  {
136  fprintf (stderr, "Invalid operation %u `%s' in episode %u\n",
137  op_counter, op, cur->id);
138  GNUNET_free (op);
139  GNUNET_free (op_name);
140  GNUNET_free (o);
141  GNUNET_free (sec_name);
142  return GNUNET_SYSERR;
143  }
144  GNUNET_free (op_name);
145 
146  /* Get source */
147  GNUNET_asprintf(&op_name, "op-%u-src", op_counter);
149  sec_name, op_name, &o->src_id))
150  {
151  fprintf (stderr, "Missing src in operation %u `%s' in episode %u\n",
152  op_counter, op, cur->id);
153  GNUNET_free (op);
154  GNUNET_free (op_name);
155  GNUNET_free (o);
156  GNUNET_free (sec_name);
157  return GNUNET_SYSERR;
158  }
159  if (o->src_id > (e->num_masters - 1))
160  {
161  fprintf (stderr, "Invalid src %llu in operation %u `%s' in episode %u\n",
162  o->src_id, 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  GNUNET_free (op_name);
170 
171  /* Get destination */
172  GNUNET_asprintf(&op_name, "op-%u-dest", op_counter);
174  sec_name, op_name, &o->dest_id))
175  {
176  fprintf (stderr, "Missing src in operation %u `%s' in episode %u\n",
177  op_counter, op, cur->id);
178  GNUNET_free (op);
179  GNUNET_free (op_name);
180  GNUNET_free (o);
181  GNUNET_free (sec_name);
182  return GNUNET_SYSERR;
183  }
184  if (o->dest_id > (e->num_slaves - 1))
185  {
186  fprintf (stderr, "Invalid destination %llu in operation %u `%s' in episode %u\n",
187  o->dest_id, op_counter, op, cur->id);
188  GNUNET_free (op);
189  GNUNET_free (op_name);
190  GNUNET_free (o);
191  GNUNET_free (sec_name);
192  return GNUNET_SYSERR;
193  }
194  GNUNET_free (op_name);
195 
196  GNUNET_asprintf(&op_name, "op-%u-type", op_counter);
198  sec_name, op_name, &type)) &&
199  (STOP_SEND != o->type) &&
200  (STOP_PREFERENCE != o->type) )
201  {
202  /* Load arguments for set_rate, start_send, set_preference */
203  if (0 == strcmp (type, "constant"))
204  {
206  }
207  else if (0 == strcmp (type, "linear"))
208  {
210  }
211  else if (0 == strcmp (type, "sinus"))
212  {
214  }
215  else if (0 == strcmp (type, "random"))
216  {
218  }
219  else
220  {
221  fprintf (stderr, "Invalid type %u `%s' in episode %u\n",
222  op_counter, op, cur->id);
223  GNUNET_free (type);
224  GNUNET_free (op);
225  GNUNET_free (op_name);
226  GNUNET_free (sec_name);
227  GNUNET_free (o);
228  return GNUNET_SYSERR;
229  }
230  GNUNET_free (op_name);
231 
232  /* Get base rate */
233  GNUNET_asprintf(&op_name, "op-%u-base-rate", op_counter);
235  sec_name, op_name, &o->base_rate))
236  {
237  fprintf (stderr, "Missing base rate in operation %u `%s' in episode %u\n",
238  op_counter, op, cur->id);
239  GNUNET_free (type);
240  GNUNET_free (op);
241  GNUNET_free (op_name);
242  GNUNET_free (sec_name);
243  GNUNET_free (o);
244  return GNUNET_SYSERR;
245  }
246  GNUNET_free (op_name);
247 
248  /* Get max rate */
249  GNUNET_asprintf(&op_name, "op-%u-max-rate", op_counter);
251  sec_name, op_name, &o->max_rate))
252  {
253  if ((GNUNET_ATS_TEST_TG_LINEAR == o->gen_type) ||
256  {
257  fprintf (stderr, "Missing max rate in operation %u `%s' in episode %u\n",
258  op_counter, op, cur->id);
259  GNUNET_free (type);
260  GNUNET_free (op_name);
261  GNUNET_free (op);
262  GNUNET_free (o);
263  GNUNET_free (sec_name);
264  return GNUNET_SYSERR;
265  }
266  }
267  GNUNET_free (op_name);
268 
269  /* Get period */
270  GNUNET_asprintf(&op_name, "op-%u-period", op_counter);
272  sec_name, op_name, &o->period))
273  {
274  o->period = cur->duration;
275  }
276  GNUNET_free (op_name);
277 
278  if (START_PREFERENCE == o->type)
279  {
280  /* Get frequency */
281  GNUNET_asprintf(&op_name, "op-%u-frequency", op_counter);
283  sec_name, op_name, &o->frequency))
284  {
285  fprintf (stderr, "Missing frequency in operation %u `%s' in episode %u\n",
286  op_counter, op, cur->id);
287  GNUNET_free (type);
288  GNUNET_free (op_name);
289  GNUNET_free (op);
290  GNUNET_free (o);
291  GNUNET_free (sec_name);
292  return GNUNET_SYSERR;
293  }
294  GNUNET_free (op_name);
295 
296  /* Get preference */
297  GNUNET_asprintf(&op_name, "op-%u-pref", op_counter);
299  sec_name, op_name, &pref))
300  {
301  fprintf (stderr, "Missing preference in operation %u `%s' in episode %u\n",
302  op_counter, op, cur->id);
303  GNUNET_free (type);
304  GNUNET_free (op_name);
305  GNUNET_free (op);
306  GNUNET_free_non_null (pref);
307  GNUNET_free (o);
308  GNUNET_free (sec_name);
309  return GNUNET_SYSERR;
310  }
311 
312  if (0 == strcmp(pref, "bandwidth"))
314  else if (0 == strcmp(pref, "latency"))
316  else
317  {
318  fprintf (stderr, "Invalid preference in operation %u `%s' in episode %u\n",
319  op_counter, op, cur->id);
320  GNUNET_free (type);
321  GNUNET_free (op_name);
322  GNUNET_free (op);
323  GNUNET_free_non_null (pref);
324  GNUNET_free (o);
325  GNUNET_free (sec_name);
326  return GNUNET_SYSERR;
327  }
328  GNUNET_free (pref);
329  GNUNET_free (op_name);
330  }
331  }
332 
333  /* Safety checks */
334  if ((GNUNET_ATS_TEST_TG_LINEAR == o->gen_type) ||
336  {
337  if ((o->max_rate - o->base_rate) > o->base_rate)
338  {
339  /* This will cause an underflow */
340  GNUNET_break (0);
341  }
342  fprintf (stderr, "Selected max rate and base rate cannot be used for desired traffic form!\n");
343  }
344 
345  if ((START_SEND == o->type) || (START_PREFERENCE == o->type))
346  fprintf (stderr, "Found operation %u in episode %u: %s [%llu]->[%llu] == %s, %llu -> %llu in %s\n",
347  op_counter, cur->id, print_op (o->type), o->src_id,
348  o->dest_id, (NULL != type) ? type : "",
349  o->base_rate, o->max_rate,
351  else
352  fprintf (stderr, "Found operation %u in episode %u: %s [%llu]->[%llu]\n",
353  op_counter, cur->id, print_op (o->type), o->src_id, o->dest_id);
354 
355  GNUNET_free_non_null (type);
356  GNUNET_free (op);
357 
358  GNUNET_CONTAINER_DLL_insert (cur->head,cur->tail, o);
359  op_counter++;
360  }
361  GNUNET_free (sec_name);
362 
363  return GNUNET_OK;
364 }
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.
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.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
unsigned long long int num_masters
Definition: ats-testing.h:525
long long unsigned int src_id
Definition: ats-testing.h:497
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
#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.
struct GNUNET_TIME_Relative period
const char * print_op(enum OperationType op)
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
int GNUNET_asprintf(char **buf, const char *format,...)
Like asprintf, just portable.
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:727
long long unsigned int base_rate
unsigned long long int num_slaves
Definition: ats-testing.h:526
enum GNUNET_ATS_PreferenceKind pref_type
struct GNUNET_TIME_Relative duration
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.
#define GNUNET_SYSERR
Definition: gnunet_common.h:79
Change the peer's latency value to the given amount.
struct GNUNET_ATS_TEST_Operation * head
struct GNUNET_ATS_TEST_Operation * tail
Change the peer's bandwidth value (value per byte of bandwidth in the goal function) to the given amo...
struct GNUNET_TIME_Relative frequency
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
#define GNUNET_YES
Definition: gnunet_common.h:80
static struct GNUNET_ARM_Operation * op
Current operation.
Definition: gnunet-arm.c:139
long long unsigned int max_rate
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ load_episodes()

static int load_episodes ( struct Experiment e,
struct GNUNET_CONFIGURATION_Handle cfg 
)
static

Definition at line 368 of file ats-testing-experiment.c.

References Episode::duration, GNUNET_asprintf(), GNUNET_CONFIGURATION_get_value_time(), GNUNET_free, GNUNET_new, GNUNET_OK, GNUNET_STRINGS_relative_time_to_string(), GNUNET_SYSERR, GNUNET_TIME_relative_add(), GNUNET_YES, Episode::id, load_episode(), Episode::next, Experiment::num_episodes, Experiment::start, and Experiment::total_duration.

Referenced by GNUNET_ATS_TEST_experimentation_load().

369 {
370  int e_counter = 0;
371  char *sec_name;
372  struct GNUNET_TIME_Relative e_duration;
373  struct Episode *cur;
374  struct Episode *last;
375 
376  e_counter = 0;
377  last = NULL;
378  while (1)
379  {
380  GNUNET_asprintf(&sec_name, "episode-%u", e_counter);
382  sec_name, "duration", &e_duration))
383  {
384  GNUNET_free (sec_name);
385  break;
386  }
387 
388  cur = GNUNET_new (struct Episode);
389  cur->duration = e_duration;
390  cur->id = e_counter;
391 
392  if (GNUNET_OK != load_episode (e, cur, cfg))
393  {
394  GNUNET_free (sec_name);
395  GNUNET_free (cur);
396  return GNUNET_SYSERR;
397  }
398 
399  fprintf (stderr, "Found episode %u with duration %s \n",
400  e_counter,
402 
403  /* Update experiment */
404  e->num_episodes ++;
406  /* Put in linked list */
407  if (NULL == last)
408  e->start = cur;
409  else
410  last->next = cur;
411 
412  GNUNET_free (sec_name);
413  e_counter ++;
414  last = cur;
415  }
416  return e_counter;
417 }
struct Episode * 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.
struct Episode * next
struct GNUNET_TIME_Relative total_duration
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
#define GNUNET_new(type)
Allocate a struct or union of the given type.
unsigned int num_episodes
static int load_episode(struct Experiment *e, struct Episode *cur, struct GNUNET_CONFIGURATION_Handle *cfg)
int GNUNET_asprintf(char **buf, const char *format,...)
Like asprintf, just portable.
const char * GNUNET_STRINGS_relative_time_to_string(struct GNUNET_TIME_Relative delta, int do_round)
Give relative time in human-readable fancy format.
Definition: strings.c:727
struct GNUNET_TIME_Relative duration
#define GNUNET_SYSERR
Definition: gnunet_common.h:79
struct GNUNET_TIME_Relative GNUNET_TIME_relative_add(struct GNUNET_TIME_Relative a1, struct GNUNET_TIME_Relative a2)
Add relative times together.
Definition: time.c:576
#define GNUNET_YES
Definition: gnunet_common.h:80
#define GNUNET_free(ptr)
Wrapper around free.
Time for relative time used by GNUnet, in microseconds.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ timeout_experiment()

static void timeout_experiment ( void *  cls)
static

Definition at line 421 of file ats-testing-experiment.c.

References e, Experiment::e_done_cb, Experiment::episode_timeout_task, Experiment::experiment_timeout_task, GNUNET_SCHEDULER_cancel(), GNUNET_SYSERR, GNUNET_TIME_absolute_get_duration(), and Experiment::start_time.

Referenced by GNUNET_ATS_TEST_experimentation_run().

422 {
423  struct Experiment *e = cls;
424  e->experiment_timeout_task = NULL;
425  fprintf (stderr, "Experiment timeout!\n");
426 
427  if (NULL != e->episode_timeout_task)
428  {
430  e->episode_timeout_task = NULL;
431  }
432 
434  GNUNET_SYSERR);
435 }
GNUNET_ATS_TESTING_ExperimentDoneCallback e_done_cb
static struct Experiment * e
struct GNUNET_SCHEDULER_Task * experiment_timeout_task
struct GNUNET_SCHEDULER_Task * episode_timeout_task
struct GNUNET_TIME_Absolute start_time
#define GNUNET_SYSERR
Definition: gnunet_common.h:79
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 * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:965
Here is the call graph for this function:
Here is the caller graph for this function:

◆ enforce_start_send()

static void enforce_start_send ( struct GNUNET_ATS_TEST_Operation op)
static

Definition at line 439 of file ats-testing-experiment.c.

References GNUNET_ATS_TEST_Operation::base_rate, GNUNET_ATS_TEST_Operation::dest_id, GNUNET_ATS_TEST_Operation::gen_type, GNUNET_ATS_TEST_generate_traffic_start(), GNUNET_ATS_TEST_generate_traffic_stop(), GNUNET_ATS_TEST_get_partner(), GNUNET_ATS_TEST_get_peer(), GNUNET_break, GNUNET_TIME_UNIT_FOREVER_REL, GNUNET_ATS_TEST_Operation::max_rate, peer, GNUNET_ATS_TEST_Operation::period, GNUNET_ATS_TEST_Operation::src_id, and BenchmarkPartner::tg.

Referenced by enforce_episode().

440 {
441  struct BenchmarkPeer *peer;
442  struct BenchmarkPartner *partner;
443 
444  peer = GNUNET_ATS_TEST_get_peer (op->src_id);
445  if (NULL == peer)
446  {
447  GNUNET_break (0);
448  return;
449  }
450 
451  partner = GNUNET_ATS_TEST_get_partner (op->src_id, op->dest_id);
452  if (NULL == partner)
453  {
454  GNUNET_break (0);
455  return;
456  }
457 
458  fprintf (stderr, "Found master %llu slave %llu\n",op->src_id, op->dest_id);
459 
460  if (NULL != partner->tg)
461  {
462  fprintf (stderr, "Stopping traffic between master %llu slave %llu\n",op->src_id, op->dest_id);
464  partner->tg = NULL;
465  }
466 
467  partner->tg = GNUNET_ATS_TEST_generate_traffic_start(peer, partner,
468  op->gen_type, op->base_rate, op->max_rate, op->period,
470 }
long long unsigned int src_id
Definition: ats-testing.h:497
struct GNUNET_TIME_Relative period
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...
struct TrafficGenerator * tg
Handle for traffic generator.
Definition: ats-testing.h:295
Information we track for a peer in the testbed.
Definition: ats-testing.h:111
long long unsigned int dest_id
Definition: ats-testing.h:498
long long unsigned int base_rate
Information about a benchmarking partner.
Definition: ats-testing.h:275
#define GNUNET_TIME_UNIT_FOREVER_REL
Constant used to specify "forever".
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
struct BenchmarkPartner * GNUNET_ATS_TEST_get_partner(int src, int dest)
Definition: ats-testing.c:899
struct BenchmarkPeer * GNUNET_ATS_TEST_get_peer(int src)
Topology related functions.
Definition: ats-testing.c:890
void GNUNET_ATS_TEST_generate_traffic_stop(struct TrafficGenerator *tg)
long long unsigned int max_rate
Here is the call graph for this function:
Here is the caller graph for this function:

◆ enforce_stop_send()

static void enforce_stop_send ( struct GNUNET_ATS_TEST_Operation op)
static

Definition at line 473 of file ats-testing-experiment.c.

References GNUNET_ATS_TEST_Operation::dest_id, GNUNET_ATS_TEST_generate_traffic_stop(), GNUNET_ATS_TEST_get_partner(), GNUNET_break, p, GNUNET_ATS_TEST_Operation::src_id, and BenchmarkPartner::tg.

Referenced by enforce_episode().

474 {
475  struct BenchmarkPartner *p;
477  if (NULL == p)
478  {
479  GNUNET_break (0);
480  return;
481  }
482 
483  fprintf (stderr, "Found master %llu slave %llu\n",op->src_id, op->dest_id);
484 
485  if (NULL != p->tg)
486  {
487  fprintf (stderr, "Stopping traffic between master %llu slave %llu\n",
488  op->src_id, op->dest_id);
490  p->tg = NULL;
491  }
492 }
long long unsigned int src_id
Definition: ats-testing.h:497
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
struct TrafficGenerator * tg
Handle for traffic generator.
Definition: ats-testing.h:295
static struct GNUNET_OS_Process * p
Helper process we started.
Definition: gnunet-qr.c:59
long long unsigned int dest_id
Definition: ats-testing.h:498
Information about a benchmarking partner.
Definition: ats-testing.h:275
struct BenchmarkPartner * GNUNET_ATS_TEST_get_partner(int src, int dest)
Definition: ats-testing.c:899
void GNUNET_ATS_TEST_generate_traffic_stop(struct TrafficGenerator *tg)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ enforce_start_preference()

static void enforce_start_preference ( struct GNUNET_ATS_TEST_Operation op)
static

Definition at line 496 of file ats-testing-experiment.c.

References GNUNET_ATS_TEST_Operation::base_rate, GNUNET_ATS_TEST_Operation::dest_id, GNUNET_ATS_TEST_Operation::frequency, GNUNET_ATS_TEST_Operation::gen_type, GNUNET_ATS_TEST_generate_preferences_start(), GNUNET_ATS_TEST_generate_preferences_stop(), GNUNET_ATS_TEST_get_partner(), GNUNET_ATS_TEST_get_peer(), GNUNET_break, GNUNET_ATS_TEST_Operation::max_rate, peer, GNUNET_ATS_TEST_Operation::period, BenchmarkPartner::pg, GNUNET_ATS_TEST_Operation::pref_type, and GNUNET_ATS_TEST_Operation::src_id.

Referenced by enforce_episode().

497 {
498  struct BenchmarkPeer *peer;
499  struct BenchmarkPartner *partner;
500 
501  peer = GNUNET_ATS_TEST_get_peer (op->src_id);
502  if (NULL == peer)
503  {
504  GNUNET_break (0);
505  return;
506  }
507 
508  partner = GNUNET_ATS_TEST_get_partner (op->src_id, op->dest_id);
509  if (NULL == partner)
510  {
511  GNUNET_break (0);
512  return;
513  }
514 
515  fprintf (stderr, "Found master %llu slave %llu\n",op->src_id, op->dest_id);
516 
517  if (NULL != partner->pg)
518  {
519  fprintf (stderr, "Stopping traffic between master %llu slave %llu\n",
520  op->src_id, op->dest_id);
522  partner->pg = NULL;
523  }
524 
525  partner->pg = GNUNET_ATS_TEST_generate_preferences_start(peer, partner,
526  op->gen_type, op->base_rate, op->max_rate, op->period, op->frequency,
527  op->pref_type);
528 }
struct PreferenceGenerator * pg
Handle for preference generator.
Definition: ats-testing.h:300
long long unsigned int src_id
Definition: ats-testing.h:497
struct GNUNET_TIME_Relative period
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
Information we track for a peer in the testbed.
Definition: ats-testing.h:111
long long unsigned int dest_id
Definition: ats-testing.h:498
long long unsigned int base_rate
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_TEST_generate_preferences_stop(struct PreferenceGenerator *pg)
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
struct BenchmarkPartner * GNUNET_ATS_TEST_get_partner(int src, int dest)
Definition: ats-testing.c:899
struct BenchmarkPeer * GNUNET_ATS_TEST_get_peer(int src)
Topology related functions.
Definition: ats-testing.c:890
struct GNUNET_TIME_Relative frequency
long long unsigned int max_rate
Here is the call graph for this function:
Here is the caller graph for this function:

◆ enforce_stop_preference()

static void enforce_stop_preference ( struct GNUNET_ATS_TEST_Operation op)
static

Definition at line 531 of file ats-testing-experiment.c.

References GNUNET_ATS_TEST_Operation::dest_id, GNUNET_ATS_TEST_generate_preferences_stop(), GNUNET_ATS_TEST_get_partner(), GNUNET_break, p, BenchmarkPartner::pg, and GNUNET_ATS_TEST_Operation::src_id.

Referenced by enforce_episode().

532 {
533  struct BenchmarkPartner *p;
535  if (NULL == p)
536  {
537  GNUNET_break (0);
538  return;
539  }
540 
541  fprintf (stderr, "Found master %llu slave %llu\n",op->src_id, op->dest_id);
542 
543  if (NULL != p->pg)
544  {
545  fprintf (stderr, "Stopping preference between master %llu slave %llu\n",
546  op->src_id, op->dest_id);
548  p->pg = NULL;
549  }
550 }
struct PreferenceGenerator * pg
Handle for preference generator.
Definition: ats-testing.h:300
long long unsigned int src_id
Definition: ats-testing.h:497
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
static struct GNUNET_OS_Process * p
Helper process we started.
Definition: gnunet-qr.c:59
long long unsigned int dest_id
Definition: ats-testing.h:498
Information about a benchmarking partner.
Definition: ats-testing.h:275
void GNUNET_ATS_TEST_generate_preferences_stop(struct PreferenceGenerator *pg)
struct BenchmarkPartner * GNUNET_ATS_TEST_get_partner(int src, int dest)
Definition: ats-testing.c:899
Here is the call graph for this function:
Here is the caller graph for this function:

◆ enforce_episode()

static void enforce_episode ( struct Episode ep)
static

Definition at line 552 of file ats-testing-experiment.c.

References GNUNET_ATS_TEST_Operation::base_rate, GNUNET_ATS_TEST_Operation::dest_id, enforce_start_preference(), enforce_start_send(), enforce_stop_preference(), enforce_stop_send(), Episode::head, GNUNET_ATS_TEST_Operation::next, print_op(), GNUNET_ATS_TEST_Operation::src_id, START_PREFERENCE, START_SEND, STOP_PREFERENCE, STOP_SEND, and GNUNET_ATS_TEST_Operation::type.

Referenced by GNUNET_ATS_TEST_experimentation_run(), and timeout_episode().

553 {
554  struct GNUNET_ATS_TEST_Operation *cur;
555  for (cur = ep->head; NULL != cur; cur = cur->next)
556  {
557 
558  fprintf (stderr, "Enforcing operation: %s [%llu]->[%llu] == %llu\n",
559  print_op (cur->type), cur->src_id, cur->dest_id, cur->base_rate);
560  switch (cur->type) {
561  case START_SEND:
562  enforce_start_send (cur);
563  break;
564  case STOP_SEND:
565  enforce_stop_send (cur);
566  break;
567  case START_PREFERENCE:
569  break;
570  case STOP_PREFERENCE:
572  break;
573  default:
574  break;
575  }
576  }
577 }
struct GNUNET_ATS_TEST_Operation * next
long long unsigned int src_id
Definition: ats-testing.h:497
static void enforce_stop_send(struct GNUNET_ATS_TEST_Operation *op)
const char * print_op(enum OperationType op)
long long unsigned int dest_id
Definition: ats-testing.h:498
long long unsigned int base_rate
static void enforce_start_preference(struct GNUNET_ATS_TEST_Operation *op)
An operation in an experiment.
struct GNUNET_ATS_TEST_Operation * head
static void enforce_stop_preference(struct GNUNET_ATS_TEST_Operation *op)
static void enforce_start_send(struct GNUNET_ATS_TEST_Operation *op)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ timeout_episode()

static void timeout_episode ( void *  cls)
static

Definition at line 581 of file ats-testing-experiment.c.

References Experiment::cur, Episode::duration, e, Experiment::e_done_cb, enforce_episode(), Experiment::ep_done_cb, Experiment::episode_timeout_task, Experiment::experiment_timeout_task, GNUNET_OK, GNUNET_SCHEDULER_add_delayed(), GNUNET_SCHEDULER_cancel(), GNUNET_STRINGS_relative_time_to_string(), GNUNET_TIME_absolute_get_duration(), GNUNET_YES, Episode::id, Episode::next, and Experiment::start_time.

Referenced by GNUNET_ATS_TEST_experimentation_run().

582 {
583  struct Experiment *e = cls;
584 
585  e->episode_timeout_task = NULL;
586  if (NULL != e->ep_done_cb)
587  e->ep_done_cb (e->cur);
588 
589  /* Scheduling next */
590  e->cur = e->cur->next;
591  if (NULL == e->cur)
592  {
593  /* done */
594  fprintf (stderr, "Last episode done!\n");
595  if (NULL != e->experiment_timeout_task)
596  {
598  e->experiment_timeout_task = NULL;
599  }
601  return;
602  }
603 
604  fprintf (stderr, "Running episode %u with timeout %s\n",
605  e->cur->id,
607  enforce_episode(e->cur);
608 
610  &timeout_episode, e);
611 }
GNUNET_ATS_TESTING_EpisodeDoneCallback ep_done_cb
GNUNET_ATS_TESTING_ExperimentDoneCallback e_done_cb
struct Episode * next
static struct Experiment * e
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
struct GNUNET_SCHEDULER_Task * experiment_timeout_task
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_delayed(struct GNUNET_TIME_Relative delay, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay.
Definition: scheduler.c:1246
struct Episode * cur
const char * GNUNET_STRINGS_relative_time_to_string(struct GNUNET_TIME_Relative delta, int do_round)
Give relative time in human-readable fancy format.
Definition: strings.c:727
struct GNUNET_SCHEDULER_Task * episode_timeout_task
struct GNUNET_TIME_Relative duration
struct GNUNET_TIME_Absolute start_time
static void enforce_episode(struct Episode *ep)
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
static void timeout_episode(void *cls)
#define GNUNET_YES
Definition: gnunet_common.h:80
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:965
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_ATS_TEST_experimentation_run()

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.

Parameters
ethe Experiment
ep_done_cba episode is completed
e_done_cbthe experiment is completed

Definition at line 615 of file ats-testing-experiment.c.

References Experiment::cur, Episode::duration, Experiment::e_done_cb, enforce_episode(), Experiment::ep_done_cb, Experiment::episode_timeout_task, Experiment::experiment_timeout_task, GNUNET_SCHEDULER_add_delayed(), GNUNET_STRINGS_relative_time_to_string(), GNUNET_TIME_absolute_get(), GNUNET_YES, Episode::id, Experiment::max_duration, Experiment::name, Experiment::start, Experiment::start_time, timeout_episode(), and timeout_experiment().

Referenced by topology_setup_done().

618 {
619  fprintf (stderr, "Running experiment `%s' with timeout %s\n", e->name,
621  e->e_done_cb = e_done_cb;
622  e->ep_done_cb = ep_done_cb;
624 
625  /* Start total time out */
627  &timeout_experiment, e);
628 
629  /* Start */
630  e->cur = e->start;
631  fprintf (stderr, "Running episode %u with timeout %s\n",
632  e->cur->id,
634  enforce_episode(e->cur);
636  &timeout_episode, e);
637 
638 
639 }
struct Episode * start
GNUNET_ATS_TESTING_EpisodeDoneCallback ep_done_cb
GNUNET_ATS_TESTING_ExperimentDoneCallback e_done_cb
static void timeout_experiment(void *cls)
struct GNUNET_SCHEDULER_Task * experiment_timeout_task
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_delayed(struct GNUNET_TIME_Relative delay, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay.
Definition: scheduler.c:1246
struct Episode * cur
const char * GNUNET_STRINGS_relative_time_to_string(struct GNUNET_TIME_Relative delta, int do_round)
Give relative time in human-readable fancy format.
Definition: strings.c:727
struct GNUNET_SCHEDULER_Task * episode_timeout_task
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
static void enforce_episode(struct Episode *ep)
static void timeout_episode(void *cls)
#define GNUNET_YES
Definition: gnunet_common.h:80
struct GNUNET_TIME_Relative max_duration
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_ATS_TEST_experimentation_load()

struct Experiment* GNUNET_ATS_TEST_experimentation_load ( const char *  filename)

Load an experiment from a file.

Parameters
filenamethe file
Returns
the Experiment or NULL on failure

Definition at line 643 of file ats-testing-experiment.c.

References cfg, Experiment::cfg_file, create_experiment(), e, free_experiment(), GNUNET_CONFIGURATION_create(), GNUNET_CONFIGURATION_destroy(), GNUNET_CONFIGURATION_get_value_filename(), GNUNET_CONFIGURATION_get_value_number(), GNUNET_CONFIGURATION_get_value_string(), GNUNET_CONFIGURATION_get_value_time(), GNUNET_CONFIGURATION_load(), GNUNET_STRINGS_relative_time_to_string(), GNUNET_SYSERR, GNUNET_YES, load_episodes(), Experiment::log_freq, Experiment::max_duration, Experiment::name, Experiment::num_episodes, Experiment::num_masters, Experiment::num_slaves, and Experiment::total_duration.

Referenced by main().

644 {
645  struct Experiment *e;
647  e = NULL;
648 
651  {
652  fprintf (stderr, "Failed to load `%s'\n", filename);
654  return NULL;
655  }
656 
657  e = create_experiment ();
658 
659  if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string(cfg, "experiment",
660  "name", &e->name))
661  {
662  fprintf (stderr, "Invalid %s", "name");
663  free_experiment (e);
664  return NULL;
665  }
666  else
667  fprintf (stderr, "Experiment name: `%s'\n", e->name);
668 
669  if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_filename (cfg, "experiment",
670  "cfg_file", &e->cfg_file))
671  {
672  fprintf (stderr, "Invalid %s", "cfg_file");
673  free_experiment (e);
674  return NULL;
675  }
676  else
677  fprintf (stderr, "Experiment name: `%s'\n", e->cfg_file);
678 
679  if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number(cfg, "experiment",
680  "masters", &e->num_masters))
681  {
682  fprintf (stderr, "Invalid %s", "masters");
683  free_experiment (e);
684  return NULL;
685  }
686  else
687  fprintf (stderr, "Experiment masters: `%llu'\n",
688  e->num_masters);
689 
690  if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number(cfg, "experiment",
691  "slaves", &e->num_slaves))
692  {
693  fprintf (stderr, "Invalid %s", "slaves");
694  free_experiment (e);
695  return NULL;
696  }
697  else
698  fprintf (stderr, "Experiment slaves: `%llu'\n",
699  e->num_slaves);
700 
701  if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_time(cfg, "experiment",
702  "log_freq", &e->log_freq))
703  {
704  fprintf (stderr, "Invalid %s", "log_freq");
705  free_experiment (e);
706  return NULL;
707  }
708  else
709  fprintf (stderr, "Experiment logging frequency: `%s'\n",
711 
712  if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_time(cfg, "experiment",
713  "max_duration", &e->max_duration))
714  {
715  fprintf (stderr, "Invalid %s", "max_duration");
716  free_experiment (e);
717  return NULL;
718  }
719  else
720  fprintf (stderr, "Experiment duration: `%s'\n",
722 
723  load_episodes (e, cfg);
724  fprintf (stderr, "Loaded %u episodes with total duration %s\n",
725  e->num_episodes,
727 
729  return e;
730 }
static struct Experiment * create_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.
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.
unsigned long long int num_masters
Definition: ats-testing.h:525
struct GNUNET_TIME_Relative total_duration
static struct Experiment * e
unsigned int num_episodes
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)
static void free_experiment(struct Experiment *e)
int GNUNET_CONFIGURATION_load(struct GNUNET_CONFIGURATION_Handle *cfg, const char *filename)
Load configuration.
struct GNUNET_TIME_Relative log_freq
const char * GNUNET_STRINGS_relative_time_to_string(struct GNUNET_TIME_Relative delta, int do_round)
Give relative time in human-readable fancy format.
Definition: strings.c:727
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
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.
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
Definition: gnunet-arm.c:104
#define GNUNET_SYSERR
Definition: gnunet_common.h:79
configuration data
Definition: configuration.c:85
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.
#define GNUNET_YES
Definition: gnunet_common.h:80
struct GNUNET_TIME_Relative max_duration
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_ATS_TEST_experimentation_stop()

void GNUNET_ATS_TEST_experimentation_stop ( struct Experiment e)

Stop an experiment.

Parameters
ethe experiment

Definition at line 733 of file ats-testing-experiment.c.

References Experiment::episode_timeout_task, Experiment::experiment_timeout_task, free_experiment(), and GNUNET_SCHEDULER_cancel().

Referenced by do_shutdown().

734 {
735  if (NULL != e->experiment_timeout_task)
736  {
738  e->experiment_timeout_task = NULL;
739  }
740  if (NULL != e->episode_timeout_task)
741  {
743  e->episode_timeout_task = NULL;
744  }
745  free_experiment (e);
746 }
static void free_experiment(struct Experiment *e)
struct GNUNET_SCHEDULER_Task * experiment_timeout_task
struct GNUNET_SCHEDULER_Task * episode_timeout_task
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:965
Here is the call graph for this function:
Here is the caller graph for this function: