aboutsummaryrefslogtreecommitdiff
path: root/src/ats-tests
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2016-07-29 20:32:23 +0000
committerChristian Grothoff <christian@grothoff.org>2016-07-29 20:32:23 +0000
commit0cd2efeadb67206c0b3e8f1ba743ff342b18926b (patch)
treeee5e46113366e26a25b9691ebdb3e49666dc8ddd /src/ats-tests
parent1e2d3aaecc2a4130e35d46a7c03b9d80d34d6673 (diff)
downloadgnunet-0cd2efeadb67206c0b3e8f1ba743ff342b18926b.tar.gz
gnunet-0cd2efeadb67206c0b3e8f1ba743ff342b18926b.zip
-migrating ATS tests to new transport (and core) API; core tests disabled as new core API doesn't exist yet
Diffstat (limited to 'src/ats-tests')
-rw-r--r--src/ats-tests/Makefile.am26
-rw-r--r--src/ats-tests/ats-testing-traffic.c265
-rw-r--r--src/ats-tests/ats-testing.c397
-rw-r--r--src/ats-tests/ats-testing.h85
-rw-r--r--src/ats-tests/perf_ats.c4
5 files changed, 383 insertions, 394 deletions
diff --git a/src/ats-tests/Makefile.am b/src/ats-tests/Makefile.am
index eefb80d3d..10612bdd0 100644
--- a/src/ats-tests/Makefile.am
+++ b/src/ats-tests/Makefile.am
@@ -14,23 +14,31 @@ if USE_COVERAGE
14endif 14endif
15 15
16if HAVE_LIBGLPK 16if HAVE_LIBGLPK
17 PERF_MLP = perf_ats_mlp_transport_none \ 17 PERF_MLP = \
18 perf_ats_mlp_core_none \ 18 perf_ats_mlp_transport_none \
19 perf_ats_mlp_transport_bandwidth \ 19 perf_ats_mlp_transport_bandwidth \
20 perf_ats_mlp_core_bandwidth \ 20 perf_ats_mlp_transport_latency
21 perf_ats_mlp_transport_latency \ 21# core-related test commented out while we wait
22 perf_ats_mlp_core_latency 22# for GNUNET_CORE_connecT to be implemented!
23# perf_ats_mlp_core_none \
24# perf_ats_mlp_core_bandwidth \
25# perf_ats_mlp_core_latency
23endif 26endif
24 27
25if HAVE_TESTING 28if HAVE_TESTING
26TESTING_TESTS = \ 29TESTING_TESTS = \
27 perf_ats_proportional_transport_none \ 30 perf_ats_proportional_transport_none \
28 perf_ats_proportional_core_none \
29 perf_ats_proportional_transport_bandwidth \ 31 perf_ats_proportional_transport_bandwidth \
30 perf_ats_proportional_core_bandwidth \
31 perf_ats_proportional_transport_latency \ 32 perf_ats_proportional_transport_latency \
32 perf_ats_proportional_core_latency \
33 $(PERF_MLP) 33 $(PERF_MLP)
34
35# core-related test commented out while we wait
36# for GNUNET_CORE_connecT to be implemented!
37# perf_ats_proportional_core_none \
38# perf_ats_proportional_core_bandwidth \
39# perf_ats_proportional_core_latency
40
41# RIL-tests commented out as RIL is currently badly broken.
34# perf_ats_ril_transport_none perf_ats_ril_core_none perf_ats_ril_transport_bandwidth perf_ats_ril_core_bandwidth perf_ats_ril_transport_latency perf_ats_ril_core_latency 42# perf_ats_ril_transport_none perf_ats_ril_core_none perf_ats_ril_transport_bandwidth perf_ats_ril_core_bandwidth perf_ats_ril_transport_latency perf_ats_ril_core_latency
35endif 43endif
36 44
@@ -257,7 +265,7 @@ perf_ats_mlp_transport_latencyDEPENDENCIES = \
257 265
258 266
259EXTRA_DIST = \ 267EXTRA_DIST = \
260 gnunet_ats_sim_default.conf \ 268 gnunet_ats_sim_default.conf \
261 perf_ats_proportional_none.conf \ 269 perf_ats_proportional_none.conf \
262 perf_ats_proportional_bandwidth.conf \ 270 perf_ats_proportional_bandwidth.conf \
263 perf_ats_proportional_latency.conf \ 271 perf_ats_proportional_latency.conf \
diff --git a/src/ats-tests/ats-testing-traffic.c b/src/ats-tests/ats-testing-traffic.c
index fade09554..760c050c8 100644
--- a/src/ats-tests/ats-testing-traffic.c
+++ b/src/ats-tests/ats-testing-traffic.c
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 Copyright (C) 2010-2013 GNUnet e.V. 3 Copyright (C) 2010-2013, 2016 GNUnet e.V.
4 4
5 GNUnet is free software; you can redistribute it and/or modify 5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published 6 it under the terms of the GNU General Public License as published
@@ -100,51 +100,12 @@ get_delay (struct TrafficGenerator *tg)
100} 100}
101 101
102 102
103static size_t 103static void
104send_ping_ready_cb (void *cls, size_t size, void *buf) 104update_ping_data (void *cls)
105{ 105{
106 struct BenchmarkPartner *p = cls; 106 struct BenchmarkPartner *p = cls;
107 static char msgbuf[TEST_MESSAGE_SIZE];
108 struct GNUNET_MessageHeader *msg;
109 struct GNUNET_TIME_Relative delay; 107 struct GNUNET_TIME_Relative delay;
110 108
111 if (NULL == buf)
112 {
113 GNUNET_break (0);
114 return 0;
115 }
116 if (size < TEST_MESSAGE_SIZE)
117 {
118 GNUNET_break (0);
119 return 0;
120 }
121
122 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
123 "Master [%u]: Sending PING to [%u]\n",
124 p->me->no, p->dest->no);
125 if (top->test_core)
126 {
127 if (NULL == p->cth)
128 {
129 GNUNET_break (0);
130 }
131 p->cth = NULL;
132 }
133 else
134 {
135 if (NULL == p->tth)
136 {
137 GNUNET_break (0);
138 }
139 p->tth = NULL;
140 }
141
142 msg = (struct GNUNET_MessageHeader *) &msgbuf;
143 memset (&msgbuf, 'a', TEST_MESSAGE_SIZE);
144 msg->type = htons (TEST_MESSAGE_TYPE_PING);
145 msg->size = htons (TEST_MESSAGE_SIZE);
146 GNUNET_memcpy (buf, msg, TEST_MESSAGE_SIZE);
147
148 p->messages_sent++; 109 p->messages_sent++;
149 p->bytes_sent += TEST_MESSAGE_SIZE; 110 p->bytes_sent += TEST_MESSAGE_SIZE;
150 p->me->total_messages_sent++; 111 p->me->total_messages_sent++;
@@ -153,16 +114,16 @@ send_ping_ready_cb (void *cls, size_t size, void *buf)
153 if (NULL == p->tg) 114 if (NULL == p->tg)
154 { 115 {
155 GNUNET_break (0); 116 GNUNET_break (0);
156 return TEST_MESSAGE_SIZE; 117 return;
157 } 118 }
158 delay = get_delay (p->tg); 119 delay = get_delay (p->tg);
159 120 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
160 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Delay for next transmission %llu ms\n", 121 "Delay for next transmission %s\n",
161 (long long unsigned int) delay.rel_value_us / 1000); 122 GNUNET_STRINGS_relative_time_to_string (delay,
162 p->tg->next_ping_transmission = GNUNET_TIME_absolute_add(GNUNET_TIME_absolute_get(), 123 GNUNET_YES));
163 delay); 124 p->tg->next_ping_transmission
164 125 = GNUNET_TIME_absolute_add (GNUNET_TIME_absolute_get(),
165 return TEST_MESSAGE_SIZE; 126 delay);
166} 127}
167 128
168 129
@@ -170,86 +131,66 @@ static void
170comm_schedule_send (void *cls) 131comm_schedule_send (void *cls)
171{ 132{
172 struct BenchmarkPartner *p = cls; 133 struct BenchmarkPartner *p = cls;
134 struct TestMessage *msg;
135 struct GNUNET_MQ_Envelope *env;
173 136
174 p->tg->send_task = NULL; 137 p->tg->send_task = NULL;
175 p->last_message_sent = GNUNET_TIME_absolute_get(); 138 p->last_message_sent = GNUNET_TIME_absolute_get();
176 if (GNUNET_YES == top->test_core) 139 env = GNUNET_MQ_msg (msg,
177 { 140 TEST_MESSAGE_TYPE_PING);
178 p->cth = GNUNET_CORE_notify_transmit_ready (p->me->ch, GNUNET_NO, 141 memset (msg->padding,
179 GNUNET_CORE_PRIO_BEST_EFFORT, 142 'a',
180 GNUNET_TIME_UNIT_MINUTES, 143 sizeof (msg->padding));
181 &p->dest->id, 144 GNUNET_MQ_notify_sent (env,
182 TEST_MESSAGE_SIZE, 145 &update_ping_data,
183 &send_ping_ready_cb, p); 146 p);
184 } 147 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
185 else 148 "Master [%u]: Sending PING to [%u]\n",
186 { 149 p->me->no,
187 p->tth = GNUNET_TRANSPORT_notify_transmit_ready (p->me->th, 150 p->dest->no);
188 &p->dest->id, 151 GNUNET_MQ_send (p->mq,
189 TEST_MESSAGE_SIZE, 152 env);
190 GNUNET_TIME_UNIT_MINUTES,
191 &send_ping_ready_cb, p);
192 }
193} 153}
194 154
195 155
196static size_t 156static void
197comm_send_pong_ready (void *cls, size_t size, void *buf) 157update_pong_data (void *cls)
198{ 158{
199 static char msgbuf[TEST_MESSAGE_SIZE];
200 struct BenchmarkPartner *p = cls; 159 struct BenchmarkPartner *p = cls;
201 struct GNUNET_MessageHeader *msg;
202
203 if (GNUNET_YES == top->test_core)
204 p->cth = NULL;
205 else
206 p->tth = NULL;
207 160
208 p->messages_sent++; 161 p->messages_sent++;
209 p->bytes_sent += TEST_MESSAGE_SIZE; 162 p->bytes_sent += TEST_MESSAGE_SIZE;
210 p->me->total_messages_sent++; 163 p->me->total_messages_sent++;
211 p->me->total_bytes_sent += TEST_MESSAGE_SIZE; 164 p->me->total_bytes_sent += TEST_MESSAGE_SIZE;
212
213 msg = (struct GNUNET_MessageHeader *) &msgbuf;
214 memset (&msgbuf, 'a', TEST_MESSAGE_SIZE);
215 msg->type = htons (TEST_MESSAGE_TYPE_PONG);
216 msg->size = htons (TEST_MESSAGE_SIZE);
217 GNUNET_memcpy (buf, msg, TEST_MESSAGE_SIZE);
218
219 return TEST_MESSAGE_SIZE;
220} 165}
221 166
222 167
223void 168void
224GNUNET_ATS_TEST_traffic_handle_ping (struct BenchmarkPartner *p) 169GNUNET_ATS_TEST_traffic_handle_ping (struct BenchmarkPartner *p)
225{ 170{
226 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 171 struct TestMessage *msg;
227 "Slave [%u]: Received PING from [%u], sending PONG\n", p->me->no, 172 struct GNUNET_MQ_Envelope *env;
228 p->dest->no);
229 173
174 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
175 "Slave [%u]: Received PING from [%u], sending PONG\n",
176 p->me->no,
177 p->dest->no);
230 p->messages_received++; 178 p->messages_received++;
231 p->bytes_received += TEST_MESSAGE_SIZE; 179 p->bytes_received += TEST_MESSAGE_SIZE;
232 p->me->total_messages_received++; 180 p->me->total_messages_received++;
233 p->me->total_bytes_received += TEST_MESSAGE_SIZE; 181 p->me->total_bytes_received += TEST_MESSAGE_SIZE;
234 182
235 if (GNUNET_YES == top->test_core) 183
236 { 184 env = GNUNET_MQ_msg (msg,
237 GNUNET_assert (NULL == p->cth); 185 TEST_MESSAGE_TYPE_PING);
238 186 memset (msg->padding,
239 p->cth 187 'a',
240 = GNUNET_CORE_notify_transmit_ready (p->me->ch, GNUNET_NO, 188 sizeof (msg->padding));
241 GNUNET_CORE_PRIO_BEST_EFFORT, 189 GNUNET_MQ_notify_sent (env,
242 GNUNET_TIME_UNIT_MINUTES, 190 &update_pong_data,
243 &p->dest->id, TEST_MESSAGE_SIZE, 191 p);
244 &comm_send_pong_ready, p); 192 GNUNET_MQ_send (p->mq,
245 } 193 env);
246 else
247 {
248 GNUNET_assert (NULL == p->tth);
249 p->tth = GNUNET_TRANSPORT_notify_transmit_ready (p->me->th, &p->dest->id,
250 TEST_MESSAGE_SIZE, GNUNET_TIME_UNIT_MINUTES, &comm_send_pong_ready,
251 p);
252 }
253} 194}
254 195
255 196
@@ -258,8 +199,9 @@ GNUNET_ATS_TEST_traffic_handle_pong (struct BenchmarkPartner *p)
258{ 199{
259 struct GNUNET_TIME_Relative left; 200 struct GNUNET_TIME_Relative left;
260 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 201 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
261 "Master [%u]: Received PONG from [%u], next message\n", p->me->no, 202 "Master [%u]: Received PONG from [%u], next message\n",
262 p->dest->no); 203 p->me->no,
204 p->dest->no);
263 205
264 p->messages_received++; 206 p->messages_received++;
265 p->bytes_received += TEST_MESSAGE_SIZE; 207 p->bytes_received += TEST_MESSAGE_SIZE;
@@ -325,7 +267,9 @@ GNUNET_ATS_TEST_generate_traffic_start (struct BenchmarkPeer *src,
325 } 267 }
326 268
327 tg = GNUNET_new (struct TrafficGenerator); 269 tg = GNUNET_new (struct TrafficGenerator);
328 GNUNET_CONTAINER_DLL_insert (tg_head, tg_tail, tg); 270 GNUNET_CONTAINER_DLL_insert (tg_head,
271 tg_tail,
272 tg);
329 tg->type = type; 273 tg->type = type;
330 tg->src = src; 274 tg->src = src;
331 tg->dest = dest; 275 tg->dest = dest;
@@ -336,50 +280,53 @@ GNUNET_ATS_TEST_generate_traffic_start (struct BenchmarkPeer *src,
336 tg->next_ping_transmission = GNUNET_TIME_UNIT_FOREVER_ABS; 280 tg->next_ping_transmission = GNUNET_TIME_UNIT_FOREVER_ABS;
337 281
338 switch (type) { 282 switch (type) {
339 case GNUNET_ATS_TEST_TG_CONSTANT: 283 case GNUNET_ATS_TEST_TG_CONSTANT:
340 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 284 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
341 "Setting up constant traffic generator master[%u] `%s' and slave [%u] `%s' max %u Bips\n", 285 "Setting up constant traffic generator master[%u] `%s' and slave [%u] `%s' max %u Bips\n",
342 dest->me->no, GNUNET_i2s (&dest->me->id), 286 dest->me->no,
343 dest->dest->no, GNUNET_i2s (&dest->dest->id), 287 GNUNET_i2s (&dest->me->id),
344 base_rate); 288 dest->dest->no,
345 break; 289 GNUNET_i2s (&dest->dest->id),
346 case GNUNET_ATS_TEST_TG_LINEAR: 290 base_rate);
347 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 291 break;
348 "Setting up linear traffic generator master[%u] `%s' and slave [%u] `%s' min %u Bips max %u Bips\n", 292 case GNUNET_ATS_TEST_TG_LINEAR:
349 dest->me->no, GNUNET_i2s (&dest->me->id), 293 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
350 dest->dest->no, GNUNET_i2s (&dest->dest->id), 294 "Setting up linear traffic generator master[%u] `%s' and slave [%u] `%s' min %u Bips max %u Bips\n",
351 base_rate, 295 dest->me->no,
352 max_rate); 296 GNUNET_i2s (&dest->me->id),
353 break; 297 dest->dest->no,
354 case GNUNET_ATS_TEST_TG_SINUS: 298 GNUNET_i2s (&dest->dest->id),
355 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 299 base_rate,
356 "Setting up sinus traffic generator master[%u] `%s' and slave [%u] `%s' baserate %u Bips, amplitude %u Bps\n", 300 max_rate);
357 dest->me->no, GNUNET_i2s (&dest->me->id), 301 break;
358 dest->dest->no, GNUNET_i2s (&dest->dest->id), 302 case GNUNET_ATS_TEST_TG_SINUS:
359 base_rate, max_rate); 303 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
360 break; 304 "Setting up sinus traffic generator master[%u] `%s' and slave [%u] `%s' baserate %u Bips, amplitude %u Bps\n",
361 case GNUNET_ATS_TEST_TG_RANDOM: 305 dest->me->no,
362 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 306 GNUNET_i2s (&dest->me->id),
363 "Setting up random traffic generator master[%u] `%s' and slave [%u] `%s' min %u Bips max %u Bps\n", 307 dest->dest->no,
364 dest->me->no, GNUNET_i2s (&dest->me->id), 308 GNUNET_i2s (&dest->dest->id),
365 dest->dest->no, GNUNET_i2s (&dest->dest->id), 309 base_rate,
366 base_rate, max_rate); 310 max_rate);
311 break;
312 case GNUNET_ATS_TEST_TG_RANDOM:
313 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
314 "Setting up random traffic generator master[%u] `%s' and slave [%u] `%s' min %u Bips max %u Bps\n",
315 dest->me->no,
316 GNUNET_i2s (&dest->me->id),
317 dest->dest->no,
318 GNUNET_i2s (&dest->dest->id),
319 base_rate,
320 max_rate);
367 break; 321 break;
368 default: 322 default:
369 break; 323 break;
370 } 324 }
371 325
372 if ( ((GNUNET_YES == top->test_core) && (NULL != dest->cth)) ||
373 ((GNUNET_NO == top->test_core) && (NULL != dest->tth)) )
374 {
375 GNUNET_break (0);
376 GNUNET_CONTAINER_DLL_remove (tg_head, tg_tail, tg);
377 GNUNET_free (tg);
378 return NULL;
379 }
380
381 dest->tg = tg; 326 dest->tg = tg;
382 tg->send_task = GNUNET_SCHEDULER_add_now (&comm_schedule_send, dest); 327 tg->send_task
328 = GNUNET_SCHEDULER_add_now (&comm_schedule_send,
329 dest);
383 return tg; 330 return tg;
384} 331}
385 332
@@ -387,30 +334,15 @@ GNUNET_ATS_TEST_generate_traffic_start (struct BenchmarkPeer *src,
387void 334void
388GNUNET_ATS_TEST_generate_traffic_stop (struct TrafficGenerator *tg) 335GNUNET_ATS_TEST_generate_traffic_stop (struct TrafficGenerator *tg)
389{ 336{
390 GNUNET_CONTAINER_DLL_remove (tg_head, tg_tail, tg); 337 GNUNET_CONTAINER_DLL_remove (tg_head,
338 tg_tail,
339 tg);
391 tg->dest->tg = NULL; 340 tg->dest->tg = NULL;
392
393 if (NULL != tg->send_task) 341 if (NULL != tg->send_task)
394 { 342 {
395 GNUNET_SCHEDULER_cancel (tg->send_task); 343 GNUNET_SCHEDULER_cancel (tg->send_task);
396 tg->send_task = NULL; 344 tg->send_task = NULL;
397 } 345 }
398 if (top->test_core)
399 {
400 if (NULL != tg->dest->cth)
401 {
402 GNUNET_CORE_notify_transmit_ready_cancel (tg->dest->cth);
403 tg->dest->cth = NULL;
404 }
405 }
406 else
407 {
408 if (NULL != tg->dest->tth)
409 {
410 GNUNET_TRANSPORT_notify_transmit_ready_cancel (tg->dest->tth);
411 tg->dest->tth = NULL;
412 }
413 }
414 GNUNET_free (tg); 346 GNUNET_free (tg);
415} 347}
416 348
@@ -423,11 +355,12 @@ GNUNET_ATS_TEST_generate_traffic_stop_all ()
423{ 355{
424 struct TrafficGenerator *cur; 356 struct TrafficGenerator *cur;
425 struct TrafficGenerator *next; 357 struct TrafficGenerator *next;
358
426 next = tg_head; 359 next = tg_head;
427 for (cur = next; NULL != cur; cur = next) 360 for (cur = next; NULL != cur; cur = next)
428 { 361 {
429 next = cur->next; 362 next = cur->next;
430 GNUNET_ATS_TEST_generate_traffic_stop(cur); 363 GNUNET_ATS_TEST_generate_traffic_stop(cur);
431 } 364 }
432} 365}
433 366
diff --git a/src/ats-tests/ats-testing.c b/src/ats-tests/ats-testing.c
index 8ed135d49..5c2f96e5d 100644
--- a/src/ats-tests/ats-testing.c
+++ b/src/ats-tests/ats-testing.c
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 Copyright (C) 2010-2013 GNUnet e.V. 3 Copyright (C) 2010-2013, 2016 GNUnet e.V.
4 4
5 GNUnet is free software; you can redistribute it and/or modify 5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published 6 it under the terms of the GNU General Public License as published
@@ -93,18 +93,13 @@ do_shutdown (void *cls)
93 GNUNET_CORE_notify_transmit_ready_cancel (p->partners[c_op].cth); 93 GNUNET_CORE_notify_transmit_ready_cancel (p->partners[c_op].cth);
94 p->partners[c_op].cth = NULL; 94 p->partners[c_op].cth = NULL;
95 } 95 }
96 if (NULL != p->partners[c_op].tth)
97 {
98 GNUNET_TRANSPORT_notify_transmit_ready_cancel (p->partners[c_op].tth);
99 p->partners[c_op].tth = NULL;
100 }
101 if ( (NULL != p->core_connect_ops) && 96 if ( (NULL != p->core_connect_ops) &&
102 (NULL != p->core_connect_ops[c_op].connect_op) ) 97 (NULL != p->core_connect_ops[c_op].connect_op) )
103 { 98 {
104 GNUNET_log(GNUNET_ERROR_TYPE_INFO, 99 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
105 _("Failed to connect peer 0 and %u\n"), c_op); 100 "Failed to connect peer 0 and %u\n",
106 GNUNET_TESTBED_operation_done ( 101 c_op);
107 p->core_connect_ops[c_op].connect_op); 102 GNUNET_TESTBED_operation_done (p->core_connect_ops[c_op].connect_op);
108 p->core_connect_ops[c_op].connect_op = NULL; 103 p->core_connect_ops[c_op].connect_op = NULL;
109 } 104 }
110 } 105 }
@@ -141,11 +136,6 @@ do_shutdown (void *cls)
141 GNUNET_CORE_notify_transmit_ready_cancel (p->partners[c_op].cth); 136 GNUNET_CORE_notify_transmit_ready_cancel (p->partners[c_op].cth);
142 p->partners[c_op].cth = NULL; 137 p->partners[c_op].cth = NULL;
143 } 138 }
144 if (NULL != p->partners[c_op].tth)
145 {
146 GNUNET_TRANSPORT_notify_transmit_ready_cancel (p->partners[c_op].tth);
147 p->partners[c_op].tth = NULL;
148 }
149 } 139 }
150 if (NULL != p->ats_perf_op) 140 if (NULL != p->ats_perf_op)
151 { 141 {
@@ -216,13 +206,17 @@ find_peer (const struct GNUNET_PeerIdentity * peer)
216 * 206 *
217 * @param cls closure 207 * @param cls closure
218 * @param peer peer identity this notification is about 208 * @param peer peer identity this notification is about
209 * @param mq queue to use to send messages to @a peer
210 * @return the `struct BenchmarkPartner` of @a peer
219 */ 211 */
220static void 212static void *
221comm_connect_cb (void *cls, 213comm_connect_cb (void *cls,
222 const struct GNUNET_PeerIdentity *peer) 214 const struct GNUNET_PeerIdentity *peer,
215 struct GNUNET_MQ_Handle *mq)
223{ 216{
224 struct BenchmarkPeer *me = cls; 217 struct BenchmarkPeer *me = cls;
225 struct BenchmarkPeer *remote; 218 struct BenchmarkPeer *remote;
219 struct BenchmarkPartner *p;
226 char *id; 220 char *id;
227 int c; 221 int c;
228 int completed; 222 int completed;
@@ -233,28 +227,32 @@ comm_connect_cb (void *cls,
233 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 227 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
234 "Unknown peer connected: `%s'\n", 228 "Unknown peer connected: `%s'\n",
235 GNUNET_i2s (peer)); 229 GNUNET_i2s (peer));
236 GNUNET_break(0); 230 GNUNET_break (0);
237 return; 231 return NULL;
238 } 232 }
239 233
240 id = GNUNET_strdup (GNUNET_i2s (&me->id)); 234 id = GNUNET_strdup (GNUNET_i2s (&me->id));
241 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 235 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
242 "%s [%u] `%s' connected to %s [%u] %s\n", 236 "%s [%u] `%s' connected to %s [%u] %s\n",
243 (me->master == GNUNET_YES) ? "Master": "Slave", me->no, id, 237 (me->master == GNUNET_YES) ? "Master": "Slave",
244 (remote->master == GNUNET_YES) ? "Master": "Slave", remote->no, 238 me->no,
239 id,
240 (remote->master == GNUNET_YES) ? "Master": "Slave",
241 remote->no,
245 GNUNET_i2s (peer)); 242 GNUNET_i2s (peer));
246 243
247 me->core_connections++; 244 me->core_connections++;
248 if ((GNUNET_YES == me->master) && (GNUNET_NO == remote->master) 245 if ((GNUNET_YES == me->master) &&
249 && (GNUNET_NO == top->state.connected_CORE)) 246 (GNUNET_NO == remote->master) &&
247 (GNUNET_NO == top->state.connected_CORE))
250 { 248 {
251 me->core_slave_connections++; 249 me->core_slave_connections++;
252 250
253 if (me->core_slave_connections == top->num_slaves) 251 if (me->core_slave_connections == top->num_slaves)
254 { 252 {
255 GNUNET_log(GNUNET_ERROR_TYPE_INFO, 253 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
256 "Master [%u] connected all slaves\n", 254 "Master [%u] connected all slaves\n",
257 me->no); 255 me->no);
258 } 256 }
259 completed = GNUNET_YES; 257 completed = GNUNET_YES;
260 for (c = 0; c < top->num_masters; c++) 258 for (c = 0; c < top->num_masters; c++)
@@ -269,22 +267,35 @@ comm_connect_cb (void *cls,
269 top->state.connected_CORE = GNUNET_YES; 267 top->state.connected_CORE = GNUNET_YES;
270 /* Notify about setup done */ 268 /* Notify about setup done */
271 if (NULL != top->done_cb) 269 if (NULL != top->done_cb)
272 top->done_cb (top->done_cb_cls, top->mps, top->sps); 270 top->done_cb (top->done_cb_cls,
271 top->mps,
272 top->sps);
273 } 273 }
274 } 274 }
275 GNUNET_free(id); 275 GNUNET_free (id);
276 p = find_partner (me,
277 peer);
278 if (NULL != p)
279 p->mq = mq;
280 return p;
276} 281}
277 282
278 283
284/**
285 * @param cls this peer
286 * @param peer id of disconnecting peer
287 * @param internal_cls the `struct BenchmarkPartner` of @a peer
288 */
279static void 289static void
280comm_disconnect_cb (void *cls, 290comm_disconnect_cb (void *cls,
281 const struct GNUNET_PeerIdentity *peer) 291 const struct GNUNET_PeerIdentity *peer,
292 void *internal_cls)
282{ 293{
283 struct BenchmarkPeer *me = cls; 294 struct BenchmarkPeer *me = cls;
284 struct BenchmarkPartner *p; 295 struct BenchmarkPartner *p = internal_cls;
285 char *id; 296 char *id;
286 297
287 if (NULL == (p = find_partner (me, peer))) 298 if (NULL == p)
288 return; 299 return;
289 300
290 id = GNUNET_strdup (GNUNET_i2s (&me->id)); 301 id = GNUNET_strdup (GNUNET_i2s (&me->id));
@@ -292,22 +303,17 @@ comm_disconnect_cb (void *cls,
292 "%s disconnected from %s\n", 303 "%s disconnected from %s\n",
293 id, 304 id,
294 GNUNET_i2s (peer)); 305 GNUNET_i2s (peer));
295 GNUNET_assert(me->core_connections > 0); 306 GNUNET_assert (me->core_connections > 0);
296 me->core_connections--; 307 me->core_connections--;
297 308
298 if ( (GNUNET_YES == top->state.benchmarking) && 309 if ( (GNUNET_YES == top->state.benchmarking) &&
299 ( (GNUNET_YES == me->master) || 310 ( (GNUNET_YES == me->master) ||
300 (GNUNET_YES == p->dest->master) ) ) 311 (GNUNET_YES == p->dest->master) ) )
301 { 312 {
302 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, 313 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
303 "%s disconnected from %s while benchmarking\n", 314 "%s disconnected from %s while benchmarking\n",
304 id, 315 id,
305 GNUNET_i2s (peer)); 316 GNUNET_i2s (peer));
306 if (NULL != p->tth)
307 {
308 GNUNET_TRANSPORT_notify_transmit_ready_cancel (p->tth);
309 p->tth = NULL;
310 }
311 if (NULL != p->cth) 317 if (NULL != p->cth)
312 { 318 {
313 GNUNET_CORE_notify_transmit_ready_cancel (p->cth); 319 GNUNET_CORE_notify_transmit_ready_cancel (p->cth);
@@ -318,121 +324,106 @@ comm_disconnect_cb (void *cls,
318} 324}
319 325
320 326
321static void * 327static void
322core_connect_adapter (void *cls, 328handle_pong (void *cls,
323 const struct GNUNET_CONFIGURATION_Handle *cfg) 329 const struct TestMessage *message)
324{ 330{
325 struct BenchmarkPeer *me = cls; 331 struct BenchmarkPartner *p = cls;
326 332
327 me->ch = GNUNET_CORE_connect (cfg, 333 GNUNET_ATS_TEST_traffic_handle_pong (p);
328 me,
329 NULL,
330 &comm_connect_cb,
331 &comm_disconnect_cb,
332 NULL,
333 GNUNET_NO,
334 NULL,
335 GNUNET_NO,
336 top->handlers);
337 if (NULL == me->ch)
338 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
339 "Failed to create core connection \n");
340 return me->ch;
341} 334}
342 335
343 336
344static void 337static void
345core_disconnect_adapter (void *cls, void *op_result) 338handle_ping (void *cls,
339 const struct TestMessage *message)
346{ 340{
347 struct BenchmarkPeer *me = cls; 341 struct BenchmarkPartner *p = cls;
348 342
349 GNUNET_CORE_disconnect (me->ch); 343 GNUNET_ATS_TEST_traffic_handle_ping (p);
350 me->ch = NULL;
351} 344}
352 345
353 346
354static int 347static void *
355comm_handle_pong (void *cls, 348transport_connect_adapter (void *cls,
356 const struct GNUNET_PeerIdentity *other, 349 const struct GNUNET_CONFIGURATION_Handle *cfg)
357 const struct GNUNET_MessageHeader *message)
358{ 350{
351 GNUNET_MQ_hd_fixed_size (ping,
352 TEST_MESSAGE_TYPE_PING,
353 struct TestMessage);
354 GNUNET_MQ_hd_fixed_size (pong,
355 TEST_MESSAGE_TYPE_PONG,
356 struct TestMessage);
359 struct BenchmarkPeer *me = cls; 357 struct BenchmarkPeer *me = cls;
360 struct BenchmarkPartner *p = NULL; 358 struct GNUNET_MQ_MessageHandler handlers[] = {
361 359 make_ping_handler (me),
362 if (NULL == (p = find_partner (me, other))) 360 make_pong_handler (me),
363 { 361 GNUNET_MQ_handler_end ()
364 GNUNET_break(0); 362 };
365 return GNUNET_SYSERR; 363
366 } 364 me->th = GNUNET_TRANSPORT_core_connect (cfg,
367 365 &me->id,
368 GNUNET_ATS_TEST_traffic_handle_pong (p); 366 handlers,
369 367 me,
370 return GNUNET_OK; 368 &comm_connect_cb,
369 &comm_disconnect_cb,
370 NULL);
371 if (NULL == me->th)
372 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
373 "Failed to create transport connection \n");
374 return me->th;
371} 375}
372 376
373 377
374static int 378static void
375comm_handle_ping (void *cls, 379transport_disconnect_adapter (void *cls,
376 const struct GNUNET_PeerIdentity *other, 380 void *op_result)
377 const struct GNUNET_MessageHeader *message)
378{ 381{
379 struct BenchmarkPeer *me = cls; 382 struct BenchmarkPeer *me = cls;
380 struct BenchmarkPartner *p = NULL;
381
382 if (NULL == (p = find_partner(me, other)))
383 {
384 GNUNET_break(0);
385 return GNUNET_SYSERR;
386 }
387 GNUNET_ATS_TEST_traffic_handle_ping (p);
388 return GNUNET_OK;
389}
390
391 383
392static void 384 GNUNET_TRANSPORT_core_disconnect (me->th);
393test_recv_cb (void *cls, 385 me->th = NULL;
394 const struct GNUNET_PeerIdentity *peer,
395 const struct GNUNET_MessageHeader *message)
396{
397 if ( (TEST_MESSAGE_SIZE != ntohs (message->size)) ||
398 ( (TEST_MESSAGE_TYPE_PING != ntohs (message->type)) &&
399 (TEST_MESSAGE_TYPE_PONG != ntohs (message->type)) ) )
400 {
401 return;
402 }
403 if (TEST_MESSAGE_TYPE_PING == ntohs (message->type))
404 comm_handle_ping (cls, peer, message);
405 if (TEST_MESSAGE_TYPE_PONG == ntohs (message->type))
406 comm_handle_pong (cls, peer, message);
407} 386}
408 387
409 388
410static void * 389static void *
411transport_connect_adapter (void *cls, 390core_connect_adapter (void *cls,
412 const struct GNUNET_CONFIGURATION_Handle *cfg) 391 const struct GNUNET_CONFIGURATION_Handle *cfg)
413{ 392{
393 GNUNET_MQ_hd_fixed_size (ping,
394 TEST_MESSAGE_TYPE_PING,
395 struct TestMessage);
396 GNUNET_MQ_hd_fixed_size (pong,
397 TEST_MESSAGE_TYPE_PONG,
398 struct TestMessage);
414 struct BenchmarkPeer *me = cls; 399 struct BenchmarkPeer *me = cls;
400 struct GNUNET_MQ_MessageHandler handlers[] = {
401 make_ping_handler (me),
402 make_pong_handler (me),
403 GNUNET_MQ_handler_end ()
404 };
415 405
416 me->th = GNUNET_TRANSPORT_connect (cfg, 406 me->ch = GNUNET_CORE_connecT (cfg,
417 &me->id, 407 me,
418 me, 408 NULL,
419 &test_recv_cb, 409 &comm_connect_cb,
420 &comm_connect_cb, 410 &comm_disconnect_cb,
421 &comm_disconnect_cb); 411 handlers);
422 if (NULL == me->th) 412 if (NULL == me->ch)
423 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, 413 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
424 "Failed to create transport connection \n"); 414 "Failed to create core connection \n");
425 return me->th; 415 return me->ch;
426} 416}
427 417
428 418
429static void 419static void
430transport_disconnect_adapter (void *cls, void *op_result) 420core_disconnect_adapter (void *cls,
421 void *op_result)
431{ 422{
432 struct BenchmarkPeer *me = cls; 423 struct BenchmarkPeer *me = cls;
433 424
434 GNUNET_TRANSPORT_disconnect (me->th); 425 GNUNET_CORE_disconnect (me->ch);
435 me->th = NULL; 426 me->ch = NULL;
436} 427}
437 428
438 429
@@ -484,8 +475,8 @@ do_connect_peers (void *cls)
484 (top->state.connected_COMM_service == GNUNET_NO)) 475 (top->state.connected_COMM_service == GNUNET_NO))
485 return; 476 return;
486 477
487 GNUNET_log(GNUNET_ERROR_TYPE_INFO, _("Connecting peers on CORE level\n")); 478 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
488 479 "Connecting peers on CORE level\n");
489 for (c_m = 0; c_m < top->num_masters; c_m++) 480 for (c_m = 0; c_m < top->num_masters; c_m++)
490 { 481 {
491 p = &top->mps[c_m]; 482 p = &top->mps[c_m];
@@ -494,18 +485,24 @@ do_connect_peers (void *cls)
494 485
495 for (c_s = 0; c_s < top->num_slaves; c_s++) 486 for (c_s = 0; c_s < top->num_slaves; c_s++)
496 { 487 {
497 GNUNET_log(GNUNET_ERROR_TYPE_INFO, 488 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
498 _("Connecting master [%u] with slave [%u]\n"), p->no, top->sps[c_s].no); 489 "Connecting master [%u] with slave [%u]\n",
490 p->no,
491 top->sps[c_s].no);
499 p->core_connect_ops[c_s].master = p; 492 p->core_connect_ops[c_s].master = p;
500 p->core_connect_ops[c_s].slave = &top->sps[c_s]; 493 p->core_connect_ops[c_s].slave = &top->sps[c_s];
501 p->core_connect_ops[c_s].connect_op = GNUNET_TESTBED_overlay_connect ( 494 p->core_connect_ops[c_s].connect_op
502 NULL, &connect_completion_callback, &p->core_connect_ops[c_s], 495 = GNUNET_TESTBED_overlay_connect (NULL,
503 top->sps[c_s].peer, p->peer); 496 &connect_completion_callback,
497 &p->core_connect_ops[c_s],
498 top->sps[c_s].peer,
499 p->peer);
504 if (NULL == p->core_connect_ops[c_s].connect_op) 500 if (NULL == p->core_connect_ops[c_s].connect_op)
505 { 501 {
506 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, 502 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
507 _("Could not connect master [%u] and slave [%u]\n"), p->no, 503 "Could not connect master [%u] and slave [%u]\n",
508 top->sps[c_s].no); 504 p->no,
505 top->sps[c_s].no);
509 GNUNET_break(0); 506 GNUNET_break(0);
510 GNUNET_SCHEDULER_shutdown (); 507 GNUNET_SCHEDULER_shutdown ();
511 return; 508 return;
@@ -535,10 +532,12 @@ comm_connect_completion_cb (void *cls,
535 532
536 if (comm_done == top->num_slaves + top->num_masters) 533 if (comm_done == top->num_slaves + top->num_masters)
537 { 534 {
538 GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Connected to all %s services\n", 535 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
539 (GNUNET_YES == top->test_core) ? "CORE" : "TRANSPORT"); 536 "Connected to all %s services\n",
537 (GNUNET_YES == top->test_core) ? "CORE" : "TRANSPORT");
540 top->state.connected_COMM_service = GNUNET_YES; 538 top->state.connected_COMM_service = GNUNET_YES;
541 GNUNET_SCHEDULER_add_now (&do_connect_peers, NULL ); 539 GNUNET_SCHEDULER_add_now (&do_connect_peers,
540 NULL);
542 } 541 }
543} 542}
544 543
@@ -548,33 +547,58 @@ do_comm_connect (void *cls)
548{ 547{
549 int c_s; 548 int c_s;
550 int c_m; 549 int c_m;
551 GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Connecting to all %s services\n", 550 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
552 (GNUNET_YES == top->test_core) ? "CORE" : "TRANSPORT"); 551 "Connecting to all %s services\n",
552 (GNUNET_YES == top->test_core) ? "CORE" : "TRANSPORT");
553 for (c_m = 0; c_m < top->num_masters; c_m++) 553 for (c_m = 0; c_m < top->num_masters; c_m++)
554 { 554 {
555 if (GNUNET_YES == top->test_core) 555 if (GNUNET_YES == top->test_core)
556 top->mps[c_m].comm_op = GNUNET_TESTBED_service_connect (NULL, top->mps[c_m].peer, 556 top->mps[c_m].comm_op
557 "core", &comm_connect_completion_cb, NULL, &core_connect_adapter, 557 = GNUNET_TESTBED_service_connect (NULL,
558 &core_disconnect_adapter, &top->mps[c_m]); 558 top->mps[c_m].peer,
559 "core",
560 &comm_connect_completion_cb,
561 NULL,
562 &core_connect_adapter,
563 &core_disconnect_adapter,
564 &top->mps[c_m]);
559 else 565 else
560 { 566 {
561 top->mps[c_m].comm_op = GNUNET_TESTBED_service_connect (NULL, top->mps[c_m].peer, 567 top->mps[c_m].comm_op
562 "transport", &comm_connect_completion_cb, NULL, &transport_connect_adapter, 568 = GNUNET_TESTBED_service_connect (NULL,
563 &transport_disconnect_adapter, &top->mps[c_m]); 569 top->mps[c_m].peer,
570 "transport",
571 &comm_connect_completion_cb,
572 NULL,
573 &transport_connect_adapter,
574 &transport_disconnect_adapter,
575 &top->mps[c_m]);
564 } 576 }
565 } 577 }
566 578
567 for (c_s = 0; c_s < top->num_slaves; c_s++) 579 for (c_s = 0; c_s < top->num_slaves; c_s++)
568 { 580 {
569 if (GNUNET_YES == top->test_core) 581 if (GNUNET_YES == top->test_core)
570 top->sps[c_s].comm_op = GNUNET_TESTBED_service_connect (NULL, top->sps[c_s].peer, 582 top->sps[c_s].comm_op
571 "core", &comm_connect_completion_cb, NULL, &core_connect_adapter, 583 = GNUNET_TESTBED_service_connect (NULL,
572 &core_disconnect_adapter, &top->sps[c_s]); 584 top->sps[c_s].peer,
585 "core",
586 &comm_connect_completion_cb,
587 NULL,
588 &core_connect_adapter,
589 &core_disconnect_adapter,
590 &top->sps[c_s]);
573 else 591 else
574 { 592 {
575 top->sps[c_s].comm_op = GNUNET_TESTBED_service_connect (NULL, top->sps[c_s].peer, 593 top->sps[c_s].comm_op
576 "transport", &comm_connect_completion_cb, NULL, &transport_connect_adapter, 594 = GNUNET_TESTBED_service_connect (NULL,
577 &transport_disconnect_adapter, &top->sps[c_s]); 595 top->sps[c_s].peer,
596 "transport",
597 &comm_connect_completion_cb,
598 NULL,
599 &transport_connect_adapter,
600 &transport_disconnect_adapter,
601 &top->sps[c_s]);
578 } 602 }
579 } 603 }
580} 604}
@@ -595,12 +619,14 @@ ats_performance_info_cb (void *cls,
595 619
596 if (NULL == address) 620 if (NULL == address)
597 { 621 {
598 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Peer %u: ATS Service disconnected!\n", 622 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
599 me->no); 623 "Peer %u: ATS Service disconnected!\n",
624 me->no);
600 return; 625 return;
601 } 626 }
602 627
603 p = find_partner (me, &address->peer); 628 p = find_partner (me,
629 &address->peer);
604 if (NULL == p) 630 if (NULL == p)
605 { 631 {
606 /* This is not one of my partners 632 /* This is not one of my partners
@@ -657,7 +683,8 @@ ats_perf_connect_adapter (void *cls,
657 683
658 684
659static void 685static void
660ats_perf_disconnect_adapter (void *cls, void *op_result) 686ats_perf_disconnect_adapter (void *cls,
687 void *op_result)
661{ 688{
662 struct BenchmarkPeer *me = cls; 689 struct BenchmarkPeer *me = cls;
663 690
@@ -743,9 +770,11 @@ peerinformation_cb (void *cb_cls,
743 GNUNET_assert(pinfo->pit == GNUNET_TESTBED_PIT_IDENTITY); 770 GNUNET_assert(pinfo->pit == GNUNET_TESTBED_PIT_IDENTITY);
744 771
745 p->id = *pinfo->result.id; 772 p->id = *pinfo->result.id;
746 GNUNET_log(GNUNET_ERROR_TYPE_INFO, "%s [%u] has peer id `%s'\n", 773 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
747 (p->master == GNUNET_YES) ? "Master" : "Slave", p->no, 774 "%s [%u] has peer id `%s'\n",
748 GNUNET_i2s (&p->id)); 775 (p->master == GNUNET_YES) ? "Master" : "Slave",
776 p->no,
777 GNUNET_i2s (&p->id));
749 778
750 GNUNET_TESTBED_operation_done (op); 779 GNUNET_TESTBED_operation_done (op);
751 p->peer_id_op = NULL; 780 p->peer_id_op = NULL;
@@ -753,12 +782,14 @@ peerinformation_cb (void *cb_cls,
753 782
754 if (done == top->num_slaves + top->num_masters) 783 if (done == top->num_slaves + top->num_masters)
755 { 784 {
756 GNUNET_log(GNUNET_ERROR_TYPE_INFO, 785 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
757 "Retrieved all peer ID, connect to ATS\n"); 786 "Retrieved all peer ID, connect to ATS\n");
758 GNUNET_SCHEDULER_add_now (&do_connect_ats, NULL ); 787 GNUNET_SCHEDULER_add_now (&do_connect_ats,
788 NULL);
759 } 789 }
760} 790}
761 791
792
762/** 793/**
763 * Signature of a main function for a testcase. 794 * Signature of a main function for a testcase.
764 * 795 *
@@ -772,7 +803,8 @@ peerinformation_cb (void *cb_cls,
772 * failed 803 * failed
773 */ 804 */
774static void 805static void
775main_run (void *cls, struct GNUNET_TESTBED_RunHandle *h, 806main_run (void *cls,
807 struct GNUNET_TESTBED_RunHandle *h,
776 unsigned int num_peers, 808 unsigned int num_peers,
777 struct GNUNET_TESTBED_Peer **peers_, 809 struct GNUNET_TESTBED_Peer **peers_,
778 unsigned int links_succeeded, 810 unsigned int links_succeeded,
@@ -781,9 +813,9 @@ main_run (void *cls, struct GNUNET_TESTBED_RunHandle *h,
781 int c_m; 813 int c_m;
782 int c_s; 814 int c_s;
783 815
784 GNUNET_assert(NULL == cls); 816 GNUNET_assert (NULL == cls);
785 GNUNET_assert(top->num_masters + top->num_slaves == num_peers); 817 GNUNET_assert (top->num_masters + top->num_slaves == num_peers);
786 GNUNET_assert(NULL != peers_); 818 GNUNET_assert (NULL != peers_);
787 819
788 GNUNET_SCHEDULER_add_shutdown (&do_shutdown, 820 GNUNET_SCHEDULER_add_shutdown (&do_shutdown,
789 top); 821 top);
@@ -812,8 +844,11 @@ main_run (void *cls, struct GNUNET_TESTBED_RunHandle *h,
812 top->mps[c_m].partners[c_s].dest = &top->sps[c_s]; 844 top->mps[c_m].partners[c_s].dest = &top->sps[c_s];
813 } 845 }
814 /* Get configuration */ 846 /* Get configuration */
815 top->mps[c_m].peer_id_op = GNUNET_TESTBED_peer_get_information (top->mps[c_m].peer, 847 top->mps[c_m].peer_id_op
816 GNUNET_TESTBED_PIT_IDENTITY, &peerinformation_cb, &top->mps[c_m]); 848 = GNUNET_TESTBED_peer_get_information (top->mps[c_m].peer,
849 GNUNET_TESTBED_PIT_IDENTITY,
850 &peerinformation_cb,
851 &top->mps[c_m]);
817 } 852 }
818 853
819 /* Setup slave peers */ 854 /* Setup slave peers */
@@ -824,7 +859,8 @@ main_run (void *cls, struct GNUNET_TESTBED_RunHandle *h,
824 top->sps[c_s].no = c_s + top->num_masters; 859 top->sps[c_s].no = c_s + top->num_masters;
825 top->sps[c_s].master = GNUNET_NO; 860 top->sps[c_s].master = GNUNET_NO;
826 top->sps[c_s].partners = 861 top->sps[c_s].partners =
827 GNUNET_malloc (top->num_masters * sizeof (struct BenchmarkPartner)); 862 GNUNET_new_array (top->num_masters,
863 struct BenchmarkPartner);
828 top->sps[c_s].num_partners = top->num_masters; 864 top->sps[c_s].num_partners = top->num_masters;
829 /* Initialize partners */ 865 /* Initialize partners */
830 for (c_m = 0; c_m < top->num_masters; c_m++) 866 for (c_m = 0; c_m < top->num_masters; c_m++)
@@ -840,11 +876,15 @@ main_run (void *cls, struct GNUNET_TESTBED_RunHandle *h,
840 top->sps[c_s].partners[c_m].props.utilization_out = 0; 876 top->sps[c_s].partners[c_m].props.utilization_out = 0;
841 } 877 }
842 /* Get configuration */ 878 /* Get configuration */
843 top->sps[c_s].peer_id_op = GNUNET_TESTBED_peer_get_information (top->sps[c_s].peer, 879 top->sps[c_s].peer_id_op
844 GNUNET_TESTBED_PIT_IDENTITY, &peerinformation_cb, &top->sps[c_s]); 880 = GNUNET_TESTBED_peer_get_information (top->sps[c_s].peer,
881 GNUNET_TESTBED_PIT_IDENTITY,
882 &peerinformation_cb,
883 &top->sps[c_s]);
845 } 884 }
846} 885}
847 886
887
848/** 888/**
849 * Controller event callback 889 * Controller event callback
850 * 890 *
@@ -878,7 +918,8 @@ GNUNET_ATS_TEST_get_peer (int src)
878 918
879 919
880struct BenchmarkPartner * 920struct BenchmarkPartner *
881GNUNET_ATS_TEST_get_partner (int src, int dest) 921GNUNET_ATS_TEST_get_partner (int src,
922 int dest)
882{ 923{
883 if (src > top->num_masters) 924 if (src > top->num_masters)
884 return NULL; 925 return NULL;
@@ -909,20 +950,13 @@ GNUNET_ATS_TEST_create_topology (char *name, char *cfg_file,
909 void *done_cb_cls, 950 void *done_cb_cls,
910 GNUNET_ATS_AddressInformationCallback log_request_cb) 951 GNUNET_ATS_AddressInformationCallback log_request_cb)
911{ 952{
912 static struct GNUNET_CORE_MessageHandler handlers[] = {
913 {&comm_handle_ping, TEST_MESSAGE_TYPE_PING, 0 },
914 {&comm_handle_pong, TEST_MESSAGE_TYPE_PONG, 0 },
915 { NULL, 0, 0 } };
916
917 top = GNUNET_new (struct GNUNET_ATS_TEST_Topology); 953 top = GNUNET_new (struct GNUNET_ATS_TEST_Topology);
918 top->num_masters = num_masters; 954 top->num_masters = num_masters;
919 top->num_slaves = num_slaves; 955 top->num_slaves = num_slaves;
920 top->handlers = handlers;
921 top->done_cb = done_cb; 956 top->done_cb = done_cb;
922 top->done_cb_cls = done_cb_cls; 957 top->done_cb_cls = done_cb_cls;
923 top->test_core = test_core; 958 top->test_core = test_core;
924 top->ats_perf_cb = log_request_cb; 959 top->ats_perf_cb = log_request_cb;
925
926 top->mps = GNUNET_new_array (num_masters, 960 top->mps = GNUNET_new_array (num_masters,
927 struct BenchmarkPeer); 961 struct BenchmarkPeer);
928 top->sps = GNUNET_new_array (num_slaves, 962 top->sps = GNUNET_new_array (num_slaves,
@@ -933,8 +967,8 @@ GNUNET_ATS_TEST_create_topology (char *name, char *cfg_file,
933 event_mask = 0; 967 event_mask = 0;
934 event_mask |= (1LL << GNUNET_TESTBED_ET_CONNECT); 968 event_mask |= (1LL << GNUNET_TESTBED_ET_CONNECT);
935 event_mask |= (1LL << GNUNET_TESTBED_ET_OPERATION_FINISHED); 969 event_mask |= (1LL << GNUNET_TESTBED_ET_OPERATION_FINISHED);
936 (void) GNUNET_TESTBED_test_run (name, cfg_file, 970 (void) GNUNET_TESTBED_test_run (name,
937 971 cfg_file,
938 num_slaves + num_masters, 972 num_slaves + num_masters,
939 event_mask, 973 event_mask,
940 &controller_event_cb, NULL, 974 &controller_event_cb, NULL,
@@ -954,7 +988,4 @@ GNUNET_ATS_TEST_shutdown_topology (void)
954} 988}
955 989
956 990
957
958
959
960/* end of file ats-testing.c */ 991/* end of file ats-testing.c */
diff --git a/src/ats-tests/ats-testing.h b/src/ats-tests/ats-testing.h
index c6e679b0b..de189953e 100644
--- a/src/ats-tests/ats-testing.h
+++ b/src/ats-tests/ats-testing.h
@@ -28,6 +28,7 @@
28#include "gnunet_testbed_service.h" 28#include "gnunet_testbed_service.h"
29#include "gnunet_ats_service.h" 29#include "gnunet_ats_service.h"
30#include "gnunet_core_service.h" 30#include "gnunet_core_service.h"
31#include "gnunet_transport_core_service.h"
31 32
32#define TEST_ATS_PREFERENCE_DEFAULT 1.0 33#define TEST_ATS_PREFERENCE_DEFAULT 1.0
33 34
@@ -46,6 +47,15 @@
46 */ 47 */
47#define TEST_MESSAGE_SIZE 100 48#define TEST_MESSAGE_SIZE 100
48 49
50
51struct TestMessage
52{
53 struct GNUNET_MessageHeader header;
54
55 uint8_t padding[TEST_MESSAGE_SIZE - sizeof (struct GNUNET_MessageHeader)];
56};
57
58
49struct BenchmarkPartner; 59struct BenchmarkPartner;
50 60
51struct BenchmarkPeer; 61struct BenchmarkPeer;
@@ -147,14 +157,14 @@ struct BenchmarkPeer
147 struct TestbedConnectOperation *core_connect_ops; 157 struct TestbedConnectOperation *core_connect_ops;
148 158
149 /** 159 /**
150 * Core handle 160 * Core handle
151 */ 161 */
152 struct GNUNET_CORE_Handle *ch; 162 struct GNUNET_CORE_Handle *ch;
153 163
154 /** 164 /**
155 * Core handle 165 * Transport handle
156 */ 166 */
157 struct GNUNET_TRANSPORT_Handle *th; 167 struct GNUNET_TRANSPORT_CoreHandle *th;
158 168
159 /** 169 /**
160 * Masters only: 170 * Masters only:
@@ -280,10 +290,9 @@ struct BenchmarkPartner
280 struct GNUNET_CORE_TransmitHandle *cth; 290 struct GNUNET_CORE_TransmitHandle *cth;
281 291
282 /** 292 /**
283 * Transport transmit handles 293 * Message queue handle.
284 */ 294 */
285 struct GNUNET_TRANSPORT_TransmitHandle *tth; 295 struct GNUNET_MQ_Handle *mq;
286
287 296
288 /** 297 /**
289 * Handle for traffic generator 298 * Handle for traffic generator
@@ -325,24 +334,34 @@ struct BenchmarkPartner
325 */ 334 */
326 unsigned int bytes_received; 335 unsigned int bytes_received;
327 336
328 /* Current ATS properties */ 337 /**
338 * Current ATS properties
339 */
329 struct GNUNET_ATS_Properties props; 340 struct GNUNET_ATS_Properties props;
330 341
331 /* Bandwidth assigned inbound */ 342 /**
343 * Bandwidth assigned inbound
344 */
332 uint32_t bandwidth_in; 345 uint32_t bandwidth_in;
333 346
334 /* Bandwidth assigned outbound */ 347 /**
348 * Bandwidth assigned outbound
349 */
335 uint32_t bandwidth_out; 350 uint32_t bandwidth_out;
336 351
337 /* Current preference values for bandwidth */ 352 /**
353 * Current preference values for bandwidth
354 */
338 double pref_bandwidth; 355 double pref_bandwidth;
339 356
340 /* Current preference values for delay */ 357 /**
358 * Current preference values for delay
359 */
341 double pref_delay; 360 double pref_delay;
342 361
343
344}; 362};
345 363
364
346/** 365/**
347 * Overall state of the performance benchmark 366 * Overall state of the performance benchmark
348 */ 367 */
@@ -387,7 +406,8 @@ struct GNUNET_ATS_TEST_Topology
387 */ 406 */
388 int result; 407 int result;
389 408
390 /**Test core (GNUNET_YES) or transport (GNUNET_NO) 409 /**
410 * Test core (#GNUNET_YES) or transport (#GNUNET_NO)
391 */ 411 */
392 int test_core; 412 int test_core;
393 413
@@ -446,10 +466,10 @@ struct GNUNET_ATS_TEST_Topology
446 */ 466 */
447 struct BenchmarkState state; 467 struct BenchmarkState state;
448 468
449 struct GNUNET_CORE_MessageHandler *handlers;
450
451 GNUNET_ATS_TEST_TopologySetupDoneCallback done_cb; 469 GNUNET_ATS_TEST_TopologySetupDoneCallback done_cb;
470
452 GNUNET_ATS_AddressInformationCallback ats_perf_cb; 471 GNUNET_ATS_AddressInformationCallback ats_perf_cb;
472
453 void *done_cb_cls; 473 void *done_cb_cls;
454}; 474};
455 475
@@ -465,11 +485,13 @@ struct Episode;
465 485
466struct Experiment; 486struct Experiment;
467 487
468typedef void (*GNUNET_ATS_TESTING_EpisodeDoneCallback) ( 488typedef void
469 struct Episode *e); 489(*GNUNET_ATS_TESTING_EpisodeDoneCallback) (struct Episode *e);
470 490
471typedef void (*GNUNET_ATS_TESTING_ExperimentDoneCallback) (struct Experiment *e, 491typedef void
472 struct GNUNET_TIME_Relative duration,int success); 492(*GNUNET_ATS_TESTING_ExperimentDoneCallback) (struct Experiment *e,
493 struct GNUNET_TIME_Relative duration,
494 int success);
473 495
474/** 496/**
475 * An operation in an experiment 497 * An operation in an experiment
@@ -524,9 +546,7 @@ struct Experiment
524 GNUNET_ATS_TESTING_ExperimentDoneCallback e_done_cb; 546 GNUNET_ATS_TESTING_ExperimentDoneCallback e_done_cb;
525}; 547};
526 548
527/* 549
528 * Experiment related functions
529 */
530extern struct GNUNET_CONFIGURATION_Handle *cfg; 550extern struct GNUNET_CONFIGURATION_Handle *cfg;
531 551
532/** 552/**
@@ -560,13 +580,11 @@ GNUNET_ATS_TEST_experimentation_load (const char *filename);
560void 580void
561GNUNET_ATS_TEST_experimentation_stop (struct Experiment *e); 581GNUNET_ATS_TEST_experimentation_stop (struct Experiment *e);
562 582
563/*
564 * Traffic related functions
565 */
566 583
567void 584void
568GNUNET_ATS_TEST_traffic_handle_ping (struct BenchmarkPartner *p); 585GNUNET_ATS_TEST_traffic_handle_ping (struct BenchmarkPartner *p);
569 586
587
570void 588void
571GNUNET_ATS_TEST_traffic_handle_pong (struct BenchmarkPartner *p); 589GNUNET_ATS_TEST_traffic_handle_pong (struct BenchmarkPartner *p);
572 590
@@ -597,6 +615,7 @@ GNUNET_ATS_TEST_generate_traffic_start (struct BenchmarkPeer *src,
597void 615void
598GNUNET_ATS_TEST_generate_traffic_stop (struct TrafficGenerator *tg); 616GNUNET_ATS_TEST_generate_traffic_stop (struct TrafficGenerator *tg);
599 617
618
600/** 619/**
601 * Stop all traffic generators 620 * Stop all traffic generators
602 */ 621 */
@@ -628,6 +647,7 @@ GNUNET_ATS_TEST_generate_preferences_start (struct BenchmarkPeer *src,
628 struct GNUNET_TIME_Relative frequency, 647 struct GNUNET_TIME_Relative frequency,
629 enum GNUNET_ATS_PreferenceKind kind); 648 enum GNUNET_ATS_PreferenceKind kind);
630 649
650
631void 651void
632GNUNET_ATS_TEST_generate_preferences_stop (struct PreferenceGenerator *pg); 652GNUNET_ATS_TEST_generate_preferences_stop (struct PreferenceGenerator *pg);
633 653
@@ -635,9 +655,6 @@ GNUNET_ATS_TEST_generate_preferences_stop (struct PreferenceGenerator *pg);
635void 655void
636GNUNET_ATS_TEST_generate_preferences_stop_all (void); 656GNUNET_ATS_TEST_generate_preferences_stop_all (void);
637 657
638/*
639 * Logging related functions
640 */
641 658
642/** 659/**
643 * Start logging 660 * Start logging
@@ -651,12 +668,12 @@ GNUNET_ATS_TEST_generate_preferences_stop_all (void);
651 * @return the logging handle or NULL on error 668 * @return the logging handle or NULL on error
652 */ 669 */
653struct LoggingHandle * 670struct LoggingHandle *
654GNUNET_ATS_TEST_logging_start(struct GNUNET_TIME_Relative log_frequency, 671GNUNET_ATS_TEST_logging_start (struct GNUNET_TIME_Relative log_frequency,
655 const char *testname, 672 const char *testname,
656 struct BenchmarkPeer *masters, 673 struct BenchmarkPeer *masters,
657 int num_masters, 674 int num_masters,
658 int num_slaves, 675 int num_slaves,
659 int verbose); 676 int verbose);
660 677
661 678
662/** 679/**
diff --git a/src/ats-tests/perf_ats.c b/src/ats-tests/perf_ats.c
index da664bc94..4df4f0c73 100644
--- a/src/ats-tests/perf_ats.c
+++ b/src/ats-tests/perf_ats.c
@@ -573,11 +573,11 @@ main (int argc, char *argv[])
573 */ 573 */
574 GNUNET_ATS_TEST_create_topology ("perf-ats", 574 GNUNET_ATS_TEST_create_topology ("perf-ats",
575 conf_name, 575 conf_name,
576 num_slaves, num_masters, 576 num_slaves,
577 num_masters,
577 test_core, 578 test_core,
578 &do_benchmark, 579 &do_benchmark,
579 NULL, 580 NULL,
580 NULL,
581 &log_request_cb); 581 &log_request_cb);
582 582
583 return result; 583 return result;