aboutsummaryrefslogtreecommitdiff
path: root/src/ats-tests
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2014-02-03 14:08:48 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2014-02-03 14:08:48 +0000
commitda30ec65a28e5ec08dc9b1b7e35927a0571a4164 (patch)
treea7ce083cb7ae8fccc5a6928eaf041c9ea29ac076 /src/ats-tests
parent54e443c4dddcd4ff8aff4fd764e4c7c010ec917e (diff)
downloadgnunet-da30ec65a28e5ec08dc9b1b7e35927a0571a4164.tar.gz
gnunet-da30ec65a28e5ec08dc9b1b7e35927a0571a4164.zip
removing set_rate, using start_send instead
Diffstat (limited to 'src/ats-tests')
-rw-r--r--src/ats-tests/ats-testing-experiment.c61
-rw-r--r--src/ats-tests/ats-testing-traffic.c61
-rw-r--r--src/ats-tests/ats-testing.h1
-rw-r--r--src/ats-tests/gnunet-ats-sim.c20
4 files changed, 79 insertions, 64 deletions
diff --git a/src/ats-tests/ats-testing-experiment.c b/src/ats-tests/ats-testing-experiment.c
index 3d19c739f..8471733d6 100644
--- a/src/ats-tests/ats-testing-experiment.c
+++ b/src/ats-tests/ats-testing-experiment.c
@@ -35,8 +35,6 @@ 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_RATE:
39 return "SET_RATE";
40 case SET_PREFERENCE: 38 case SET_PREFERENCE:
41 return "SET_PREFERENCE"; 39 return "SET_PREFERENCE";
42 default: 40 default:
@@ -119,10 +117,6 @@ load_episode (struct Experiment *e, struct Episode *cur,
119 { 117 {
120 o->type = STOP_SEND; 118 o->type = STOP_SEND;
121 } 119 }
122 else if (0 == strcmp (op, "set_rate"))
123 {
124 o->type = SET_RATE;
125 }
126 else if (0 == strcmp (op, "set_preference")) 120 else if (0 == strcmp (op, "set_preference"))
127 { 121 {
128 o->type = SET_PREFERENCE; 122 o->type = SET_PREFERENCE;
@@ -253,7 +247,6 @@ load_episode (struct Experiment *e, struct Episode *cur,
253 o->period = cur->duration; 247 o->period = cur->duration;
254 } 248 }
255 GNUNET_free (op_name); 249 GNUNET_free (op_name);
256
257 } 250 }
258 251
259 /* Safety checks */ 252 /* Safety checks */
@@ -357,35 +350,6 @@ timeout_experiment (void *cls, const struct GNUNET_SCHEDULER_TaskContext* tc)
357static void 350static void
358enforce_start_send (struct GNUNET_ATS_TEST_Operation *op) 351enforce_start_send (struct GNUNET_ATS_TEST_Operation *op)
359{ 352{
360 GNUNET_break (0);
361}
362
363static void
364enforce_stop_send (struct GNUNET_ATS_TEST_Operation *op)
365{
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
384}
385
386static void
387enforce_set_rate (struct GNUNET_ATS_TEST_Operation *op)
388{
389 struct BenchmarkPeer *peer; 353 struct BenchmarkPeer *peer;
390 struct BenchmarkPartner *partner; 354 struct BenchmarkPartner *partner;
391 355
@@ -418,6 +382,28 @@ enforce_set_rate (struct GNUNET_ATS_TEST_Operation *op)
418} 382}
419 383
420static void 384static void
385enforce_stop_send (struct GNUNET_ATS_TEST_Operation *op)
386{
387 struct BenchmarkPartner *p;
388 p = GNUNET_ATS_TEST_get_partner (op->src_id, op->dest_id);
389 if (NULL == p)
390 {
391 GNUNET_break (0);
392 return;
393 }
394
395 fprintf (stderr, "Found master %llu slave %llu\n",op->src_id, op->dest_id);
396
397 if (NULL != p->tg)
398 {
399 fprintf (stderr, "Stopping traffic between master %llu slave %llu\n",op->src_id, op->dest_id);
400 GNUNET_ATS_TEST_generate_traffic_stop(p->tg);
401 p->tg = NULL;
402 }
403}
404
405
406static void
421enforce_set_preference (struct GNUNET_ATS_TEST_Operation *op) 407enforce_set_preference (struct GNUNET_ATS_TEST_Operation *op)
422{ 408{
423 GNUNET_break (0); 409 GNUNET_break (0);
@@ -438,9 +424,6 @@ static void enforce_episode (struct Episode *ep)
438 case STOP_SEND: 424 case STOP_SEND:
439 enforce_stop_send (cur); 425 enforce_stop_send (cur);
440 break; 426 break;
441 case SET_RATE:
442 enforce_set_rate (cur);
443 break;
444 case SET_PREFERENCE: 427 case SET_PREFERENCE:
445 enforce_set_preference (cur); 428 enforce_set_preference (cur);
446 break; 429 break;
diff --git a/src/ats-tests/ats-testing-traffic.c b/src/ats-tests/ats-testing-traffic.c
index c3eaf4959..fc3de791c 100644
--- a/src/ats-tests/ats-testing-traffic.c
+++ b/src/ats-tests/ats-testing-traffic.c
@@ -48,7 +48,6 @@ get_delay (struct TrafficGenerator *tg)
48 if (UINT32_MAX == tg->base_rate) 48 if (UINT32_MAX == tg->base_rate)
49 return GNUNET_TIME_UNIT_ZERO; 49 return GNUNET_TIME_UNIT_ZERO;
50 cur_rate = tg->base_rate; 50 cur_rate = tg->base_rate;
51 return delay;
52 break; 51 break;
53 case GNUNET_ATS_TEST_TG_LINEAR: 52 case GNUNET_ATS_TEST_TG_LINEAR:
54 time_delta = GNUNET_TIME_absolute_get_duration(tg->time_start); 53 time_delta = GNUNET_TIME_absolute_get_duration(tg->time_start);
@@ -56,7 +55,7 @@ get_delay (struct TrafficGenerator *tg)
56 time_delta.rel_value_us = time_delta.rel_value_us % tg->duration_period.rel_value_us; 55 time_delta.rel_value_us = time_delta.rel_value_us % tg->duration_period.rel_value_us;
57 delta_rate = ((double) time_delta.rel_value_us / tg->duration_period.rel_value_us) * 56 delta_rate = ((double) time_delta.rel_value_us / tg->duration_period.rel_value_us) *
58 (tg->max_rate - tg->base_rate); 57 (tg->max_rate - tg->base_rate);
59 if ((tg->max_rate - tg->base_rate) > tg->base_rate) 58 if ((tg->max_rate < tg->base_rate) && ((tg->max_rate - tg->base_rate) > tg->base_rate))
60 { 59 {
61 /* This will cause an underflow */ 60 /* This will cause an underflow */
62 GNUNET_break (0); 61 GNUNET_break (0);
@@ -88,9 +87,8 @@ get_delay (struct TrafficGenerator *tg)
88 87
89 if (cur_rate < 0) 88 if (cur_rate < 0)
90 { 89 {
91 cur_rate = 0; 90 cur_rate = 1;
92 } 91 }
93
94 /* Calculate the delay for the next message based on the current delay */ 92 /* Calculate the delay for the next message based on the current delay */
95 delay.rel_value_us = GNUNET_TIME_UNIT_SECONDS.rel_value_us * TEST_MESSAGE_SIZE / cur_rate; 93 delay.rel_value_us = GNUNET_TIME_UNIT_SECONDS.rel_value_us * TEST_MESSAGE_SIZE / cur_rate;
96 94
@@ -157,9 +155,9 @@ send_ping_ready_cb (void *cls, size_t size, void *buf)
157 return TEST_MESSAGE_SIZE; 155 return TEST_MESSAGE_SIZE;
158 } 156 }
159 delay = get_delay (p->tg); 157 delay = get_delay (p->tg);
160 /* 158
161 fprintf (stderr, "Delay for next transmission %llu ms\n", 159 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Delay for next transmission %llu ms\n",
162 (long long unsigned int) delay.rel_value_us / 1000);*/ 160 (long long unsigned int) delay.rel_value_us / 1000);
163 p->tg->next_ping_transmission = GNUNET_TIME_absolute_add(GNUNET_TIME_absolute_get(), 161 p->tg->next_ping_transmission = GNUNET_TIME_absolute_add(GNUNET_TIME_absolute_get(),
164 delay); 162 delay);
165 163
@@ -225,7 +223,7 @@ comm_send_pong_ready (void *cls, size_t size, void *buf)
225void 223void
226GNUNET_ATS_TEST_traffic_handle_ping (struct BenchmarkPartner *p) 224GNUNET_ATS_TEST_traffic_handle_ping (struct BenchmarkPartner *p)
227{ 225{
228 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 226 GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
229 "Slave [%u]: Received PING from [%u], sending PONG\n", p->me->no, 227 "Slave [%u]: Received PING from [%u], sending PONG\n", p->me->no,
230 p->dest->no); 228 p->dest->no);
231 229
@@ -259,7 +257,7 @@ void
259GNUNET_ATS_TEST_traffic_handle_pong (struct BenchmarkPartner *p) 257GNUNET_ATS_TEST_traffic_handle_pong (struct BenchmarkPartner *p)
260{ 258{
261 struct GNUNET_TIME_Relative left; 259 struct GNUNET_TIME_Relative left;
262 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 260 GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
263 "Master [%u]: Received PONG from [%u], next message\n", p->me->no, 261 "Master [%u]: Received PONG from [%u], next message\n", p->me->no,
264 p->dest->no); 262 p->dest->no);
265 263
@@ -271,6 +269,9 @@ GNUNET_ATS_TEST_traffic_handle_pong (struct BenchmarkPartner *p)
271 GNUNET_TIME_absolute_get()).rel_value_us; 269 GNUNET_TIME_absolute_get()).rel_value_us;
272 270
273 /* Schedule next send event */ 271 /* Schedule next send event */
272 if (NULL == p->tg)
273 return;
274
274 left = GNUNET_TIME_absolute_get_remaining(p->tg->next_ping_transmission); 275 left = GNUNET_TIME_absolute_get_remaining(p->tg->next_ping_transmission);
275 if (UINT32_MAX == p->tg->base_rate) 276 if (UINT32_MAX == p->tg->base_rate)
276 { 277 {
@@ -282,6 +283,11 @@ GNUNET_ATS_TEST_traffic_handle_pong (struct BenchmarkPartner *p)
282 } 283 }
283 else 284 else
284 { 285 {
286 /* Enforce minimum transmission rate 1 msg / sec */
287 if (GNUNET_TIME_UNIT_SECONDS.rel_value_us == (left = GNUNET_TIME_relative_min (left, GNUNET_TIME_UNIT_SECONDS)).rel_value_us)
288 GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
289 "Enforcing minimum send rate between master [%u] and slave [%u]\n",
290 p->me->no, p->dest->no);
285 p->tg->send_task = GNUNET_SCHEDULER_add_delayed (left, 291 p->tg->send_task = GNUNET_SCHEDULER_add_delayed (left,
286 &comm_schedule_send, p); 292 &comm_schedule_send, p);
287 } 293 }
@@ -329,11 +335,38 @@ GNUNET_ATS_TEST_generate_traffic_start (struct BenchmarkPeer *src,
329 tg->time_start = GNUNET_TIME_absolute_get(); 335 tg->time_start = GNUNET_TIME_absolute_get();
330 tg->next_ping_transmission = GNUNET_TIME_UNIT_FOREVER_ABS; 336 tg->next_ping_transmission = GNUNET_TIME_UNIT_FOREVER_ABS;
331 337
332 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 338 switch (type) {
333 "Setting up traffic generator master[%u] `%s' and slave [%u] `%s' max %u Bips\n", 339 case GNUNET_ATS_TEST_TG_CONSTANT:
334 dest->me->no, GNUNET_i2s (&dest->me->id), 340 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
335 dest->dest->no, GNUNET_i2s (&dest->dest->id), 341 "Setting up constant traffic generator master[%u] `%s' and slave [%u] `%s' max %u Bips\n",
336 base_rate); 342 dest->me->no, GNUNET_i2s (&dest->me->id),
343 dest->dest->no, GNUNET_i2s (&dest->dest->id),
344 base_rate);
345 break;
346 case GNUNET_ATS_TEST_TG_LINEAR:
347 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
348 "Setting up linear traffic generator master[%u] `%s' and slave [%u] `%s' min %u Bips max %u Bips\n",
349 dest->me->no, GNUNET_i2s (&dest->me->id),
350 dest->dest->no, GNUNET_i2s (&dest->dest->id),
351 base_rate, max_rate);
352 break;
353 case GNUNET_ATS_TEST_TG_SINUS:
354 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
355 "Setting up sinus traffic generator master[%u] `%s' and slave [%u] `%s' baserate %u Bips, amplitude %u Bps\n",
356 dest->me->no, GNUNET_i2s (&dest->me->id),
357 dest->dest->no, GNUNET_i2s (&dest->dest->id),
358 base_rate, max_rate);
359 break;
360 case GNUNET_ATS_TEST_TG_RANDOM:
361 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
362 "Setting up random traffic generator master[%u] `%s' and slave [%u] `%s' min %u Bips max %u Bps\n",
363 dest->me->no, GNUNET_i2s (&dest->me->id),
364 dest->dest->no, GNUNET_i2s (&dest->dest->id),
365 base_rate, max_rate);
366 break;
367 default:
368 break;
369 }
337 370
338 if ( ((GNUNET_YES == top->test_core) && (NULL != dest->cth)) || 371 if ( ((GNUNET_YES == top->test_core) && (NULL != dest->cth)) ||
339 ((GNUNET_NO == top->test_core) && (NULL != dest->tth)) ) 372 ((GNUNET_NO == top->test_core) && (NULL != dest->tth)) )
diff --git a/src/ats-tests/ats-testing.h b/src/ats-tests/ats-testing.h
index d620b7a06..238e1b005 100644
--- a/src/ats-tests/ats-testing.h
+++ b/src/ats-tests/ats-testing.h
@@ -439,7 +439,6 @@ enum OperationType
439{ 439{
440 START_SEND, 440 START_SEND,
441 STOP_SEND, 441 STOP_SEND,
442 SET_RATE,
443 SET_PREFERENCE 442 SET_PREFERENCE
444}; 443};
445 444
diff --git a/src/ats-tests/gnunet-ats-sim.c b/src/ats-tests/gnunet-ats-sim.c
index a06bbc172..c47e760c8 100644
--- a/src/ats-tests/gnunet-ats-sim.c
+++ b/src/ats-tests/gnunet-ats-sim.c
@@ -66,9 +66,9 @@ evaluate (struct GNUNET_TIME_Relative duration_total)
66 struct BenchmarkPeer *mp; 66 struct BenchmarkPeer *mp;
67 struct BenchmarkPartner *p; 67 struct BenchmarkPartner *p;
68 68
69 unsigned int kb_sent_sec; 69 unsigned int b_sent_sec;
70 double kb_sent_percent; 70 double kb_sent_percent;
71 unsigned int kb_recv_sec; 71 unsigned int b_recv_sec;
72 double kb_recv_percent; 72 double kb_recv_percent;
73 unsigned int rtt; 73 unsigned int rtt;
74 74
@@ -88,16 +88,16 @@ evaluate (struct GNUNET_TIME_Relative duration_total)
88 { 88 {
89 p = &mp->partners[c_s]; 89 p = &mp->partners[c_s];
90 90
91 kb_sent_sec = 0; 91 b_sent_sec = 0;
92 kb_recv_sec = 0; 92 b_recv_sec = 0;
93 kb_sent_percent = 0.0; 93 kb_sent_percent = 0.0;
94 kb_recv_percent = 0.0; 94 kb_recv_percent = 0.0;
95 rtt = 0; 95 rtt = 0;
96 96
97 if (duration > 0) 97 if (duration > 0)
98 { 98 {
99 kb_sent_sec = (p->bytes_sent / 1024) / duration; 99 b_sent_sec = p->bytes_sent / duration;
100 kb_recv_sec = (p->bytes_received / 1024) / duration; 100 b_recv_sec = p->bytes_received / duration;
101 } 101 }
102 102
103 if (mp->total_bytes_sent > 0) 103 if (mp->total_bytes_sent > 0)
@@ -107,11 +107,11 @@ evaluate (struct GNUNET_TIME_Relative duration_total)
107 if (1000 * p->messages_sent > 0) 107 if (1000 * p->messages_sent > 0)
108 rtt = p->total_app_rtt / (1000 * p->messages_sent); 108 rtt = p->total_app_rtt / (1000 * p->messages_sent);
109 fprintf (stderr, 109 fprintf (stderr,
110 "%c Master [%u] -> Slave [%u]: sent %u KiB/s (%.2f %%), received %u KiB/s (%.2f %%)\n", 110 "%c Master [%u] -> Slave [%u]: sent %u Bips (%.2f %%), received %u Bips (%.2f %%)\n",
111 (mp->pref_partner == p->dest) ? '*' : ' ', 111 (mp->pref_partner == p->dest) ? '*' : ' ',
112 mp->no, p->dest->no, 112 mp->no, p->dest->no,
113 kb_sent_sec, kb_sent_percent, 113 b_sent_sec, kb_sent_percent,
114 kb_recv_sec, kb_recv_percent); 114 b_recv_sec, kb_recv_percent);
115 fprintf (stderr, 115 fprintf (stderr,
116 "%c Master [%u] -> Slave [%u]: Average application layer RTT: %u ms\n", 116 "%c Master [%u] -> Slave [%u]: Average application layer RTT: %u ms\n",
117 (mp->pref_partner == p->dest) ? '*' : ' ', 117 (mp->pref_partner == p->dest) ? '*' : ' ',
@@ -213,7 +213,7 @@ static void topology_setup_done (void *cls,
213 masters_p = masters; 213 masters_p = masters;
214 slaves_p = slaves; 214 slaves_p = slaves;
215 215
216 l = GNUNET_ATS_TEST_logging_start (GNUNET_TIME_UNIT_SECONDS, 216 l = GNUNET_ATS_TEST_logging_start (GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 100),
217 e->name, 217 e->name,
218 masters_p, 218 masters_p,
219 e->num_masters); 219 e->num_masters);