diff options
Diffstat (limited to 'src/ats-tests/ats-testing-experiment.c')
-rw-r--r-- | src/ats-tests/ats-testing-experiment.c | 131 |
1 files changed, 100 insertions, 31 deletions
diff --git a/src/ats-tests/ats-testing-experiment.c b/src/ats-tests/ats-testing-experiment.c index 12858f2aa..1ab1342c5 100644 --- a/src/ats-tests/ats-testing-experiment.c +++ b/src/ats-tests/ats-testing-experiment.c | |||
@@ -94,14 +94,15 @@ load_episode (struct Experiment *e, struct Episode *cur, | |||
94 | char *sec_name; | 94 | char *sec_name; |
95 | char *op_name; | 95 | char *op_name; |
96 | char *op; | 96 | char *op; |
97 | int ep_counter = 0; | 97 | char *type; |
98 | int op_counter = 0; | ||
98 | fprintf (stderr, "Parsing episode %u\n",cur->id); | 99 | fprintf (stderr, "Parsing episode %u\n",cur->id); |
99 | GNUNET_asprintf(&sec_name, "episode-%u", cur->id); | 100 | GNUNET_asprintf(&sec_name, "episode-%u", cur->id); |
100 | 101 | ||
101 | while (1) | 102 | while (1) |
102 | { | 103 | { |
103 | 104 | /* Load operation */ | |
104 | GNUNET_asprintf(&op_name, "op-%u-operation", ep_counter); | 105 | GNUNET_asprintf(&op_name, "op-%u-operation", op_counter); |
105 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string(cfg, | 106 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string(cfg, |
106 | sec_name, op_name, &op)) | 107 | sec_name, op_name, &op)) |
107 | { | 108 | { |
@@ -128,72 +129,140 @@ load_episode (struct Experiment *e, struct Episode *cur, | |||
128 | else | 129 | else |
129 | { | 130 | { |
130 | fprintf (stderr, "Invalid operation %u `%s' in episode %u\n", | 131 | fprintf (stderr, "Invalid operation %u `%s' in episode %u\n", |
131 | ep_counter, op, cur->id); | 132 | op_counter, op, cur->id); |
132 | GNUNET_free (op); | 133 | GNUNET_free (op); |
134 | GNUNET_free (op_name); | ||
133 | return GNUNET_SYSERR; | 135 | return GNUNET_SYSERR; |
134 | } | 136 | } |
135 | |||
136 | GNUNET_free (op_name); | 137 | GNUNET_free (op_name); |
137 | GNUNET_asprintf(&op_name, "op-%u-src", ep_counter); | 138 | |
139 | /* Get source */ | ||
140 | GNUNET_asprintf(&op_name, "op-%u-src", op_counter); | ||
138 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (cfg, | 141 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (cfg, |
139 | sec_name, op_name, &o->src_id)) | 142 | sec_name, op_name, &o->src_id)) |
140 | { | 143 | { |
141 | fprintf (stderr, "Missing src in operation %u `%s' in episode %u\n", | 144 | fprintf (stderr, "Missing src in operation %u `%s' in episode %u\n", |
142 | ep_counter, op, cur->id); | 145 | op_counter, op, cur->id); |
143 | GNUNET_free (op); | 146 | GNUNET_free (op); |
147 | GNUNET_free (op_name); | ||
144 | return GNUNET_SYSERR; | 148 | return GNUNET_SYSERR; |
145 | } | 149 | } |
146 | if (o->src_id > e->num_masters) | 150 | if (o->src_id > e->num_masters) |
147 | { | 151 | { |
148 | fprintf (stderr, "Invalid src %llu in operation %u `%s' in episode %u\n", | 152 | fprintf (stderr, "Invalid src %llu in operation %u `%s' in episode %u\n", |
149 | o->src_id, ep_counter, op, cur->id); | 153 | o->src_id, op_counter, op, cur->id); |
150 | GNUNET_free (op); | 154 | GNUNET_free (op); |
155 | GNUNET_free (op_name); | ||
151 | return GNUNET_SYSERR; | 156 | return GNUNET_SYSERR; |
152 | } | 157 | } |
153 | |||
154 | GNUNET_free (op_name); | 158 | GNUNET_free (op_name); |
155 | GNUNET_asprintf(&op_name, "op-%u-dest", ep_counter); | 159 | |
160 | /* Get destination */ | ||
161 | GNUNET_asprintf(&op_name, "op-%u-dest", op_counter); | ||
156 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (cfg, | 162 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (cfg, |
157 | sec_name, op_name, &o->dest_id)) | 163 | sec_name, op_name, &o->dest_id)) |
158 | { | 164 | { |
159 | fprintf (stderr, "Missing src in operation %u `%s' in episode %u\n", | 165 | fprintf (stderr, "Missing src in operation %u `%s' in episode %u\n", |
160 | ep_counter, op, cur->id); | 166 | op_counter, op, cur->id); |
161 | GNUNET_free (op); | 167 | GNUNET_free (op); |
168 | GNUNET_free (op_name); | ||
162 | return GNUNET_SYSERR; | 169 | return GNUNET_SYSERR; |
163 | } | 170 | } |
164 | if (o->dest_id > e->num_slaves) | 171 | if (o->dest_id > e->num_slaves) |
165 | { | 172 | { |
166 | fprintf (stderr, "Invalid destination %llu in operation %u `%s' in episode %u\n", | 173 | fprintf (stderr, "Invalid destination %llu in operation %u `%s' in episode %u\n", |
167 | o->dest_id, ep_counter, op, cur->id); | 174 | o->dest_id, op_counter, op, cur->id); |
168 | GNUNET_free (op); | 175 | GNUNET_free (op); |
176 | GNUNET_free (op_name); | ||
169 | return GNUNET_SYSERR; | 177 | return GNUNET_SYSERR; |
170 | } | 178 | } |
171 | |||
172 | |||
173 | GNUNET_free (op_name); | 179 | GNUNET_free (op_name); |
174 | GNUNET_asprintf(&op_name, "op-%u-value", ep_counter); | 180 | |
175 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (cfg, | 181 | GNUNET_asprintf(&op_name, "op-%u-type", op_counter); |
176 | sec_name, op_name, &o->value)) | 182 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string(cfg, |
183 | sec_name, op_name, &type)) | ||
177 | { | 184 | { |
178 | fprintf (stderr, "Missing value in operation %u `%s' in episode %u\n", | 185 | break; |
179 | ep_counter, op, cur->id); | ||
180 | GNUNET_free (op); | ||
181 | return GNUNET_SYSERR; | ||
182 | } | 186 | } |
183 | if (o->dest_id > e->num_slaves) | 187 | |
188 | if (STOP_SEND != o->type) | ||
184 | { | 189 | { |
185 | fprintf (stderr, "Invalid destination %llu in operation %u `%s' in episode %u\n", | 190 | /* Load arguments for set_rate, start_send, set_preference */ |
186 | o->dest_id, ep_counter, op, cur->id); | 191 | if (0 == strcmp (type, "constant")) |
187 | GNUNET_free (op); | 192 | { |
188 | return GNUNET_SYSERR; | 193 | o->tg_type = GNUNET_ATS_TEST_TG_CONSTANT; |
194 | } | ||
195 | else if (0 == strcmp (type, "linear")) | ||
196 | { | ||
197 | o->tg_type = GNUNET_ATS_TEST_TG_LINEAR; | ||
198 | } | ||
199 | else if (0 == strcmp (type, "sinus")) | ||
200 | { | ||
201 | o->tg_type = GNUNET_ATS_TEST_TG_SINUS; | ||
202 | } | ||
203 | else if (0 == strcmp (type, "random")) | ||
204 | { | ||
205 | o->tg_type = GNUNET_ATS_TEST_TG_RANDOM; | ||
206 | } | ||
207 | else | ||
208 | { | ||
209 | fprintf (stderr, "Invalid type %u `%s' in episode %u\n", | ||
210 | op_counter, op, cur->id); | ||
211 | GNUNET_free (op); | ||
212 | GNUNET_free (op_name); | ||
213 | return GNUNET_SYSERR; | ||
214 | } | ||
215 | GNUNET_free (op_name); | ||
216 | |||
217 | /* Get base rate */ | ||
218 | GNUNET_asprintf(&op_name, "op-%u-base-rate", op_counter); | ||
219 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (cfg, | ||
220 | sec_name, op_name, &o->base_rate)) | ||
221 | { | ||
222 | fprintf (stderr, "Missing base rate in operation %u `%s' in episode %u\n", | ||
223 | op_counter, op, cur->id); | ||
224 | GNUNET_free (op); | ||
225 | GNUNET_free (op_name); | ||
226 | return GNUNET_SYSERR; | ||
227 | } | ||
228 | GNUNET_free (op_name); | ||
229 | |||
230 | /* Get max rate */ | ||
231 | GNUNET_asprintf(&op_name, "op-%u-max-rate", op_counter); | ||
232 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (cfg, | ||
233 | sec_name, op_name, &o->max_rate)) | ||
234 | { | ||
235 | if ((GNUNET_ATS_TEST_TG_LINEAR == o->tg_type) || | ||
236 | (GNUNET_ATS_TEST_TG_RANDOM == o->tg_type) || | ||
237 | (GNUNET_ATS_TEST_TG_SINUS == o->tg_type)) | ||
238 | { | ||
239 | fprintf (stderr, "Missing max rate in operation %u `%s' in episode %u\n", | ||
240 | op_counter, op, cur->id); | ||
241 | GNUNET_free (op); | ||
242 | return GNUNET_SYSERR; | ||
243 | } | ||
244 | } | ||
245 | GNUNET_free (op_name); | ||
246 | |||
247 | { | ||
248 | /* Get period */ | ||
249 | GNUNET_asprintf(&op_name, "op-%u-period", op_counter); | ||
250 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_time (cfg, | ||
251 | sec_name, op_name, &o->period)) | ||
252 | { | ||
253 | o->period = cur->duration; | ||
254 | } | ||
255 | GNUNET_free (op_name); | ||
256 | } | ||
189 | } | 257 | } |
190 | 258 | ||
191 | fprintf (stderr, "Found operation %u in episode %u: %s [%llu]->[%llu] == %llu\n", | 259 | fprintf (stderr, "Found operation %u in episode %u: %s [%llu]->[%llu] == %s, %llu -> %llu in %s\n", |
192 | ep_counter, cur->id, print_op (o->type), o->src_id, o->dest_id, o->value); | 260 | op_counter, cur->id, print_op (o->type), o->src_id, |
261 | o->dest_id, type, o->base_rate, o->max_rate, | ||
262 | GNUNET_STRINGS_relative_time_to_string (o->period, GNUNET_YES)); | ||
193 | 263 | ||
194 | GNUNET_CONTAINER_DLL_insert (cur->head,cur->tail, o); | 264 | GNUNET_CONTAINER_DLL_insert (cur->head,cur->tail, o); |
195 | GNUNET_free (op_name); | 265 | op_counter++; |
196 | ep_counter++; | ||
197 | } | 266 | } |
198 | GNUNET_free (sec_name); | 267 | GNUNET_free (sec_name); |
199 | 268 | ||
@@ -300,7 +369,7 @@ static void enforce_episode (struct Episode *ep) | |||
300 | { | 369 | { |
301 | 370 | ||
302 | fprintf (stderr, "Enforcing operation: %s [%llu]->[%llu] == %llu\n", | 371 | fprintf (stderr, "Enforcing operation: %s [%llu]->[%llu] == %llu\n", |
303 | print_op (cur->type), cur->src_id, cur->dest_id, cur->value); | 372 | print_op (cur->type), cur->src_id, cur->dest_id, cur->base_rate); |
304 | switch (cur->type) { | 373 | switch (cur->type) { |
305 | case START_SEND: | 374 | case START_SEND: |
306 | enforce_start_send (cur); | 375 | enforce_start_send (cur); |