diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2014-01-23 16:03:53 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2014-01-23 16:03:53 +0000 |
commit | 7401d20fe0d587ca704228d4b1474666cad3df12 (patch) | |
tree | 02a53cb537d0f7e72dcc6d616f27a72e351d42b0 /src/ats-tests | |
parent | d10f54d435d545b4fdafd4ffa278f786b5f500dc (diff) | |
download | gnunet-7401d20fe0d587ca704228d4b1474666cad3df12.tar.gz gnunet-7401d20fe0d587ca704228d4b1474666cad3df12.zip |
implementing operations, episodes...
Diffstat (limited to 'src/ats-tests')
-rw-r--r-- | src/ats-tests/ats-testing-experiment.c | 147 | ||||
-rw-r--r-- | src/ats-tests/ats-testing.h | 41 | ||||
-rw-r--r-- | src/ats-tests/gnunet-ats-sim.c | 14 |
3 files changed, 184 insertions, 18 deletions
diff --git a/src/ats-tests/ats-testing-experiment.c b/src/ats-tests/ats-testing-experiment.c index fca374324..03e5efd02 100644 --- a/src/ats-tests/ats-testing-experiment.c +++ b/src/ats-tests/ats-testing-experiment.c | |||
@@ -27,6 +27,25 @@ | |||
27 | #include "gnunet_util_lib.h" | 27 | #include "gnunet_util_lib.h" |
28 | #include "ats-testing.h" | 28 | #include "ats-testing.h" |
29 | 29 | ||
30 | const char * | ||
31 | print_op (enum OperationType op) | ||
32 | { | ||
33 | switch (op) { | ||
34 | case START_SEND: | ||
35 | return "START_SEND"; | ||
36 | case STOP_SEND: | ||
37 | return "STOP_SEND"; | ||
38 | case SET_RATE: | ||
39 | return "SET_RATE"; | ||
40 | case SET_PREFERENCE: | ||
41 | return "SET_PREFERENCE"; | ||
42 | default: | ||
43 | break; | ||
44 | } | ||
45 | return ""; | ||
46 | } | ||
47 | |||
48 | |||
30 | static struct Experiment * | 49 | static struct Experiment * |
31 | create_experiment () | 50 | create_experiment () |
32 | { | 51 | { |
@@ -59,6 +78,120 @@ free_experiment (struct Experiment *e) | |||
59 | } | 78 | } |
60 | 79 | ||
61 | static int | 80 | static int |
81 | load_episode (struct Experiment *e, struct Episode *cur, | ||
82 | struct GNUNET_CONFIGURATION_Handle *cfg) | ||
83 | { | ||
84 | struct Operation *o; | ||
85 | char *sec_name; | ||
86 | char *op_name; | ||
87 | char *op; | ||
88 | int ep_counter = 0; | ||
89 | fprintf (stderr, "Parsing episode %u\n",cur->id); | ||
90 | GNUNET_asprintf(&sec_name, "episode-%u", cur->id); | ||
91 | |||
92 | while (1) | ||
93 | { | ||
94 | |||
95 | GNUNET_asprintf(&op_name, "op-%u-operation", ep_counter); | ||
96 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string(cfg, | ||
97 | sec_name, op_name, &op)) | ||
98 | { | ||
99 | break; | ||
100 | } | ||
101 | o = GNUNET_new (struct Operation); | ||
102 | /* operations = set_rate, start_send, stop_send, set_preference */ | ||
103 | if (0 == strcmp (op, "start_send")) | ||
104 | { | ||
105 | o->type = START_SEND; | ||
106 | } | ||
107 | else if (0 == strcmp (op, "stop_send")) | ||
108 | { | ||
109 | o->type = STOP_SEND; | ||
110 | } | ||
111 | else if (0 == strcmp (op, "set_rate")) | ||
112 | { | ||
113 | o->type = SET_RATE; | ||
114 | } | ||
115 | else if (0 == strcmp (op, "set_preference ")) | ||
116 | { | ||
117 | o->type = SET_PREFERENCE; | ||
118 | } | ||
119 | else | ||
120 | { | ||
121 | fprintf (stderr, "Invalid operation %u `%s' in episode %u\n", | ||
122 | ep_counter, op, cur->id); | ||
123 | GNUNET_free (op); | ||
124 | return GNUNET_SYSERR; | ||
125 | } | ||
126 | |||
127 | GNUNET_free (op_name); | ||
128 | GNUNET_asprintf(&op_name, "op-%u-src", ep_counter); | ||
129 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (cfg, | ||
130 | sec_name, op_name, &o->src_id)) | ||
131 | { | ||
132 | fprintf (stderr, "Missing src in operation %u `%s' in episode %u\n", | ||
133 | ep_counter, op, cur->id); | ||
134 | GNUNET_free (op); | ||
135 | return GNUNET_SYSERR; | ||
136 | } | ||
137 | if (o->src_id > e->num_masters) | ||
138 | { | ||
139 | fprintf (stderr, "Invalid src %llu in operation %u `%s' in episode %u\n", | ||
140 | o->src_id, ep_counter, op, cur->id); | ||
141 | GNUNET_free (op); | ||
142 | return GNUNET_SYSERR; | ||
143 | } | ||
144 | |||
145 | GNUNET_free (op_name); | ||
146 | GNUNET_asprintf(&op_name, "op-%u-dest", ep_counter); | ||
147 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (cfg, | ||
148 | sec_name, op_name, &o->dest_id)) | ||
149 | { | ||
150 | fprintf (stderr, "Missing src in operation %u `%s' in episode %u\n", | ||
151 | ep_counter, op, cur->id); | ||
152 | GNUNET_free (op); | ||
153 | return GNUNET_SYSERR; | ||
154 | } | ||
155 | if (o->dest_id > e->num_slaves) | ||
156 | { | ||
157 | fprintf (stderr, "Invalid destination %llu in operation %u `%s' in episode %u\n", | ||
158 | o->dest_id, ep_counter, op, cur->id); | ||
159 | GNUNET_free (op); | ||
160 | return GNUNET_SYSERR; | ||
161 | } | ||
162 | |||
163 | |||
164 | GNUNET_free (op_name); | ||
165 | GNUNET_asprintf(&op_name, "op-%u-value", ep_counter); | ||
166 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (cfg, | ||
167 | sec_name, op_name, &o->value)) | ||
168 | { | ||
169 | fprintf (stderr, "Missing value in operation %u `%s' in episode %u\n", | ||
170 | ep_counter, op, cur->id); | ||
171 | GNUNET_free (op); | ||
172 | return GNUNET_SYSERR; | ||
173 | } | ||
174 | if (o->dest_id > e->num_slaves) | ||
175 | { | ||
176 | fprintf (stderr, "Invalid destination %llu in operation %u `%s' in episode %u\n", | ||
177 | o->dest_id, ep_counter, op, cur->id); | ||
178 | GNUNET_free (op); | ||
179 | return GNUNET_SYSERR; | ||
180 | } | ||
181 | |||
182 | fprintf (stderr, "Found operation %u in episode %u: %s [%llu]->[%llu] == %llu\n", | ||
183 | ep_counter, cur->id, print_op (o->type), o->src_id, o->dest_id, o->value); | ||
184 | |||
185 | GNUNET_CONTAINER_DLL_insert (cur->head,cur->tail, o); | ||
186 | GNUNET_free (op_name); | ||
187 | ep_counter++; | ||
188 | } | ||
189 | GNUNET_free (sec_name); | ||
190 | |||
191 | return GNUNET_OK; | ||
192 | } | ||
193 | |||
194 | static int | ||
62 | load_episodes (struct Experiment *e, struct GNUNET_CONFIGURATION_Handle *cfg) | 195 | load_episodes (struct Experiment *e, struct GNUNET_CONFIGURATION_Handle *cfg) |
63 | { | 196 | { |
64 | int e_counter = 0; | 197 | int e_counter = 0; |
@@ -83,6 +216,13 @@ load_episodes (struct Experiment *e, struct GNUNET_CONFIGURATION_Handle *cfg) | |||
83 | cur->duration = e_duration; | 216 | cur->duration = e_duration; |
84 | cur->id = e_counter; | 217 | cur->id = e_counter; |
85 | 218 | ||
219 | if (GNUNET_OK != load_episode (e, cur, cfg)) | ||
220 | { | ||
221 | GNUNET_free (sec_name); | ||
222 | GNUNET_free (cur); | ||
223 | return GNUNET_SYSERR; | ||
224 | } | ||
225 | |||
86 | fprintf (stderr, "Found episode %u with duration %s \n", | 226 | fprintf (stderr, "Found episode %u with duration %s \n", |
87 | e_counter, | 227 | e_counter, |
88 | GNUNET_STRINGS_relative_time_to_string(cur->duration, GNUNET_YES)); | 228 | GNUNET_STRINGS_relative_time_to_string(cur->duration, GNUNET_YES)); |
@@ -110,7 +250,8 @@ timeout_experiment (void *cls, const struct GNUNET_SCHEDULER_TaskContext* tc) | |||
110 | e->experiment_timeout_task = GNUNET_SCHEDULER_NO_TASK; | 250 | e->experiment_timeout_task = GNUNET_SCHEDULER_NO_TASK; |
111 | fprintf (stderr, "Experiment timeout!\n"); | 251 | fprintf (stderr, "Experiment timeout!\n"); |
112 | 252 | ||
113 | e->e_done_cb (e, GNUNET_SYSERR); | 253 | e->e_done_cb (e, GNUNET_TIME_absolute_get_duration(e->start_time), |
254 | GNUNET_SYSERR); | ||
114 | } | 255 | } |
115 | 256 | ||
116 | static void | 257 | static void |
@@ -131,7 +272,7 @@ timeout_episode (void *cls, const struct GNUNET_SCHEDULER_TaskContext* tc) | |||
131 | GNUNET_SCHEDULER_cancel (e->experiment_timeout_task); | 272 | GNUNET_SCHEDULER_cancel (e->experiment_timeout_task); |
132 | e->experiment_timeout_task = GNUNET_SCHEDULER_NO_TASK; | 273 | e->experiment_timeout_task = GNUNET_SCHEDULER_NO_TASK; |
133 | } | 274 | } |
134 | e->e_done_cb (e, GNUNET_OK); | 275 | e->e_done_cb (e, GNUNET_TIME_absolute_get_duration(e->start_time), GNUNET_OK); |
135 | return; | 276 | return; |
136 | } | 277 | } |
137 | 278 | ||
@@ -152,6 +293,7 @@ GNUNET_ATS_TEST_experimentation_run (struct Experiment *e, | |||
152 | GNUNET_STRINGS_relative_time_to_string(e->max_duration, GNUNET_YES)); | 293 | GNUNET_STRINGS_relative_time_to_string(e->max_duration, GNUNET_YES)); |
153 | e->e_done_cb = e_done_cb; | 294 | e->e_done_cb = e_done_cb; |
154 | e->ep_done_cb = ep_done_cb; | 295 | e->ep_done_cb = ep_done_cb; |
296 | e->start_time = GNUNET_TIME_absolute_get(); | ||
155 | 297 | ||
156 | /* Start total time out */ | 298 | /* Start total time out */ |
157 | e->experiment_timeout_task = GNUNET_SCHEDULER_add_delayed (e->max_duration, | 299 | e->experiment_timeout_task = GNUNET_SCHEDULER_add_delayed (e->max_duration, |
@@ -168,6 +310,7 @@ GNUNET_ATS_TEST_experimentation_run (struct Experiment *e, | |||
168 | 310 | ||
169 | } | 311 | } |
170 | 312 | ||
313 | |||
171 | struct Experiment * | 314 | struct Experiment * |
172 | GNUNET_ATS_TEST_experimentation_load (char *filename) | 315 | GNUNET_ATS_TEST_experimentation_load (char *filename) |
173 | { | 316 | { |
diff --git a/src/ats-tests/ats-testing.h b/src/ats-tests/ats-testing.h index 028789d69..a2937d51d 100644 --- a/src/ats-tests/ats-testing.h +++ b/src/ats-tests/ats-testing.h | |||
@@ -385,15 +385,43 @@ struct GNUNET_ATS_TEST_Topology | |||
385 | void *done_cb_cls; | 385 | void *done_cb_cls; |
386 | }; | 386 | }; |
387 | 387 | ||
388 | struct Experiment; | 388 | enum OperationType |
389 | { | ||
390 | START_SEND, | ||
391 | STOP_SEND, | ||
392 | SET_RATE, | ||
393 | SET_PREFERENCE | ||
394 | }; | ||
389 | 395 | ||
390 | struct Episode; | 396 | struct Episode; |
391 | 397 | ||
398 | struct Experiment; | ||
399 | |||
392 | typedef void (*GNUNET_ATS_TESTING_EpisodeDoneCallback) ( | 400 | typedef void (*GNUNET_ATS_TESTING_EpisodeDoneCallback) ( |
393 | struct Episode *e); | 401 | struct Episode *e); |
394 | 402 | ||
395 | typedef void (*GNUNET_ATS_TESTING_ExperimentDoneCallback) ( | 403 | typedef void (*GNUNET_ATS_TESTING_ExperimentDoneCallback) (struct Experiment *e, |
396 | struct Experiment *e, int success); | 404 | struct GNUNET_TIME_Relative duration,int success); |
405 | |||
406 | struct Operation | ||
407 | { | ||
408 | struct Operation *next; | ||
409 | struct Operation *prev; | ||
410 | long long unsigned int src_id; | ||
411 | long long unsigned int dest_id; | ||
412 | long long unsigned int value; | ||
413 | enum OperationType type; | ||
414 | }; | ||
415 | |||
416 | struct Episode | ||
417 | { | ||
418 | int id; | ||
419 | struct Episode *next; | ||
420 | struct GNUNET_TIME_Relative duration; | ||
421 | |||
422 | struct Operation *head; | ||
423 | struct Operation *tail; | ||
424 | }; | ||
397 | 425 | ||
398 | 426 | ||
399 | struct Experiment | 427 | struct Experiment |
@@ -416,13 +444,6 @@ struct Experiment | |||
416 | GNUNET_ATS_TESTING_ExperimentDoneCallback e_done_cb; | 444 | GNUNET_ATS_TESTING_ExperimentDoneCallback e_done_cb; |
417 | }; | 445 | }; |
418 | 446 | ||
419 | struct Episode | ||
420 | { | ||
421 | int id; | ||
422 | struct Episode *next; | ||
423 | struct GNUNET_TIME_Relative duration; | ||
424 | }; | ||
425 | |||
426 | void | 447 | void |
427 | GNUNET_ATS_TEST_experimentation_run (struct Experiment *e, | 448 | GNUNET_ATS_TEST_experimentation_run (struct Experiment *e, |
428 | GNUNET_ATS_TESTING_EpisodeDoneCallback ep_done_cb, | 449 | GNUNET_ATS_TESTING_EpisodeDoneCallback ep_done_cb, |
diff --git a/src/ats-tests/gnunet-ats-sim.c b/src/ats-tests/gnunet-ats-sim.c index e06ca8887..a15afa639 100644 --- a/src/ats-tests/gnunet-ats-sim.c +++ b/src/ats-tests/gnunet-ats-sim.c | |||
@@ -43,7 +43,7 @@ struct Experiment *e; | |||
43 | struct LoggingHandle *l; | 43 | struct LoggingHandle *l; |
44 | 44 | ||
45 | static void | 45 | static void |
46 | evaluate () | 46 | evaluate (struct GNUNET_TIME_Relative duration_total) |
47 | { | 47 | { |
48 | int c_m; | 48 | int c_m; |
49 | int c_s; | 49 | int c_s; |
@@ -57,7 +57,8 @@ evaluate () | |||
57 | double kb_recv_percent; | 57 | double kb_recv_percent; |
58 | unsigned int rtt; | 58 | unsigned int rtt; |
59 | 59 | ||
60 | duration = (TEST_TIMEOUT.rel_value_us / (1000 * 1000)); | 60 | |
61 | duration = (duration_total.rel_value_us / (1000 * 1000)); | ||
61 | for (c_m = 0; c_m < e->num_masters; c_m++) | 62 | for (c_m = 0; c_m < e->num_masters; c_m++) |
62 | { | 63 | { |
63 | mp = &masters_p[c_m]; | 64 | mp = &masters_p[c_m]; |
@@ -135,12 +136,13 @@ log_request__cb (void *cls, const struct GNUNET_HELLO_Address *address, | |||
135 | } | 136 | } |
136 | 137 | ||
137 | static void | 138 | static void |
138 | experiment_done_cb (struct Experiment *e, int success) | 139 | experiment_done_cb (struct Experiment *e, struct GNUNET_TIME_Relative duration,int success) |
139 | { | 140 | { |
140 | if (GNUNET_OK == success) | 141 | if (GNUNET_OK == success) |
141 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Experiment `%s' done successful\n", e->name); | 142 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Experiment done successful in %s\n", |
143 | GNUNET_STRINGS_relative_time_to_string (duration, GNUNET_YES)); | ||
142 | else | 144 | else |
143 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Experiment `%s' failed \n", e->name); | 145 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Experiment failed \n"); |
144 | if (GNUNET_SCHEDULER_NO_TASK != timeout_task) | 146 | if (GNUNET_SCHEDULER_NO_TASK != timeout_task) |
145 | { | 147 | { |
146 | GNUNET_SCHEDULER_cancel (timeout_task); | 148 | GNUNET_SCHEDULER_cancel (timeout_task); |
@@ -148,7 +150,7 @@ experiment_done_cb (struct Experiment *e, int success) | |||
148 | } | 150 | } |
149 | /* Stop logging */ | 151 | /* Stop logging */ |
150 | GNUNET_ATS_TEST_logging_stop (l); | 152 | GNUNET_ATS_TEST_logging_stop (l); |
151 | evaluate (); | 153 | evaluate (duration); |
152 | 154 | ||
153 | /* Stop traffic generation */ | 155 | /* Stop traffic generation */ |
154 | GNUNET_ATS_TEST_generate_traffic_stop_all(); | 156 | GNUNET_ATS_TEST_generate_traffic_stop_all(); |