diff options
-rw-r--r-- | src/ats-tests/Makefile.am | 3 | ||||
-rw-r--r-- | src/ats-tests/ats-testing.c | 387 | ||||
-rw-r--r-- | src/ats-tests/ats-testing.h | 165 | ||||
-rw-r--r-- | src/ats-tests/gnunet-ats-sim.c | 8 | ||||
-rw-r--r-- | src/ats-tests/gnunet_ats_sim_default.conf | 6 |
5 files changed, 185 insertions, 384 deletions
diff --git a/src/ats-tests/Makefile.am b/src/ats-tests/Makefile.am index abb0988fc..5753abea1 100644 --- a/src/ats-tests/Makefile.am +++ b/src/ats-tests/Makefile.am | |||
@@ -52,7 +52,7 @@ noinst_PROGRAMS = \ | |||
52 | gnunet-ats-sim | 52 | gnunet-ats-sim |
53 | 53 | ||
54 | libgnunetatstesting_la_SOURCES = \ | 54 | libgnunetatstesting_la_SOURCES = \ |
55 | ats-testing.c ats-testing-log.c ats-testing.h | 55 | ats-testing.c ats-testing-log.c ats-testing-traffic.c ats-testing.h |
56 | libgnunetatstesting_la_LIBADD = \ | 56 | libgnunetatstesting_la_LIBADD = \ |
57 | $(top_builddir)/src/transport/libgnunettransport.la \ | 57 | $(top_builddir)/src/transport/libgnunettransport.la \ |
58 | $(top_builddir)/src/hello/libgnunethello.la \ | 58 | $(top_builddir)/src/hello/libgnunethello.la \ |
@@ -316,6 +316,7 @@ perf_ats_ril_transport_latency_DEPENDENCIES = \ | |||
316 | $(top_builddir)/src/util/libgnunetutil.la | 316 | $(top_builddir)/src/util/libgnunetutil.la |
317 | 317 | ||
318 | EXTRA_DIST = \ | 318 | EXTRA_DIST = \ |
319 | gnunet_ats_sim_default.conf \ | ||
319 | perf_ats_proportional_none.conf \ | 320 | perf_ats_proportional_none.conf \ |
320 | perf_ats_proportional_bandwidth.conf \ | 321 | perf_ats_proportional_bandwidth.conf \ |
321 | perf_ats_proportional_latency.conf \ | 322 | perf_ats_proportional_latency.conf \ |
diff --git a/src/ats-tests/ats-testing.c b/src/ats-tests/ats-testing.c index 8ed1164b3..3d090c237 100644 --- a/src/ats-tests/ats-testing.c +++ b/src/ats-tests/ats-testing.c | |||
@@ -26,39 +26,6 @@ | |||
26 | */ | 26 | */ |
27 | #include "ats-testing.h" | 27 | #include "ats-testing.h" |
28 | 28 | ||
29 | /** | ||
30 | * Overall state of the performance benchmark | ||
31 | */ | ||
32 | struct BenchmarkState | ||
33 | { | ||
34 | /** | ||
35 | * Are we connected to ATS service of all peers: GNUNET_YES/NO | ||
36 | */ | ||
37 | int connected_ATS_service; | ||
38 | |||
39 | /** | ||
40 | * Are we connected to CORE service of all peers: GNUNET_YES/NO | ||
41 | */ | ||
42 | int connected_COMM_service; | ||
43 | |||
44 | /** | ||
45 | * Are we connected to all peers: GNUNET_YES/NO | ||
46 | */ | ||
47 | int connected_PEERS; | ||
48 | |||
49 | /** | ||
50 | * Are we connected to all slave peers on CORE level: GNUNET_YES/NO | ||
51 | */ | ||
52 | int connected_CORE; | ||
53 | |||
54 | /** | ||
55 | * Are we connected to CORE service of all peers: GNUNET_YES/NO | ||
56 | */ | ||
57 | int benchmarking; | ||
58 | }; | ||
59 | |||
60 | |||
61 | |||
62 | 29 | ||
63 | /** | 30 | /** |
64 | * Connect peers with testbed | 31 | * Connect peers with testbed |
@@ -81,115 +48,8 @@ struct TestbedConnectOperation | |||
81 | struct GNUNET_TESTBED_Operation *connect_op; | 48 | struct GNUNET_TESTBED_Operation *connect_op; |
82 | }; | 49 | }; |
83 | 50 | ||
84 | struct GNUNET_ATS_TEST_Topology | ||
85 | { | ||
86 | /** | ||
87 | * Shutdown task | ||
88 | */ | ||
89 | GNUNET_SCHEDULER_TaskIdentifier shutdown_task; | ||
90 | |||
91 | /** | ||
92 | * Progress task | ||
93 | */ | ||
94 | GNUNET_SCHEDULER_TaskIdentifier progress_task; | ||
95 | 51 | ||
96 | /** | 52 | struct GNUNET_ATS_TEST_Topology *top; |
97 | * Test result | ||
98 | */ | ||
99 | int result; | ||
100 | |||
101 | /** | ||
102 | * Test result logging | ||
103 | */ | ||
104 | int logging; | ||
105 | |||
106 | /**Test core (GNUNET_YES) or transport (GNUNET_NO) | ||
107 | */ | ||
108 | int test_core; | ||
109 | |||
110 | /** | ||
111 | * Solver string | ||
112 | */ | ||
113 | char *solver; | ||
114 | |||
115 | /** | ||
116 | * Preference string | ||
117 | */ | ||
118 | char *testname; | ||
119 | |||
120 | /** | ||
121 | * Preference string | ||
122 | */ | ||
123 | char *pref_str; | ||
124 | |||
125 | /** | ||
126 | * ATS preference value | ||
127 | */ | ||
128 | int pref_val; | ||
129 | |||
130 | /** | ||
131 | * Number master peers | ||
132 | */ | ||
133 | unsigned int num_masters; | ||
134 | |||
135 | /** | ||
136 | * Array of master peers | ||
137 | */ | ||
138 | struct BenchmarkPeer *mps; | ||
139 | |||
140 | /** | ||
141 | * Number slave peers | ||
142 | */ | ||
143 | unsigned int num_slaves; | ||
144 | |||
145 | /** | ||
146 | * Array of slave peers | ||
147 | */ | ||
148 | struct BenchmarkPeer *sps; | ||
149 | |||
150 | /** | ||
151 | * Benchmark duration | ||
152 | */ | ||
153 | struct GNUNET_TIME_Relative perf_duration; | ||
154 | |||
155 | /** | ||
156 | * Logging frequency | ||
157 | */ | ||
158 | struct GNUNET_TIME_Relative log_frequency; | ||
159 | |||
160 | /** | ||
161 | * Benchmark state | ||
162 | */ | ||
163 | struct BenchmarkState state; | ||
164 | |||
165 | struct GNUNET_CORE_MessageHandler *handlers; | ||
166 | |||
167 | GNUNET_TRANSPORT_ReceiveCallback transport_recv_cb; | ||
168 | |||
169 | GNUNET_ATS_TESTING_TopologySetupDoneCallback done_cb; | ||
170 | GNUNET_ATS_AddressInformationCallback ats_perf_cb; | ||
171 | void *done_cb_cls; | ||
172 | }; | ||
173 | |||
174 | |||
175 | |||
176 | static struct GNUNET_ATS_TEST_Topology *top; | ||
177 | |||
178 | struct TrafficGenerator *tg_head; | ||
179 | struct TrafficGenerator *tg_tail; | ||
180 | |||
181 | struct TrafficGenerator | ||
182 | { | ||
183 | struct TrafficGenerator *prev; | ||
184 | struct TrafficGenerator *next; | ||
185 | |||
186 | struct BenchmarkPeer *src; | ||
187 | struct BenchmarkPartner *dest; | ||
188 | unsigned int rate; | ||
189 | GNUNET_SCHEDULER_Task next_send; | ||
190 | struct GNUNET_TIME_Absolute last_sent; | ||
191 | struct GNUNET_TIME_Relative delta; | ||
192 | }; | ||
193 | 53 | ||
194 | /** | 54 | /** |
195 | * Shutdown nicely | 55 | * Shutdown nicely |
@@ -204,25 +64,17 @@ do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
204 | int c_s; | 64 | int c_s; |
205 | int c_op; | 65 | int c_op; |
206 | struct BenchmarkPeer *p; | 66 | struct BenchmarkPeer *p; |
207 | struct TrafficGenerator *cur; | ||
208 | struct TrafficGenerator *next; | ||
209 | 67 | ||
210 | if (GNUNET_YES == top->logging) | 68 | if (GNUNET_YES == top->logging) |
211 | GNUNET_ATS_TEST_logging_stop (); | 69 | GNUNET_ATS_TEST_logging_stop (); |
212 | 70 | ||
213 | top->shutdown_task = GNUNET_SCHEDULER_NO_TASK; | 71 | top->shutdown_task = GNUNET_SCHEDULER_NO_TASK; |
214 | |||
215 | top->state.benchmarking = GNUNET_NO; | 72 | top->state.benchmarking = GNUNET_NO; |
216 | 73 | ||
217 | next = tg_head; | ||
218 | for (cur = next; NULL != cur; cur = next) | ||
219 | { | ||
220 | next = cur->next; | ||
221 | GNUNET_ATS_TEST_generate_traffic_stop(cur); | ||
222 | } | ||
223 | |||
224 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, _("Benchmarking done\n")); | 74 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, _("Benchmarking done\n")); |
225 | 75 | ||
76 | GNUNET_ATS_TEST_generate_traffic_stop_all (); | ||
77 | |||
226 | for (c_m = 0; c_m < top->num_masters; c_m++) | 78 | for (c_m = 0; c_m < top->num_masters; c_m++) |
227 | { | 79 | { |
228 | p = &top->mps[c_m]; | 80 | p = &top->mps[c_m]; |
@@ -475,96 +327,13 @@ core_disconnect_adapter (void *cls, void *op_result) | |||
475 | 327 | ||
476 | 328 | ||
477 | 329 | ||
478 | static size_t | ||
479 | send_ping_ready_cb (void *cls, size_t size, void *buf) | ||
480 | { | ||
481 | struct BenchmarkPartner *p = cls; | ||
482 | static char msgbuf[TEST_MESSAGE_SIZE]; | ||
483 | struct GNUNET_MessageHeader *msg; | ||
484 | |||
485 | if (NULL == buf) | ||
486 | { | ||
487 | GNUNET_break (0); | ||
488 | return 0; | ||
489 | } | ||
490 | if (size < TEST_MESSAGE_SIZE) | ||
491 | { | ||
492 | GNUNET_break (0); | ||
493 | return 0; | ||
494 | } | ||
495 | |||
496 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Master [%u]: Sending PING to [%u]\n", | ||
497 | p->me->no, p->dest->no); | ||
498 | |||
499 | if (top->test_core) | ||
500 | { | ||
501 | if (NULL == p->cth) | ||
502 | { | ||
503 | GNUNET_break (0); | ||
504 | } | ||
505 | p->cth = NULL; | ||
506 | } | ||
507 | else | ||
508 | { | ||
509 | if (NULL == p->tth) | ||
510 | { | ||
511 | GNUNET_break (0); | ||
512 | } | ||
513 | p->tth = NULL; | ||
514 | } | ||
515 | |||
516 | msg = (struct GNUNET_MessageHeader *) &msgbuf; | ||
517 | memset (&msgbuf, 'a', TEST_MESSAGE_SIZE); | ||
518 | msg->type = htons (TEST_MESSAGE_TYPE_PING); | ||
519 | msg->size = htons (TEST_MESSAGE_SIZE); | ||
520 | memcpy (buf, msg, TEST_MESSAGE_SIZE); | ||
521 | |||
522 | p->messages_sent++; | ||
523 | p->bytes_sent += TEST_MESSAGE_SIZE; | ||
524 | p->me->total_messages_sent++; | ||
525 | p->me->total_bytes_sent += TEST_MESSAGE_SIZE; | ||
526 | |||
527 | return TEST_MESSAGE_SIZE; | ||
528 | } | ||
529 | |||
530 | |||
531 | static void | ||
532 | comm_schedule_send (struct BenchmarkPartner *p) | ||
533 | { | ||
534 | p->last_message_sent = GNUNET_TIME_absolute_get(); | ||
535 | if (GNUNET_YES == top->test_core) | ||
536 | { | ||
537 | p->cth = GNUNET_CORE_notify_transmit_ready ( | ||
538 | p->me->ch, GNUNET_NO, 0, GNUNET_TIME_UNIT_MINUTES, &p->dest->id, | ||
539 | TEST_MESSAGE_SIZE, &send_ping_ready_cb, p); | ||
540 | } | ||
541 | else | ||
542 | { | ||
543 | p->tth = GNUNET_TRANSPORT_notify_transmit_ready ( | ||
544 | p->me->th, &p->dest->id, TEST_MESSAGE_SIZE, 0,GNUNET_TIME_UNIT_MINUTES, | ||
545 | &send_ping_ready_cb, p); | ||
546 | } | ||
547 | } | ||
548 | |||
549 | static struct TrafficGenerator * | ||
550 | find_tg (struct BenchmarkPartner *p) | ||
551 | { | ||
552 | struct TrafficGenerator *cur; | ||
553 | for (cur = tg_head; NULL != cur; cur = cur->next) | ||
554 | if ( (0 == memcmp (&p->me->id, &cur->dest->me, sizeof (cur->dest->me))) && | ||
555 | (0 == memcmp (&p->dest->id, &cur->dest->dest->id, sizeof (cur->dest->dest->id))) ) | ||
556 | return cur; | ||
557 | |||
558 | return NULL; | ||
559 | } | ||
560 | 330 | ||
561 | static int | 331 | static int |
562 | core_handle_pong (void *cls, const struct GNUNET_PeerIdentity *other, | 332 | comm_handle_pong (void *cls, const struct GNUNET_PeerIdentity *other, |
563 | const struct GNUNET_MessageHeader *message) | 333 | const struct GNUNET_MessageHeader *message) |
564 | { | 334 | { |
565 | struct BenchmarkPeer *me = cls; | 335 | struct BenchmarkPeer *me = cls; |
566 | struct BenchmarkPartner *p = NULL; | 336 | struct BenchmarkPartner *p = NULL; |
567 | struct TrafficGenerator *tg; | ||
568 | 337 | ||
569 | if (NULL == (p = find_partner (me, other))) | 338 | if (NULL == (p = find_partner (me, other))) |
570 | { | 339 | { |
@@ -572,54 +341,13 @@ core_handle_pong (void *cls, const struct GNUNET_PeerIdentity *other, | |||
572 | return GNUNET_SYSERR; | 341 | return GNUNET_SYSERR; |
573 | } | 342 | } |
574 | 343 | ||
575 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, | 344 | GNUNET_ATS_TEST_traffic_handle_pong (p); |
576 | "Master [%u]: Received PONG from [%u], next message\n", me->no, | ||
577 | p->dest->no); | ||
578 | |||
579 | p->messages_received++; | ||
580 | p->bytes_received += TEST_MESSAGE_SIZE; | ||
581 | p->me->total_messages_received++; | ||
582 | p->me->total_bytes_received += TEST_MESSAGE_SIZE; | ||
583 | p->total_app_rtt += GNUNET_TIME_absolute_get_difference(p->last_message_sent, | ||
584 | GNUNET_TIME_absolute_get()).rel_value_us; | ||
585 | |||
586 | 345 | ||
587 | tg = find_tg(p); | ||
588 | /* | ||
589 | if (GNUNET_TIME_absolute_max(GNUNET_TIME_absolute_get(), tg->next_send))*/ | ||
590 | comm_schedule_send (p); | ||
591 | return GNUNET_OK; | 346 | return GNUNET_OK; |
592 | } | 347 | } |
593 | 348 | ||
594 | static size_t | ||
595 | comm_send_pong_ready (void *cls, size_t size, void *buf) | ||
596 | { | ||
597 | static char msgbuf[TEST_MESSAGE_SIZE]; | ||
598 | struct BenchmarkPartner *p = cls; | ||
599 | struct GNUNET_MessageHeader *msg; | ||
600 | |||
601 | if (GNUNET_YES == top->test_core) | ||
602 | p->cth = NULL; | ||
603 | else | ||
604 | p->tth = NULL; | ||
605 | |||
606 | p->messages_sent++; | ||
607 | p->bytes_sent += TEST_MESSAGE_SIZE; | ||
608 | p->me->total_messages_sent++; | ||
609 | p->me->total_bytes_sent += TEST_MESSAGE_SIZE; | ||
610 | |||
611 | msg = (struct GNUNET_MessageHeader *) &msgbuf; | ||
612 | memset (&msgbuf, 'a', TEST_MESSAGE_SIZE); | ||
613 | msg->type = htons (TEST_MESSAGE_TYPE_PONG); | ||
614 | msg->size = htons (TEST_MESSAGE_SIZE); | ||
615 | memcpy (buf, msg, TEST_MESSAGE_SIZE); | ||
616 | |||
617 | return TEST_MESSAGE_SIZE; | ||
618 | } | ||
619 | |||
620 | |||
621 | static int | 349 | static int |
622 | core_handle_ping (void *cls, const struct GNUNET_PeerIdentity *other, | 350 | comm_handle_ping (void *cls, const struct GNUNET_PeerIdentity *other, |
623 | const struct GNUNET_MessageHeader *message) | 351 | const struct GNUNET_MessageHeader *message) |
624 | { | 352 | { |
625 | struct BenchmarkPeer *me = cls; | 353 | struct BenchmarkPeer *me = cls; |
@@ -630,31 +358,7 @@ core_handle_ping (void *cls, const struct GNUNET_PeerIdentity *other, | |||
630 | GNUNET_break(0); | 358 | GNUNET_break(0); |
631 | return GNUNET_SYSERR; | 359 | return GNUNET_SYSERR; |
632 | } | 360 | } |
633 | 361 | GNUNET_ATS_TEST_traffic_handle_ping (p); | |
634 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, | ||
635 | "Slave [%u]: Received PING from [%u], sending PONG\n", me->no, | ||
636 | p->dest->no); | ||
637 | |||
638 | p->messages_received++; | ||
639 | p->bytes_received += TEST_MESSAGE_SIZE; | ||
640 | p->me->total_messages_received++; | ||
641 | p->me->total_bytes_received += TEST_MESSAGE_SIZE; | ||
642 | |||
643 | if (GNUNET_YES == top->test_core) | ||
644 | { | ||
645 | GNUNET_assert (NULL == p->cth); | ||
646 | |||
647 | p->cth = GNUNET_CORE_notify_transmit_ready (me->ch, GNUNET_NO, 0, | ||
648 | GNUNET_TIME_UNIT_MINUTES, &p->dest->id, TEST_MESSAGE_SIZE, | ||
649 | &comm_send_pong_ready, p); | ||
650 | } | ||
651 | else | ||
652 | { | ||
653 | GNUNET_assert (NULL == p->tth); | ||
654 | p->tth = GNUNET_TRANSPORT_notify_transmit_ready (me->th, &p->dest->id, | ||
655 | TEST_MESSAGE_SIZE, 0, GNUNET_TIME_UNIT_MINUTES, &comm_send_pong_ready, | ||
656 | p); | ||
657 | } | ||
658 | return GNUNET_OK; | 362 | return GNUNET_OK; |
659 | } | 363 | } |
660 | 364 | ||
@@ -670,9 +374,9 @@ test_recv_cb (void *cls, | |||
670 | return; | 374 | return; |
671 | } | 375 | } |
672 | if (TEST_MESSAGE_TYPE_PING == ntohs (message->type)) | 376 | if (TEST_MESSAGE_TYPE_PING == ntohs (message->type)) |
673 | core_handle_ping (cls, peer, message); | 377 | comm_handle_ping (cls, peer, message); |
674 | if (TEST_MESSAGE_TYPE_PONG == ntohs (message->type)) | 378 | if (TEST_MESSAGE_TYPE_PONG == ntohs (message->type)) |
675 | core_handle_pong (cls, peer, message); | 379 | comm_handle_pong (cls, peer, message); |
676 | } | 380 | } |
677 | 381 | ||
678 | 382 | ||
@@ -1146,8 +850,8 @@ GNUNET_ATS_TEST_create_topology (char *name, char *cfg_file, | |||
1146 | { | 850 | { |
1147 | 851 | ||
1148 | static struct GNUNET_CORE_MessageHandler handlers[] = { | 852 | static struct GNUNET_CORE_MessageHandler handlers[] = { |
1149 | {&core_handle_ping, TEST_MESSAGE_TYPE_PING, 0 }, | 853 | {&comm_handle_ping, TEST_MESSAGE_TYPE_PING, 0 }, |
1150 | {&core_handle_pong, TEST_MESSAGE_TYPE_PONG, 0 }, | 854 | {&comm_handle_pong, TEST_MESSAGE_TYPE_PONG, 0 }, |
1151 | { NULL, 0, 0 } }; | 855 | { NULL, 0, 0 } }; |
1152 | 856 | ||
1153 | top = GNUNET_new (struct GNUNET_ATS_TEST_Topology); | 857 | top = GNUNET_new (struct GNUNET_ATS_TEST_Topology); |
@@ -1184,75 +888,6 @@ GNUNET_ATS_TEST_shutdown_topology (void) | |||
1184 | 888 | ||
1185 | 889 | ||
1186 | 890 | ||
1187 | struct TrafficGenerator * | ||
1188 | GNUNET_ATS_TEST_generate_traffic_start (struct BenchmarkPeer *src, | ||
1189 | struct BenchmarkPartner *dest, unsigned int rate, | ||
1190 | struct GNUNET_TIME_Relative duration) | ||
1191 | { | ||
1192 | struct TrafficGenerator * tg; | ||
1193 | tg = NULL; | ||
1194 | |||
1195 | tg = GNUNET_new (struct TrafficGenerator); | ||
1196 | GNUNET_CONTAINER_DLL_insert (tg_head, tg_tail, tg); | ||
1197 | tg->src = src; | ||
1198 | tg->dest = dest; | ||
1199 | tg->rate = rate; | ||
1200 | |||
1201 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
1202 | "Setting up traffic generator between master[%u] `%s' and slave [%u] `%s' sending with %u Bytes/sec\n", | ||
1203 | dest->me->no, GNUNET_i2s (&dest->me->id), | ||
1204 | dest->dest->no, GNUNET_i2s (&dest->dest->id), | ||
1205 | rate); | ||
1206 | |||
1207 | if (top->test_core) | ||
1208 | { | ||
1209 | if (NULL != dest->cth) | ||
1210 | { | ||
1211 | GNUNET_break (0); | ||
1212 | return tg; | ||
1213 | } | ||
1214 | dest->cth = GNUNET_CORE_notify_transmit_ready (src->ch, GNUNET_NO, | ||
1215 | UINT32_MAX, GNUNET_TIME_UNIT_FOREVER_REL, &dest->dest->id, | ||
1216 | TEST_MESSAGE_SIZE, &send_ping_ready_cb, dest); | ||
1217 | } | ||
1218 | else | ||
1219 | { | ||
1220 | if (NULL != dest->tth) | ||
1221 | { | ||
1222 | GNUNET_break (0); | ||
1223 | return tg; | ||
1224 | } | ||
1225 | dest->tth = GNUNET_TRANSPORT_notify_transmit_ready (src->th, &dest->dest->id, | ||
1226 | TEST_MESSAGE_SIZE, UINT32_MAX, GNUNET_TIME_UNIT_FOREVER_REL, | ||
1227 | &send_ping_ready_cb, dest); | ||
1228 | tg->last_sent = GNUNET_TIME_absolute_get(); | ||
1229 | tg->delta.rel_value_us = (GNUNET_TIME_UNIT_SECONDS.rel_value_us / (rate / TEST_MESSAGE_SIZE)); | ||
1230 | } | ||
1231 | return tg; | ||
1232 | } | ||
1233 | |||
1234 | void | ||
1235 | GNUNET_ATS_TEST_generate_traffic_stop (struct TrafficGenerator *tg) | ||
1236 | { | ||
1237 | GNUNET_CONTAINER_DLL_remove (tg_head, tg_tail, tg); | ||
1238 | 891 | ||
1239 | if (top->test_core) | ||
1240 | { | ||
1241 | if (NULL != tg->dest->cth) | ||
1242 | { | ||
1243 | GNUNET_CORE_notify_transmit_ready_cancel (tg->dest->cth); | ||
1244 | tg->dest->cth = NULL; | ||
1245 | } | ||
1246 | } | ||
1247 | else | ||
1248 | { | ||
1249 | if (NULL != tg->dest->tth) | ||
1250 | { | ||
1251 | GNUNET_TRANSPORT_notify_transmit_ready_cancel (tg->dest->tth); | ||
1252 | tg->dest->tth = NULL; | ||
1253 | } | ||
1254 | } | ||
1255 | GNUNET_free (tg); | ||
1256 | } | ||
1257 | 892 | ||
1258 | /* end of file ats-testing.c */ | 893 | /* end of file ats-testing.c */ |
diff --git a/src/ats-tests/ats-testing.h b/src/ats-tests/ats-testing.h index a3d208187..b3301f19d 100644 --- a/src/ats-tests/ats-testing.h +++ b/src/ats-tests/ats-testing.h | |||
@@ -33,7 +33,7 @@ | |||
33 | 33 | ||
34 | #define TEST_MESSAGE_TYPE_PING 12345 | 34 | #define TEST_MESSAGE_TYPE_PING 12345 |
35 | #define TEST_MESSAGE_TYPE_PONG 12346 | 35 | #define TEST_MESSAGE_TYPE_PONG 12346 |
36 | #define TEST_MESSAGE_SIZE 1000 | 36 | #define TEST_MESSAGE_SIZE 100 |
37 | 37 | ||
38 | struct BenchmarkPartner; | 38 | struct BenchmarkPartner; |
39 | struct BenchmarkPeer; | 39 | struct BenchmarkPeer; |
@@ -166,6 +166,19 @@ struct BenchmarkPeer | |||
166 | unsigned int total_bytes_received; | 166 | unsigned int total_bytes_received; |
167 | }; | 167 | }; |
168 | 168 | ||
169 | struct TrafficGenerator | ||
170 | { | ||
171 | struct TrafficGenerator *prev; | ||
172 | struct TrafficGenerator *next; | ||
173 | |||
174 | struct BenchmarkPeer *src; | ||
175 | struct BenchmarkPartner *dest; | ||
176 | unsigned int rate; | ||
177 | GNUNET_SCHEDULER_TaskIdentifier send_task; | ||
178 | struct GNUNET_TIME_Absolute next_ping_transmission; | ||
179 | struct GNUNET_TIME_Relative delta; | ||
180 | }; | ||
181 | |||
169 | 182 | ||
170 | /** | 183 | /** |
171 | * Information about a benchmarking partner | 184 | * Information about a benchmarking partner |
@@ -192,6 +205,8 @@ struct BenchmarkPartner | |||
192 | */ | 205 | */ |
193 | struct GNUNET_TRANSPORT_TransmitHandle *tth; | 206 | struct GNUNET_TRANSPORT_TransmitHandle *tth; |
194 | 207 | ||
208 | struct TrafficGenerator *tg; | ||
209 | |||
195 | /** | 210 | /** |
196 | * Timestamp to calculate communication layer delay | 211 | * Timestamp to calculate communication layer delay |
197 | */ | 212 | */ |
@@ -245,6 +260,129 @@ struct BenchmarkPartner | |||
245 | uint32_t ats_cost_wlan; | 260 | uint32_t ats_cost_wlan; |
246 | }; | 261 | }; |
247 | 262 | ||
263 | /** | ||
264 | * Overall state of the performance benchmark | ||
265 | */ | ||
266 | struct BenchmarkState | ||
267 | { | ||
268 | /** | ||
269 | * Are we connected to ATS service of all peers: GNUNET_YES/NO | ||
270 | */ | ||
271 | int connected_ATS_service; | ||
272 | |||
273 | /** | ||
274 | * Are we connected to CORE service of all peers: GNUNET_YES/NO | ||
275 | */ | ||
276 | int connected_COMM_service; | ||
277 | |||
278 | /** | ||
279 | * Are we connected to all peers: GNUNET_YES/NO | ||
280 | */ | ||
281 | int connected_PEERS; | ||
282 | |||
283 | /** | ||
284 | * Are we connected to all slave peers on CORE level: GNUNET_YES/NO | ||
285 | */ | ||
286 | int connected_CORE; | ||
287 | |||
288 | /** | ||
289 | * Are we connected to CORE service of all peers: GNUNET_YES/NO | ||
290 | */ | ||
291 | int benchmarking; | ||
292 | }; | ||
293 | |||
294 | |||
295 | struct GNUNET_ATS_TEST_Topology | ||
296 | { | ||
297 | /** | ||
298 | * Shutdown task | ||
299 | */ | ||
300 | GNUNET_SCHEDULER_TaskIdentifier shutdown_task; | ||
301 | |||
302 | /** | ||
303 | * Progress task | ||
304 | */ | ||
305 | GNUNET_SCHEDULER_TaskIdentifier progress_task; | ||
306 | |||
307 | /** | ||
308 | * Test result | ||
309 | */ | ||
310 | int result; | ||
311 | |||
312 | /** | ||
313 | * Test result logging | ||
314 | */ | ||
315 | int logging; | ||
316 | |||
317 | /**Test core (GNUNET_YES) or transport (GNUNET_NO) | ||
318 | */ | ||
319 | int test_core; | ||
320 | |||
321 | /** | ||
322 | * Solver string | ||
323 | */ | ||
324 | char *solver; | ||
325 | |||
326 | /** | ||
327 | * Preference string | ||
328 | */ | ||
329 | char *testname; | ||
330 | |||
331 | /** | ||
332 | * Preference string | ||
333 | */ | ||
334 | char *pref_str; | ||
335 | |||
336 | /** | ||
337 | * ATS preference value | ||
338 | */ | ||
339 | int pref_val; | ||
340 | |||
341 | /** | ||
342 | * Number master peers | ||
343 | */ | ||
344 | unsigned int num_masters; | ||
345 | |||
346 | /** | ||
347 | * Array of master peers | ||
348 | */ | ||
349 | struct BenchmarkPeer *mps; | ||
350 | |||
351 | /** | ||
352 | * Number slave peers | ||
353 | */ | ||
354 | unsigned int num_slaves; | ||
355 | |||
356 | /** | ||
357 | * Array of slave peers | ||
358 | */ | ||
359 | struct BenchmarkPeer *sps; | ||
360 | |||
361 | /** | ||
362 | * Benchmark duration | ||
363 | */ | ||
364 | struct GNUNET_TIME_Relative perf_duration; | ||
365 | |||
366 | /** | ||
367 | * Logging frequency | ||
368 | */ | ||
369 | struct GNUNET_TIME_Relative log_frequency; | ||
370 | |||
371 | /** | ||
372 | * Benchmark state | ||
373 | */ | ||
374 | struct BenchmarkState state; | ||
375 | |||
376 | struct GNUNET_CORE_MessageHandler *handlers; | ||
377 | |||
378 | GNUNET_TRANSPORT_ReceiveCallback transport_recv_cb; | ||
379 | |||
380 | GNUNET_ATS_TESTING_TopologySetupDoneCallback done_cb; | ||
381 | GNUNET_ATS_AddressInformationCallback ats_perf_cb; | ||
382 | void *done_cb_cls; | ||
383 | }; | ||
384 | |||
385 | |||
248 | struct TrafficGenerator * | 386 | struct TrafficGenerator * |
249 | GNUNET_ATS_TEST_generate_traffic_start (struct BenchmarkPeer *src, | 387 | GNUNET_ATS_TEST_generate_traffic_start (struct BenchmarkPeer *src, |
250 | struct BenchmarkPartner *dest, unsigned int rate, | 388 | struct BenchmarkPartner *dest, unsigned int rate, |
@@ -253,15 +391,38 @@ GNUNET_ATS_TEST_generate_traffic_start (struct BenchmarkPeer *src, | |||
253 | void | 391 | void |
254 | GNUNET_ATS_TEST_generate_traffic_stop (struct TrafficGenerator *tg); | 392 | GNUNET_ATS_TEST_generate_traffic_stop (struct TrafficGenerator *tg); |
255 | 393 | ||
394 | /** | ||
395 | * Stop all traffic generators | ||
396 | */ | ||
397 | void | ||
398 | GNUNET_ATS_TEST_generate_traffic_stop_all (); | ||
399 | |||
400 | /** | ||
401 | * Start logging | ||
402 | */ | ||
256 | void | 403 | void |
257 | GNUNET_ATS_TEST_logging_start (struct GNUNET_TIME_Relative log_frequency, | 404 | GNUNET_ATS_TEST_logging_start (struct GNUNET_TIME_Relative log_frequency, |
258 | char * testname, struct BenchmarkPeer *masters, int num_masters); | 405 | char * testname, struct BenchmarkPeer *masters, int num_masters); |
259 | 406 | ||
407 | /** | ||
408 | * Stop logging | ||
409 | */ | ||
410 | void | ||
411 | GNUNET_ATS_TEST_logging_stop (void); | ||
412 | |||
413 | /** | ||
414 | * Log all data now | ||
415 | */ | ||
260 | void | 416 | void |
261 | GNUNET_ATS_TEST_logging_now (void); | 417 | GNUNET_ATS_TEST_logging_now (void); |
262 | 418 | ||
419 | |||
263 | void | 420 | void |
264 | GNUNET_ATS_TEST_logging_stop (void); | 421 | GNUNET_ATS_TEST_traffic_handle_ping (struct BenchmarkPartner *p); |
422 | |||
423 | void | ||
424 | GNUNET_ATS_TEST_traffic_handle_pong (struct BenchmarkPartner *p); | ||
425 | |||
265 | 426 | ||
266 | void | 427 | void |
267 | GNUNET_ATS_TEST_create_topology (char *name, char *cfg_file, | 428 | GNUNET_ATS_TEST_create_topology (char *name, char *cfg_file, |
diff --git a/src/ats-tests/gnunet-ats-sim.c b/src/ats-tests/gnunet-ats-sim.c index 993a8a0e4..35320cf8f 100644 --- a/src/ats-tests/gnunet-ats-sim.c +++ b/src/ats-tests/gnunet-ats-sim.c | |||
@@ -37,9 +37,6 @@ | |||
37 | 37 | ||
38 | #define TEST_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10) | 38 | #define TEST_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10) |
39 | 39 | ||
40 | #define TEST_MESSAGE_TYPE_PING 12345 | ||
41 | #define TEST_MESSAGE_TYPE_PONG 1234 | ||
42 | |||
43 | static struct BenchmarkPeer *masters_p; | 40 | static struct BenchmarkPeer *masters_p; |
44 | static struct BenchmarkPeer *slaves_p; | 41 | static struct BenchmarkPeer *slaves_p; |
45 | 42 | ||
@@ -157,7 +154,8 @@ static void topology_setup_done (void *cls, | |||
157 | { | 154 | { |
158 | /* Generate maximum traffic to all peers */ | 155 | /* Generate maximum traffic to all peers */ |
159 | GNUNET_ATS_TEST_generate_traffic_start (&masters[c_m], | 156 | GNUNET_ATS_TEST_generate_traffic_start (&masters[c_m], |
160 | &masters[c_m].partners[c_s], 10000, | 157 | &masters[c_m].partners[c_s], |
158 | 10000, | ||
161 | GNUNET_TIME_UNIT_FOREVER_REL); | 159 | GNUNET_TIME_UNIT_FOREVER_REL); |
162 | } | 160 | } |
163 | } | 161 | } |
@@ -172,7 +170,7 @@ main (int argc, char *argv[]) | |||
172 | c_masters = DEFAULT_NUM_MASTERS; | 170 | c_masters = DEFAULT_NUM_MASTERS; |
173 | 171 | ||
174 | /* Setup a topology with */ | 172 | /* Setup a topology with */ |
175 | GNUNET_ATS_TEST_create_topology ("gnunet-ats-sim", "perf_ats_proportional_none.conf", | 173 | GNUNET_ATS_TEST_create_topology ("gnunet-ats-sim", "gnunet_ats_sim_default.conf", |
176 | c_slaves, | 174 | c_slaves, |
177 | c_masters, | 175 | c_masters, |
178 | GNUNET_NO, | 176 | GNUNET_NO, |
diff --git a/src/ats-tests/gnunet_ats_sim_default.conf b/src/ats-tests/gnunet_ats_sim_default.conf new file mode 100644 index 000000000..ca95eb923 --- /dev/null +++ b/src/ats-tests/gnunet_ats_sim_default.conf | |||
@@ -0,0 +1,6 @@ | |||
1 | @INLINE@ template_perf_ats.conf | ||
2 | [transport] | ||
3 | plugins = unix | ||
4 | |||
5 | [ats] | ||
6 | MODE = PROPORTIONAL | ||