aboutsummaryrefslogtreecommitdiff
path: root/src/ats-tests
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2014-02-03 22:31:19 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2014-02-03 22:31:19 +0000
commit6dd86aa09f9eff39fcca73bcca12b3eb34f1bc1d (patch)
tree041e8cde4d37f318ccaae4b512882c54b49286fe /src/ats-tests
parent0558cdeaee9f5b2021279b8106e9f907021c45cd (diff)
downloadgnunet-6dd86aa09f9eff39fcca73bcca12b3eb34f1bc1d.tar.gz
gnunet-6dd86aa09f9eff39fcca73bcca12b3eb34f1bc1d.zip
enforcing preferences
Diffstat (limited to 'src/ats-tests')
-rw-r--r--src/ats-tests/ats-testing-experiment.c137
-rw-r--r--src/ats-tests/ats-testing.h5
-rw-r--r--src/ats-tests/experiments/test.exp34
-rw-r--r--src/ats-tests/gnunet-ats-sim.c3
4 files changed, 164 insertions, 15 deletions
diff --git a/src/ats-tests/ats-testing-experiment.c b/src/ats-tests/ats-testing-experiment.c
index 4db1758cb..ae92b58c2 100644
--- a/src/ats-tests/ats-testing-experiment.c
+++ b/src/ats-tests/ats-testing-experiment.c
@@ -35,8 +35,10 @@ print_op (enum OperationType op)
35 return "START_SEND"; 35 return "START_SEND";
36 case STOP_SEND: 36 case STOP_SEND:
37 return "STOP_SEND"; 37 return "STOP_SEND";
38 case SET_PREFERENCE: 38 case START_PREFERENCE:
39 return "SET_PREFERENCE"; 39 return "START_PREFERENCE";
40 case STOP_PREFERENCE:
41 return "STOP_PREFERENCE";
40 default: 42 default:
41 break; 43 break;
42 } 44 }
@@ -93,6 +95,7 @@ load_episode (struct Experiment *e, struct Episode *cur,
93 char *op_name; 95 char *op_name;
94 char *op; 96 char *op;
95 char *type; 97 char *type;
98 char *pref;
96 int op_counter = 0; 99 int op_counter = 0;
97 fprintf (stderr, "Parsing episode %u\n",cur->id); 100 fprintf (stderr, "Parsing episode %u\n",cur->id);
98 GNUNET_asprintf(&sec_name, "episode-%u", cur->id); 101 GNUNET_asprintf(&sec_name, "episode-%u", cur->id);
@@ -117,9 +120,13 @@ load_episode (struct Experiment *e, struct Episode *cur,
117 { 120 {
118 o->type = STOP_SEND; 121 o->type = STOP_SEND;
119 } 122 }
120 else if (0 == strcmp (op, "set_preference")) 123 else if (0 == strcmp (op, "start_preference"))
121 { 124 {
122 o->type = SET_PREFERENCE; 125 o->type = START_PREFERENCE;
126 }
127 else if (0 == strcmp (op, "stop_preference"))
128 {
129 o->type = STOP_PREFERENCE;
123 } 130 }
124 else 131 else
125 { 132 {
@@ -176,7 +183,7 @@ load_episode (struct Experiment *e, struct Episode *cur,
176 GNUNET_asprintf(&op_name, "op-%u-type", op_counter); 183 GNUNET_asprintf(&op_name, "op-%u-type", op_counter);
177 if ( (GNUNET_SYSERR != GNUNET_CONFIGURATION_get_value_string(cfg, 184 if ( (GNUNET_SYSERR != GNUNET_CONFIGURATION_get_value_string(cfg,
178 sec_name, op_name, &type)) && 185 sec_name, op_name, &type)) &&
179 (STOP_SEND != o->type)) 186 ((STOP_SEND != o->type) || (STOP_PREFERENCE != o->type)))
180 { 187 {
181 /* Load arguments for set_rate, start_send, set_preference */ 188 /* Load arguments for set_rate, start_send, set_preference */
182 if (0 == strcmp (type, "constant")) 189 if (0 == strcmp (type, "constant"))
@@ -247,6 +254,55 @@ load_episode (struct Experiment *e, struct Episode *cur,
247 o->period = cur->duration; 254 o->period = cur->duration;
248 } 255 }
249 GNUNET_free (op_name); 256 GNUNET_free (op_name);
257
258 if (START_PREFERENCE == o->type)
259 {
260 /* Get frequency */
261 GNUNET_asprintf(&op_name, "op-%u-frequency", op_counter);
262 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_time (cfg,
263 sec_name, op_name, &o->frequency))
264 {
265 fprintf (stderr, "Missing frequency in operation %u `%s' in episode %u\n",
266 op_counter, op, cur->id);
267 GNUNET_free (type);
268 GNUNET_free (op_name);
269 GNUNET_free (op);
270 return GNUNET_SYSERR;
271 }
272 GNUNET_free (op_name);
273
274 /* Get preference */
275 GNUNET_asprintf(&op_name, "op-%u-pref", op_counter);
276 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string (cfg,
277 sec_name, op_name, &pref))
278 {
279 fprintf (stderr, "Missing preference in operation %u `%s' in episode %u\n",
280 op_counter, op, cur->id);
281 GNUNET_free (type);
282 GNUNET_free (op_name);
283 GNUNET_free (op);
284 GNUNET_free_non_null (pref);
285 return GNUNET_SYSERR;
286 }
287
288 if (0 == strcmp(pref, "bandwidth"))
289 o->pref_type = GNUNET_ATS_PREFERENCE_BANDWIDTH;
290 else if (0 == strcmp(pref, "latency"))
291 o->pref_type = GNUNET_ATS_PREFERENCE_LATENCY;
292 else
293 {
294 fprintf (stderr, "Invalid preference in operation %u `%s' in episode %u\n",
295 op_counter, op, cur->id);
296 GNUNET_free (type);
297 GNUNET_free (op_name);
298 GNUNET_free (op);
299 GNUNET_free (pref);
300 GNUNET_free_non_null (pref);
301 return GNUNET_SYSERR;
302 }
303 GNUNET_free (pref);
304 GNUNET_free (op_name);
305 }
250 } 306 }
251 307
252 /* Safety checks */ 308 /* Safety checks */
@@ -261,11 +317,15 @@ load_episode (struct Experiment *e, struct Episode *cur,
261 fprintf (stderr, "Selected max rate and base rate cannot be used for desired traffic form!\n"); 317 fprintf (stderr, "Selected max rate and base rate cannot be used for desired traffic form!\n");
262 } 318 }
263 319
264 fprintf (stderr, "Found operation %u in episode %u: %s [%llu]->[%llu] == %s, %llu -> %llu in %s\n", 320 if ((START_SEND == o->type) || (START_PREFERENCE == o->type))
321 fprintf (stderr, "Found operation %u in episode %u: %s [%llu]->[%llu] == %s, %llu -> %llu in %s\n",
265 op_counter, cur->id, print_op (o->type), o->src_id, 322 op_counter, cur->id, print_op (o->type), o->src_id,
266 o->dest_id, (NULL != type) ? type : "", 323 o->dest_id, (NULL != type) ? type : "",
267 o->base_rate, o->max_rate, 324 o->base_rate, o->max_rate,
268 GNUNET_STRINGS_relative_time_to_string (o->period, GNUNET_YES)); 325 GNUNET_STRINGS_relative_time_to_string (o->period, GNUNET_YES));
326 else
327 fprintf (stderr, "Found operation %u in episode %u: %s [%llu]->[%llu]\n",
328 op_counter, cur->id, print_op (o->type), o->src_id, o->dest_id);
269 329
270 GNUNET_free_non_null (type); 330 GNUNET_free_non_null (type);
271 GNUNET_free (op); 331 GNUNET_free (op);
@@ -396,7 +456,8 @@ enforce_stop_send (struct GNUNET_ATS_TEST_Operation *op)
396 456
397 if (NULL != p->tg) 457 if (NULL != p->tg)
398 { 458 {
399 fprintf (stderr, "Stopping traffic between master %llu slave %llu\n",op->src_id, op->dest_id); 459 fprintf (stderr, "Stopping traffic between master %llu slave %llu\n",
460 op->src_id, op->dest_id);
400 GNUNET_ATS_TEST_generate_traffic_stop(p->tg); 461 GNUNET_ATS_TEST_generate_traffic_stop(p->tg);
401 p->tg = NULL; 462 p->tg = NULL;
402 } 463 }
@@ -404,9 +465,60 @@ enforce_stop_send (struct GNUNET_ATS_TEST_Operation *op)
404 465
405 466
406static void 467static void
407enforce_set_preference (struct GNUNET_ATS_TEST_Operation *op) 468enforce_start_preference (struct GNUNET_ATS_TEST_Operation *op)
408{ 469{
409 GNUNET_break (0); 470 struct BenchmarkPeer *peer;
471 struct BenchmarkPartner *partner;
472
473 peer = GNUNET_ATS_TEST_get_peer (op->src_id);
474 if (NULL == peer)
475 {
476 GNUNET_break (0);
477 return;
478 }
479
480 partner = GNUNET_ATS_TEST_get_partner (op->src_id, op->dest_id);
481 if (NULL == partner)
482 {
483 GNUNET_break (0);
484 return;
485 }
486
487 fprintf (stderr, "Found master %llu slave %llu\n",op->src_id, op->dest_id);
488
489 if (NULL != partner->pg)
490 {
491 fprintf (stderr, "Stopping traffic between master %llu slave %llu\n",
492 op->src_id, op->dest_id);
493 GNUNET_ATS_TEST_generate_preferences_stop(partner->pg);
494 partner->pg = NULL;
495 }
496
497 partner->pg = GNUNET_ATS_TEST_generate_preferences_start(peer, partner,
498 op->tg_type, op->base_rate, op->max_rate, op->period, op->frequency,
499 op->pref_type);
500}
501
502static void
503enforce_stop_preference (struct GNUNET_ATS_TEST_Operation *op)
504{
505 struct BenchmarkPartner *p;
506 p = GNUNET_ATS_TEST_get_partner (op->src_id, op->dest_id);
507 if (NULL == p)
508 {
509 GNUNET_break (0);
510 return;
511 }
512
513 fprintf (stderr, "Found master %llu slave %llu\n",op->src_id, op->dest_id);
514
515 if (NULL != p->pg)
516 {
517 fprintf (stderr, "Stopping preference between master %llu slave %llu\n",
518 op->src_id, op->dest_id);
519 GNUNET_ATS_TEST_generate_preferences_stop (p->pg);
520 p->pg = NULL;
521 }
410} 522}
411 523
412static void enforce_episode (struct Episode *ep) 524static void enforce_episode (struct Episode *ep)
@@ -424,8 +536,11 @@ static void enforce_episode (struct Episode *ep)
424 case STOP_SEND: 536 case STOP_SEND:
425 enforce_stop_send (cur); 537 enforce_stop_send (cur);
426 break; 538 break;
427 case SET_PREFERENCE: 539 case START_PREFERENCE:
428 enforce_set_preference (cur); 540 enforce_start_preference (cur);
541 break;
542 case STOP_PREFERENCE:
543 enforce_stop_preference (cur);
429 break; 544 break;
430 default: 545 default:
431 break; 546 break;
diff --git a/src/ats-tests/ats-testing.h b/src/ats-tests/ats-testing.h
index e24f1dc53..15bf858f5 100644
--- a/src/ats-tests/ats-testing.h
+++ b/src/ats-tests/ats-testing.h
@@ -462,7 +462,8 @@ enum OperationType
462{ 462{
463 START_SEND, 463 START_SEND,
464 STOP_SEND, 464 STOP_SEND,
465 SET_PREFERENCE 465 START_PREFERENCE,
466 STOP_PREFERENCE
466}; 467};
467 468
468struct Episode; 469struct Episode;
@@ -489,9 +490,11 @@ struct GNUNET_ATS_TEST_Operation
489 long long unsigned int base_rate; 490 long long unsigned int base_rate;
490 long long unsigned int max_rate; 491 long long unsigned int max_rate;
491 struct GNUNET_TIME_Relative period; 492 struct GNUNET_TIME_Relative period;
493 struct GNUNET_TIME_Relative frequency;
492 494
493 enum OperationType type; 495 enum OperationType type;
494 enum GeneratorType tg_type; 496 enum GeneratorType tg_type;
497 enum GNUNET_ATS_PreferenceKind pref_type;
495}; 498};
496 499
497struct Episode 500struct Episode
diff --git a/src/ats-tests/experiments/test.exp b/src/ats-tests/experiments/test.exp
index c18871e7c..636139f89 100644
--- a/src/ats-tests/experiments/test.exp
+++ b/src/ats-tests/experiments/test.exp
@@ -2,12 +2,12 @@
2 name = test 2 name = test
3 masters = 1 3 masters = 1
4 slaves = 2 4 slaves = 2
5 max_duration = 10 s 5 max_duration = 15 s
6 log_freq = 100 ms 6 log_freq = 100 ms
7 cfg_file = gnunet_ats_sim_default.conf 7 cfg_file = gnunet_ats_sim_default.conf
8 8
9[episode-0] 9[episode-0]
10# operations = set_rate, start_send, stop_send, set_preference 10# operations = start_send, stop_send, start_preference, stop_preference
11duration = 10 s 11duration = 10 s
12op-0-operation = start_send 12op-0-operation = start_send
13op-0-src = 0 13op-0-src = 0
@@ -23,3 +23,33 @@ op-1-type = sinus
23op-1-period = 5 s 23op-1-period = 5 s
24op-1-base-rate= 10000 24op-1-base-rate= 10000
25op-1-max-rate = 15000 25op-1-max-rate = 15000
26
27op-2-operation = start_preference
28op-2-src = 0
29op-2-dest = 0
30op-2-type = constant
31op-2-period = 5 s
32op-2-base-rate= 10
33op-2-max-rate = 5
34op-2-pref = latency
35op-2-frequency = 2 s
36
37op-3-operation = start_preference
38op-3-src = 0
39op-3-dest = 1
40op-3-type = linear
41op-3-period = 5 s
42op-3-base-rate= 40
43op-3-max-rate = 50
44op-3-pref = bandwidth
45op-3-frequency = 750 ms
46
47[episode-1]
48duration = 5 s
49op-0-operation = stop_preference
50op-0-src = 0
51op-0-dest = 0
52
53op-1-operation = stop_preference
54op-1-src = 0
55op-1-dest = 1
diff --git a/src/ats-tests/gnunet-ats-sim.c b/src/ats-tests/gnunet-ats-sim.c
index 567fd7e50..0659af05d 100644
--- a/src/ats-tests/gnunet-ats-sim.c
+++ b/src/ats-tests/gnunet-ats-sim.c
@@ -257,12 +257,13 @@ static void topology_setup_done (void *cls,
257 GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 250), 257 GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 250),
258 GNUNET_ATS_PREFERENCE_BANDWIDTH); 258 GNUNET_ATS_PREFERENCE_BANDWIDTH);
259*/ 259*/
260 /*
260 GNUNET_ATS_TEST_generate_preferences_start(&masters[0],&masters[0].partners[0], 261 GNUNET_ATS_TEST_generate_preferences_start(&masters[0],&masters[0].partners[0],
261 GNUNET_ATS_TEST_TG_SINUS, 10, 5, 262 GNUNET_ATS_TEST_TG_SINUS, 10, 5,
262 GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 5), 263 GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 5),
263 GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 250), 264 GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 250),
264 GNUNET_ATS_PREFERENCE_BANDWIDTH); 265 GNUNET_ATS_PREFERENCE_BANDWIDTH);
265 266*/
266#if 0 267#if 0
267 int c_m; 268 int c_m;
268 int c_s; 269 int c_s;