aboutsummaryrefslogtreecommitdiff
path: root/src/ats-tests
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2014-02-03 12:36:25 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2014-02-03 12:36:25 +0000
commit23c87f2aea815cbd6078ab75b5b8fe8cf8f6ee31 (patch)
treeaf24b05a1b2f4a2829ee044b7e7c7161df6e9989 /src/ats-tests
parentc25e21e16f0079b94b4ee71240013e16b425240d (diff)
downloadgnunet-23c87f2aea815cbd6078ab75b5b8fe8cf8f6ee31.tar.gz
gnunet-23c87f2aea815cbd6078ab75b5b8fe8cf8f6ee31.zip
various fixes
Diffstat (limited to 'src/ats-tests')
-rw-r--r--src/ats-tests/ats-testing-experiment.c103
-rw-r--r--src/ats-tests/ats-testing-log.c1
-rw-r--r--src/ats-tests/ats-testing-traffic.c2
-rw-r--r--src/ats-tests/ats-testing.c20
-rw-r--r--src/ats-tests/ats-testing.h16
-rw-r--r--src/ats-tests/experiments/send_linear_10_sec.exp22
-rw-r--r--src/ats-tests/gnunet-ats-sim.c11
7 files changed, 133 insertions, 42 deletions
diff --git a/src/ats-tests/ats-testing-experiment.c b/src/ats-tests/ats-testing-experiment.c
index 80f30d9f0..764d7fb84 100644
--- a/src/ats-tests/ats-testing-experiment.c
+++ b/src/ats-tests/ats-testing-experiment.c
@@ -64,8 +64,8 @@ free_experiment (struct Experiment *e)
64{ 64{
65 struct Episode *cur; 65 struct Episode *cur;
66 struct Episode *next; 66 struct Episode *next;
67 struct Operation *cur_o; 67 struct GNUNET_ATS_TEST_Operation *cur_o;
68 struct Operation *next_o; 68 struct GNUNET_ATS_TEST_Operation *next_o;
69 69
70 next = e->start; 70 next = e->start;
71 for (cur = next; NULL != cur; cur = next) 71 for (cur = next; NULL != cur; cur = next)
@@ -90,7 +90,7 @@ static int
90load_episode (struct Experiment *e, struct Episode *cur, 90load_episode (struct Experiment *e, struct Episode *cur,
91 struct GNUNET_CONFIGURATION_Handle *cfg) 91 struct GNUNET_CONFIGURATION_Handle *cfg)
92{ 92{
93 struct Operation *o; 93 struct GNUNET_ATS_TEST_Operation *o;
94 char *sec_name; 94 char *sec_name;
95 char *op_name; 95 char *op_name;
96 char *op; 96 char *op;
@@ -106,9 +106,10 @@ load_episode (struct Experiment *e, struct Episode *cur,
106 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string(cfg, 106 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string(cfg,
107 sec_name, op_name, &op)) 107 sec_name, op_name, &op))
108 { 108 {
109 GNUNET_free (op_name);
109 break; 110 break;
110 } 111 }
111 o = GNUNET_new (struct Operation); 112 o = GNUNET_new (struct GNUNET_ATS_TEST_Operation);
112 /* operations = set_rate, start_send, stop_send, set_preference */ 113 /* operations = set_rate, start_send, stop_send, set_preference */
113 if (0 == strcmp (op, "start_send")) 114 if (0 == strcmp (op, "start_send"))
114 { 115 {
@@ -179,13 +180,9 @@ load_episode (struct Experiment *e, struct Episode *cur,
179 GNUNET_free (op_name); 180 GNUNET_free (op_name);
180 181
181 GNUNET_asprintf(&op_name, "op-%u-type", op_counter); 182 GNUNET_asprintf(&op_name, "op-%u-type", op_counter);
182 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string(cfg, 183 if ( (GNUNET_SYSERR != GNUNET_CONFIGURATION_get_value_string(cfg,
183 sec_name, op_name, &type)) 184 sec_name, op_name, &type)) &&
184 { 185 (STOP_SEND != o->type))
185 break;
186 }
187
188 if (STOP_SEND != o->type)
189 { 186 {
190 /* Load arguments for set_rate, start_send, set_preference */ 187 /* Load arguments for set_rate, start_send, set_preference */
191 if (0 == strcmp (type, "constant")) 188 if (0 == strcmp (type, "constant"))
@@ -208,6 +205,7 @@ load_episode (struct Experiment *e, struct Episode *cur,
208 { 205 {
209 fprintf (stderr, "Invalid type %u `%s' in episode %u\n", 206 fprintf (stderr, "Invalid type %u `%s' in episode %u\n",
210 op_counter, op, cur->id); 207 op_counter, op, cur->id);
208 GNUNET_free (type);
211 GNUNET_free (op); 209 GNUNET_free (op);
212 GNUNET_free (op_name); 210 GNUNET_free (op_name);
213 return GNUNET_SYSERR; 211 return GNUNET_SYSERR;
@@ -221,6 +219,7 @@ load_episode (struct Experiment *e, struct Episode *cur,
221 { 219 {
222 fprintf (stderr, "Missing base rate in operation %u `%s' in episode %u\n", 220 fprintf (stderr, "Missing base rate in operation %u `%s' in episode %u\n",
223 op_counter, op, cur->id); 221 op_counter, op, cur->id);
222 GNUNET_free (type);
224 GNUNET_free (op); 223 GNUNET_free (op);
225 GNUNET_free (op_name); 224 GNUNET_free (op_name);
226 return GNUNET_SYSERR; 225 return GNUNET_SYSERR;
@@ -238,22 +237,23 @@ load_episode (struct Experiment *e, struct Episode *cur,
238 { 237 {
239 fprintf (stderr, "Missing max rate in operation %u `%s' in episode %u\n", 238 fprintf (stderr, "Missing max rate in operation %u `%s' in episode %u\n",
240 op_counter, op, cur->id); 239 op_counter, op, cur->id);
240 GNUNET_free (type);
241 GNUNET_free (op_name);
241 GNUNET_free (op); 242 GNUNET_free (op);
242 return GNUNET_SYSERR; 243 return GNUNET_SYSERR;
243 } 244 }
244 } 245 }
245 GNUNET_free (op_name); 246 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))
247 { 252 {
248 /* Get period */ 253 o->period = cur->duration;
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 } 254 }
255 GNUNET_free (op_name);
256
257 } 257 }
258 258
259 /* Safety checks */ 259 /* Safety checks */
@@ -270,9 +270,13 @@ load_episode (struct Experiment *e, struct Episode *cur,
270 270
271 fprintf (stderr, "Found operation %u in episode %u: %s [%llu]->[%llu] == %s, %llu -> %llu in %s\n", 271 fprintf (stderr, "Found operation %u in episode %u: %s [%llu]->[%llu] == %s, %llu -> %llu in %s\n",
272 op_counter, cur->id, print_op (o->type), o->src_id, 272 op_counter, cur->id, print_op (o->type), o->src_id,
273 o->dest_id, type, o->base_rate, o->max_rate, 273 o->dest_id, (NULL != type) ? type : "",
274 o->base_rate, o->max_rate,
274 GNUNET_STRINGS_relative_time_to_string (o->period, GNUNET_YES)); 275 GNUNET_STRINGS_relative_time_to_string (o->period, GNUNET_YES));
275 276
277 GNUNET_free_non_null (type);
278 GNUNET_free (op);
279
276 GNUNET_CONTAINER_DLL_insert (cur->head,cur->tail, o); 280 GNUNET_CONTAINER_DLL_insert (cur->head,cur->tail, o);
277 op_counter++; 281 op_counter++;
278 } 282 }
@@ -351,32 +355,77 @@ timeout_experiment (void *cls, const struct GNUNET_SCHEDULER_TaskContext* tc)
351} 355}
352 356
353static void 357static void
354enforce_start_send (struct Operation *op) 358enforce_start_send (struct GNUNET_ATS_TEST_Operation *op)
355{ 359{
356 GNUNET_break (0); 360 GNUNET_break (0);
357} 361}
358 362
359static void 363static void
360enforce_stop_send (struct Operation *op) 364enforce_stop_send (struct GNUNET_ATS_TEST_Operation *op)
361{ 365{
362 GNUNET_break (0); 366 struct BenchmarkPartner *p;
367 p = GNUNET_ATS_TEST_get_partner (op->src_id, op->dest_id);
368 if (NULL == p)
369 {
370 GNUNET_break (0);
371 return;
372 }
373
374 fprintf (stderr, "Found master %llu slave %llu\n",op->src_id, op->dest_id);
375
376 if (NULL != p->tg)
377 {
378 fprintf (stderr, "Stopping traffic between master %llu slave %llu\n",op->src_id, op->dest_id);
379 GNUNET_ATS_TEST_generate_traffic_stop(p->tg);
380 p->tg = NULL;
381 }
382
383
363} 384}
364 385
365static void 386static void
366enforce_set_rate (struct Operation *op) 387enforce_set_rate (struct GNUNET_ATS_TEST_Operation *op)
367{ 388{
368 GNUNET_break (0); 389 struct BenchmarkPeer *peer;
390 struct BenchmarkPartner *partner;
391
392 peer = GNUNET_ATS_TEST_get_peer (op->src_id);
393 if (NULL == peer)
394 {
395 GNUNET_break (0);
396 return;
397 }
398
399 partner = GNUNET_ATS_TEST_get_partner (op->src_id, op->dest_id);
400 if (NULL == partner)
401 {
402 GNUNET_break (0);
403 return;
404 }
405
406 fprintf (stderr, "Found master %llu slave %llu\n",op->src_id, op->dest_id);
407
408 if (NULL != partner->tg)
409 {
410 fprintf (stderr, "Stopping traffic between master %llu slave %llu\n",op->src_id, op->dest_id);
411 GNUNET_ATS_TEST_generate_traffic_stop(partner->tg);
412 partner->tg = NULL;
413 }
414
415 partner->tg = GNUNET_ATS_TEST_generate_traffic_start(peer, partner,
416 op->tg_type, op->base_rate, op->max_rate, op->period,
417 GNUNET_TIME_UNIT_FOREVER_REL);
369} 418}
370 419
371static void 420static void
372enforce_set_preference (struct Operation *op) 421enforce_set_preference (struct GNUNET_ATS_TEST_Operation *op)
373{ 422{
374 GNUNET_break (0); 423 GNUNET_break (0);
375} 424}
376 425
377static void enforce_episode (struct Episode *ep) 426static void enforce_episode (struct Episode *ep)
378{ 427{
379 struct Operation *cur; 428 struct GNUNET_ATS_TEST_Operation *cur;
380 for (cur = ep->head; NULL != cur; cur = cur->next) 429 for (cur = ep->head; NULL != cur; cur = cur->next)
381 { 430 {
382 431
diff --git a/src/ats-tests/ats-testing-log.c b/src/ats-tests/ats-testing-log.c
index 01dc7148e..968ecc6cd 100644
--- a/src/ats-tests/ats-testing-log.c
+++ b/src/ats-tests/ats-testing-log.c
@@ -757,7 +757,6 @@ GNUNET_ATS_TEST_logging_stop (struct LoggingHandle *l)
757 GNUNET_SCHEDULER_cancel (l->log_task); 757 GNUNET_SCHEDULER_cancel (l->log_task);
758 l->log_task = GNUNET_SCHEDULER_NO_TASK; 758 l->log_task = GNUNET_SCHEDULER_NO_TASK;
759 tc.reason = GNUNET_SCHEDULER_REASON_SHUTDOWN; 759 tc.reason = GNUNET_SCHEDULER_REASON_SHUTDOWN;
760 collect_log_task (l, &tc);
761 l->running = GNUNET_NO; 760 l->running = GNUNET_NO;
762 761
763 GNUNET_log(GNUNET_ERROR_TYPE_INFO, 762 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
diff --git a/src/ats-tests/ats-testing-traffic.c b/src/ats-tests/ats-testing-traffic.c
index 0938f79f4..c3eaf4959 100644
--- a/src/ats-tests/ats-testing-traffic.c
+++ b/src/ats-tests/ats-testing-traffic.c
@@ -329,7 +329,7 @@ GNUNET_ATS_TEST_generate_traffic_start (struct BenchmarkPeer *src,
329 tg->time_start = GNUNET_TIME_absolute_get(); 329 tg->time_start = GNUNET_TIME_absolute_get();
330 tg->next_ping_transmission = GNUNET_TIME_UNIT_FOREVER_ABS; 330 tg->next_ping_transmission = GNUNET_TIME_UNIT_FOREVER_ABS;
331 331
332 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 332 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
333 "Setting up traffic generator master[%u] `%s' and slave [%u] `%s' max %u Bips\n", 333 "Setting up traffic generator master[%u] `%s' and slave [%u] `%s' max %u Bips\n",
334 dest->me->no, GNUNET_i2s (&dest->me->id), 334 dest->me->no, GNUNET_i2s (&dest->me->id),
335 dest->dest->no, GNUNET_i2s (&dest->dest->id), 335 dest->dest->no, GNUNET_i2s (&dest->dest->id),
diff --git a/src/ats-tests/ats-testing.c b/src/ats-tests/ats-testing.c
index 381dd7bb6..4639b29e6 100644
--- a/src/ats-tests/ats-testing.c
+++ b/src/ats-tests/ats-testing.c
@@ -836,6 +836,23 @@ controller_event_cb (void *cls,
836 } 836 }
837} 837}
838 838
839struct BenchmarkPeer *
840GNUNET_ATS_TEST_get_peer (int src)
841{
842 if (src > top->num_masters)
843 return NULL;
844 return &top->mps[src];
845}
846
847struct BenchmarkPartner *
848GNUNET_ATS_TEST_get_partner (int src, int dest)
849{
850 if (src > top->num_masters)
851 return NULL;
852 if (dest > top->num_slaves)
853 return NULL;
854 return &top->mps[src].partners[dest];
855}
839 856
840/** 857/**
841 * Create a topology for ats testing 858 * Create a topology for ats testing
@@ -898,6 +915,9 @@ GNUNET_ATS_TEST_shutdown_topology (void)
898 if (NULL == top) 915 if (NULL == top)
899 return; 916 return;
900 917
918 GNUNET_free (top->mps);
919 GNUNET_free (top->sps);
920
901 GNUNET_SCHEDULER_shutdown(); 921 GNUNET_SCHEDULER_shutdown();
902} 922}
903 923
diff --git a/src/ats-tests/ats-testing.h b/src/ats-tests/ats-testing.h
index 56e114bf5..d620b7a06 100644
--- a/src/ats-tests/ats-testing.h
+++ b/src/ats-tests/ats-testing.h
@@ -456,10 +456,10 @@ typedef void (*GNUNET_ATS_TESTING_ExperimentDoneCallback) (struct Experiment *e,
456/** 456/**
457 * An operation in an experiment 457 * An operation in an experiment
458 */ 458 */
459struct Operation 459struct GNUNET_ATS_TEST_Operation
460{ 460{
461 struct Operation *next; 461 struct GNUNET_ATS_TEST_Operation *next;
462 struct Operation *prev; 462 struct GNUNET_ATS_TEST_Operation *prev;
463 463
464 long long unsigned int src_id; 464 long long unsigned int src_id;
465 long long unsigned int dest_id; 465 long long unsigned int dest_id;
@@ -478,8 +478,8 @@ struct Episode
478 struct Episode *next; 478 struct Episode *next;
479 struct GNUNET_TIME_Relative duration; 479 struct GNUNET_TIME_Relative duration;
480 480
481 struct Operation *head; 481 struct GNUNET_ATS_TEST_Operation *head;
482 struct Operation *tail; 482 struct GNUNET_ATS_TEST_Operation *tail;
483}; 483};
484 484
485 485
@@ -640,6 +640,12 @@ GNUNET_ATS_TEST_logging_write_to_file (struct LoggingHandle *l,
640 * Topology related functions 640 * Topology related functions
641 */ 641 */
642 642
643struct BenchmarkPeer *
644GNUNET_ATS_TEST_get_peer (int src);
645
646struct BenchmarkPartner *
647GNUNET_ATS_TEST_get_partner (int src, int dest);
648
643/** 649/**
644 * Create a topology for ats testing 650 * Create a topology for ats testing
645 * 651 *
diff --git a/src/ats-tests/experiments/send_linear_10_sec.exp b/src/ats-tests/experiments/send_linear_10_sec.exp
index 763fb6247..efd2c7b08 100644
--- a/src/ats-tests/experiments/send_linear_10_sec.exp
+++ b/src/ats-tests/experiments/send_linear_10_sec.exp
@@ -2,23 +2,29 @@
2 name = test 2 name = test
3 masters = 1 3 masters = 1
4 slaves = 3 4 slaves = 3
5 max_duration = 10 s 5 max_duration = 2 s
6 cfg_file = gnunet_ats_sim_default.conf 6 cfg_file = gnunet_ats_sim_default.conf
7 7
8[episode-0] 8[episode-0]
9# operations = set_rate, start_send, stop_send, set_preference 9# operations = set_rate, start_send, stop_send, set_preference
10duration = 10 s 10duration = 2 s
11op-0-operation = set_rate 11op-0-operation = set_rate
12op-0-value = 10000
13op-0-src = 0 12op-0-src = 0
14op-0-dest = 1 13op-0-dest = 0
14op-0-type = constant
15op-0-base-rate= 10000
16op-0-max-rate = 10000
15 17
16op-1-operation = set_rate 18op-1-operation = set_rate
17op-1-value = 10000
18op-1-src = 0 19op-1-src = 0
19op-1-dest = 2 20op-1-dest = 1
21op-1-type = constant
22op-1-base-rate= 10000
23op-1-max-rate = 10000
20 24
21op-2-operation = set_rate 25op-2-operation = set_rate
22op-2-value = 10000
23op-2-src = 0 26op-2-src = 0
24op-2-dest = 3 \ No newline at end of file 27op-2-dest = 2
28op-2-type = constant
29op-2-base-rate= 10000
30op-2-max-rate = 10000 \ No newline at end of file
diff --git a/src/ats-tests/gnunet-ats-sim.c b/src/ats-tests/gnunet-ats-sim.c
index 7ed667d23..02bb65776 100644
--- a/src/ats-tests/gnunet-ats-sim.c
+++ b/src/ats-tests/gnunet-ats-sim.c
@@ -123,12 +123,21 @@ evaluate (struct GNUNET_TIME_Relative duration_total)
123static void 123static void
124do_shutdown () 124do_shutdown ()
125{ 125{
126 fprintf (stderr, "Shutdown\n");
126 /* timeout */ 127 /* timeout */
128 if (NULL != l)
129 {
130 GNUNET_ATS_TEST_logging_stop (l);
131 GNUNET_ATS_TEST_logging_clean_up (l);
132 l = NULL;
133 }
127 if (NULL != e) 134 if (NULL != e)
128 { 135 {
136 GNUNET_break (0);
129 GNUNET_ATS_TEST_experimentation_stop (e); 137 GNUNET_ATS_TEST_experimentation_stop (e);
130 e = NULL; 138 e = NULL;
131 } 139 }
140 GNUNET_break (0);
132 GNUNET_ATS_TEST_shutdown_topology (); 141 GNUNET_ATS_TEST_shutdown_topology ();
133} 142}
134 143
@@ -237,6 +246,7 @@ static void topology_setup_done (void *cls,
237 */ 246 */
238 /* Example: Generate traffic with a sinus form, a base rate of 247 /* Example: Generate traffic with a sinus form, a base rate of
239 * 1000 Bytes/s, an amplitude of (max-base), and a period of 1 minute */ 248 * 1000 Bytes/s, an amplitude of (max-base), and a period of 1 minute */
249 /*
240 GNUNET_ATS_TEST_generate_traffic_start (&masters[c_m], 250 GNUNET_ATS_TEST_generate_traffic_start (&masters[c_m],
241 &masters[c_m].partners[c_s], 251 &masters[c_m].partners[c_s],
242 GNUNET_ATS_TEST_TG_SINUS, 252 GNUNET_ATS_TEST_TG_SINUS,
@@ -244,6 +254,7 @@ static void topology_setup_done (void *cls,
244 2000, 254 2000,
245 GNUNET_TIME_UNIT_MINUTES, 255 GNUNET_TIME_UNIT_MINUTES,
246 GNUNET_TIME_UNIT_FOREVER_REL); 256 GNUNET_TIME_UNIT_FOREVER_REL);
257 */
247 } 258 }
248 } 259 }
249 260