aboutsummaryrefslogtreecommitdiff
path: root/src/ats-tests/ats-testing.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ats-tests/ats-testing.c')
-rw-r--r--src/ats-tests/ats-testing.c1052
1 files changed, 528 insertions, 524 deletions
diff --git a/src/ats-tests/ats-testing.c b/src/ats-tests/ats-testing.c
index 696deb4bd..88c1729a6 100644
--- a/src/ats-tests/ats-testing.c
+++ b/src/ats-tests/ats-testing.c
@@ -30,7 +30,8 @@
30/** 30/**
31 * Connect peers with testbed 31 * Connect peers with testbed
32 */ 32 */
33struct TestbedConnectOperation { 33struct TestbedConnectOperation
34{
34 /** 35 /**
35 * The benchmarking master initiating this connection 36 * The benchmarking master initiating this connection
36 */ 37 */
@@ -58,7 +59,7 @@ struct GNUNET_ATS_TEST_Topology *top;
58 * @param cls NULL 59 * @param cls NULL
59 */ 60 */
60static void 61static void
61do_shutdown(void *cls) 62do_shutdown (void *cls)
62{ 63{
63 int c_m; 64 int c_m;
64 int c_s; 65 int c_s;
@@ -67,118 +68,118 @@ do_shutdown(void *cls)
67 68
68 top->state.benchmarking = GNUNET_NO; 69 top->state.benchmarking = GNUNET_NO;
69 70
70 GNUNET_log(GNUNET_ERROR_TYPE_INFO, 71 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
71 "Benchmarking done\n"); 72 "Benchmarking done\n");
72 73
73 GNUNET_ATS_TEST_generate_traffic_stop_all(); 74 GNUNET_ATS_TEST_generate_traffic_stop_all ();
74 75
75 for (c_m = 0; c_m < top->num_masters; c_m++) 76 for (c_m = 0; c_m < top->num_masters; c_m++)
77 {
78 p = &top->mps[c_m];
79 if (NULL != top->mps[c_m].peer_id_op)
80 {
81 GNUNET_TESTBED_operation_done (p->peer_id_op);
82 p->peer_id_op = NULL;
83 }
84
85 if (NULL != p->ats_task)
86 GNUNET_SCHEDULER_cancel (p->ats_task);
87 p->ats_task = NULL;
88
89 for (c_op = 0; c_op < p->num_partners; c_op++)
90 {
91 if ((NULL != p->core_connect_ops) &&
92 (NULL != p->core_connect_ops[c_op].connect_op))
93 {
94 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
95 "Failed to connect peer 0 and %u\n",
96 c_op);
97 GNUNET_TESTBED_operation_done (p->core_connect_ops[c_op].connect_op);
98 p->core_connect_ops[c_op].connect_op = NULL;
99 }
100 }
101
102 if (NULL != p->ats_perf_op)
103 {
104 GNUNET_TESTBED_operation_done (p->ats_perf_op);
105 p->ats_perf_op = NULL;
106 }
107
108 if (NULL != p->comm_op)
76 { 109 {
77 p = &top->mps[c_m]; 110 GNUNET_TESTBED_operation_done (p->comm_op);
78 if (NULL != top->mps[c_m].peer_id_op) 111 p->comm_op = NULL;
79 {
80 GNUNET_TESTBED_operation_done(p->peer_id_op);
81 p->peer_id_op = NULL;
82 }
83
84 if (NULL != p->ats_task)
85 GNUNET_SCHEDULER_cancel(p->ats_task);
86 p->ats_task = NULL;
87
88 for (c_op = 0; c_op < p->num_partners; c_op++)
89 {
90 if ((NULL != p->core_connect_ops) &&
91 (NULL != p->core_connect_ops[c_op].connect_op))
92 {
93 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
94 "Failed to connect peer 0 and %u\n",
95 c_op);
96 GNUNET_TESTBED_operation_done(p->core_connect_ops[c_op].connect_op);
97 p->core_connect_ops[c_op].connect_op = NULL;
98 }
99 }
100
101 if (NULL != p->ats_perf_op)
102 {
103 GNUNET_TESTBED_operation_done(p->ats_perf_op);
104 p->ats_perf_op = NULL;
105 }
106
107 if (NULL != p->comm_op)
108 {
109 GNUNET_TESTBED_operation_done(p->comm_op);
110 p->comm_op = NULL;
111 }
112 GNUNET_free_non_null(p->core_connect_ops);
113 GNUNET_free(p->partners);
114 p->partners = NULL;
115 } 112 }
113 GNUNET_free_non_null (p->core_connect_ops);
114 GNUNET_free (p->partners);
115 p->partners = NULL;
116 }
116 117
117 for (c_s = 0; c_s < top->num_slaves; c_s++) 118 for (c_s = 0; c_s < top->num_slaves; c_s++)
119 {
120 p = &top->sps[c_s];
121 if (NULL != p->peer_id_op)
118 { 122 {
119 p = &top->sps[c_s]; 123 GNUNET_TESTBED_operation_done (p->peer_id_op);
120 if (NULL != p->peer_id_op) 124 p->peer_id_op = NULL;
121 {
122 GNUNET_TESTBED_operation_done(p->peer_id_op);
123 p->peer_id_op = NULL;
124 }
125 if (NULL != p->ats_perf_op)
126 {
127 GNUNET_TESTBED_operation_done(p->ats_perf_op);
128 p->ats_perf_op = NULL;
129 }
130 if (NULL != p->comm_op)
131 {
132 GNUNET_TESTBED_operation_done(p->comm_op);
133 p->comm_op = NULL;
134 }
135 GNUNET_free(p->partners);
136 p->partners = NULL;
137 } 125 }
138 GNUNET_SCHEDULER_shutdown(); 126 if (NULL != p->ats_perf_op)
139 GNUNET_free(top); 127 {
128 GNUNET_TESTBED_operation_done (p->ats_perf_op);
129 p->ats_perf_op = NULL;
130 }
131 if (NULL != p->comm_op)
132 {
133 GNUNET_TESTBED_operation_done (p->comm_op);
134 p->comm_op = NULL;
135 }
136 GNUNET_free (p->partners);
137 p->partners = NULL;
138 }
139 GNUNET_SCHEDULER_shutdown ();
140 GNUNET_free (top);
140 top = NULL; 141 top = NULL;
141} 142}
142 143
143 144
144static struct BenchmarkPartner * 145static struct BenchmarkPartner *
145find_partner(struct BenchmarkPeer *me, 146find_partner (struct BenchmarkPeer *me,
146 const struct GNUNET_PeerIdentity *peer) 147 const struct GNUNET_PeerIdentity *peer)
147{ 148{
148 int c_m; 149 int c_m;
149 150
150 for (c_m = 0; c_m < me->num_partners; c_m++) 151 for (c_m = 0; c_m < me->num_partners; c_m++)
152 {
153 /* Find a partner with other as destination */
154 if (0 == GNUNET_memcmp (peer,
155 &me->partners[c_m].dest->id))
151 { 156 {
152 /* Find a partner with other as destination */ 157 return &me->partners[c_m];
153 if (0 == GNUNET_memcmp(peer,
154 &me->partners[c_m].dest->id))
155 {
156 return &me->partners[c_m];
157 }
158 } 158 }
159 }
159 160
160 return NULL; 161 return NULL;
161} 162}
162 163
163 164
164static struct BenchmarkPeer * 165static struct BenchmarkPeer *
165find_peer(const struct GNUNET_PeerIdentity * peer) 166find_peer (const struct GNUNET_PeerIdentity *peer)
166{ 167{
167 int c_p; 168 int c_p;
168 169
169 for (c_p = 0; c_p < top->num_masters; c_p++) 170 for (c_p = 0; c_p < top->num_masters; c_p++)
170 { 171 {
171 if (0 == GNUNET_memcmp(&top->mps[c_p].id, 172 if (0 == GNUNET_memcmp (&top->mps[c_p].id,
172 peer)) 173 peer))
173 return &top->mps[c_p]; 174 return &top->mps[c_p];
174 } 175 }
175 176
176 for (c_p = 0; c_p < top->num_slaves; c_p++) 177 for (c_p = 0; c_p < top->num_slaves; c_p++)
177 { 178 {
178 if (0 == GNUNET_memcmp(&top->sps[c_p].id, 179 if (0 == GNUNET_memcmp (&top->sps[c_p].id,
179 peer)) 180 peer))
180 return &top->sps[c_p]; 181 return &top->sps[c_p];
181 } 182 }
182 return NULL; 183 return NULL;
183} 184}
184 185
@@ -192,9 +193,9 @@ find_peer(const struct GNUNET_PeerIdentity * peer)
192 * @return the `struct BenchmarkPartner` of @a peer 193 * @return the `struct BenchmarkPartner` of @a peer
193 */ 194 */
194static void * 195static void *
195comm_connect_cb(void *cls, 196comm_connect_cb (void *cls,
196 const struct GNUNET_PeerIdentity *peer, 197 const struct GNUNET_PeerIdentity *peer,
197 struct GNUNET_MQ_Handle *mq) 198 struct GNUNET_MQ_Handle *mq)
198{ 199{
199 struct BenchmarkPeer *me = cls; 200 struct BenchmarkPeer *me = cls;
200 struct BenchmarkPeer *remote; 201 struct BenchmarkPeer *remote;
@@ -203,60 +204,60 @@ comm_connect_cb(void *cls,
203 int c; 204 int c;
204 int completed; 205 int completed;
205 206
206 remote = find_peer(peer); 207 remote = find_peer (peer);
207 if (NULL == remote) 208 if (NULL == remote)
208 { 209 {
209 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, 210 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
210 "Unknown peer connected: `%s'\n", 211 "Unknown peer connected: `%s'\n",
211 GNUNET_i2s(peer)); 212 GNUNET_i2s (peer));
212 GNUNET_break(0); 213 GNUNET_break (0);
213 return NULL; 214 return NULL;
214 } 215 }
215 216
216 id = GNUNET_strdup(GNUNET_i2s(&me->id)); 217 id = GNUNET_strdup (GNUNET_i2s (&me->id));
217 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 218 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
218 "%s [%u] `%s' connected to %s [%u] %s\n", 219 "%s [%u] `%s' connected to %s [%u] %s\n",
219 (me->master == GNUNET_YES) ? "Master" : "Slave", 220 (me->master == GNUNET_YES) ? "Master" : "Slave",
220 me->no, 221 me->no,
221 id, 222 id,
222 (remote->master == GNUNET_YES) ? "Master" : "Slave", 223 (remote->master == GNUNET_YES) ? "Master" : "Slave",
223 remote->no, 224 remote->no,
224 GNUNET_i2s(peer)); 225 GNUNET_i2s (peer));
225 226
226 me->core_connections++; 227 me->core_connections++;
227 if ((GNUNET_YES == me->master) && 228 if ((GNUNET_YES == me->master) &&
228 (GNUNET_NO == remote->master) && 229 (GNUNET_NO == remote->master) &&
229 (GNUNET_NO == top->state.connected_CORE)) 230 (GNUNET_NO == top->state.connected_CORE))
231 {
232 me->core_slave_connections++;
233
234 if (me->core_slave_connections == top->num_slaves)
235 {
236 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
237 "Master [%u] connected all slaves\n",
238 me->no);
239 }
240 completed = GNUNET_YES;
241 for (c = 0; c < top->num_masters; c++)
230 { 242 {
231 me->core_slave_connections++; 243 if (top->mps[c].core_slave_connections != top->num_slaves)
232 244 completed = GNUNET_NO;
233 if (me->core_slave_connections == top->num_slaves)
234 {
235 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
236 "Master [%u] connected all slaves\n",
237 me->no);
238 }
239 completed = GNUNET_YES;
240 for (c = 0; c < top->num_masters; c++)
241 {
242 if (top->mps[c].core_slave_connections != top->num_slaves)
243 completed = GNUNET_NO;
244 }
245 if (GNUNET_YES == completed)
246 {
247 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
248 "All master peers connected all slave peers\n");
249 top->state.connected_CORE = GNUNET_YES;
250 /* Notify about setup done */
251 if (NULL != top->done_cb)
252 top->done_cb(top->done_cb_cls,
253 top->mps,
254 top->sps);
255 }
256 } 245 }
257 GNUNET_free(id); 246 if (GNUNET_YES == completed)
258 p = find_partner(me, 247 {
259 peer); 248 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
249 "All master peers connected all slave peers\n");
250 top->state.connected_CORE = GNUNET_YES;
251 /* Notify about setup done */
252 if (NULL != top->done_cb)
253 top->done_cb (top->done_cb_cls,
254 top->mps,
255 top->sps);
256 }
257 }
258 GNUNET_free (id);
259 p = find_partner (me,
260 peer);
260 if (NULL != p) 261 if (NULL != p)
261 p->mq = mq; 262 p->mq = mq;
262 return p; 263 return p;
@@ -269,9 +270,9 @@ comm_connect_cb(void *cls,
269 * @param internal_cls the `struct BenchmarkPartner` of @a peer 270 * @param internal_cls the `struct BenchmarkPartner` of @a peer
270 */ 271 */
271static void 272static void
272comm_disconnect_cb(void *cls, 273comm_disconnect_cb (void *cls,
273 const struct GNUNET_PeerIdentity *peer, 274 const struct GNUNET_PeerIdentity *peer,
274 void *internal_cls) 275 void *internal_cls)
275{ 276{
276 struct BenchmarkPeer *me = cls; 277 struct BenchmarkPeer *me = cls;
277 struct BenchmarkPartner *p = internal_cls; 278 struct BenchmarkPartner *p = internal_cls;
@@ -280,170 +281,170 @@ comm_disconnect_cb(void *cls,
280 if (NULL == p) 281 if (NULL == p)
281 return; 282 return;
282 283
283 id = GNUNET_strdup(GNUNET_i2s(&me->id)); 284 id = GNUNET_strdup (GNUNET_i2s (&me->id));
284 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 285 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
285 "%s disconnected from %s\n", 286 "%s disconnected from %s\n",
286 id, 287 id,
287 GNUNET_i2s(peer)); 288 GNUNET_i2s (peer));
288 GNUNET_assert(me->core_connections > 0); 289 GNUNET_assert (me->core_connections > 0);
289 me->core_connections--; 290 me->core_connections--;
290 291
291 if ((GNUNET_YES == top->state.benchmarking) && 292 if ((GNUNET_YES == top->state.benchmarking) &&
292 ((GNUNET_YES == me->master) || 293 ((GNUNET_YES == me->master) ||
293 (GNUNET_YES == p->dest->master))) 294 (GNUNET_YES == p->dest->master)))
294 { 295 {
295 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, 296 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
296 "%s disconnected from %s while benchmarking\n", 297 "%s disconnected from %s while benchmarking\n",
297 id, 298 id,
298 GNUNET_i2s(peer)); 299 GNUNET_i2s (peer));
299 } 300 }
300 GNUNET_free(id); 301 GNUNET_free (id);
301} 302}
302 303
303 304
304static void 305static void
305handle_pong(void *cls, 306handle_pong (void *cls,
306 const struct TestMessage *message) 307 const struct TestMessage *message)
307{ 308{
308 struct BenchmarkPartner *p = cls; 309 struct BenchmarkPartner *p = cls;
309 310
310 GNUNET_ATS_TEST_traffic_handle_pong(p); 311 GNUNET_ATS_TEST_traffic_handle_pong (p);
311} 312}
312 313
313 314
314static void 315static void
315handle_ping(void *cls, 316handle_ping (void *cls,
316 const struct TestMessage *message) 317 const struct TestMessage *message)
317{ 318{
318 struct BenchmarkPartner *p = cls; 319 struct BenchmarkPartner *p = cls;
319 320
320 GNUNET_ATS_TEST_traffic_handle_ping(p); 321 GNUNET_ATS_TEST_traffic_handle_ping (p);
321} 322}
322 323
323 324
324static void * 325static void *
325transport_connect_adapter(void *cls, 326transport_connect_adapter (void *cls,
326 const struct GNUNET_CONFIGURATION_Handle *cfg) 327 const struct GNUNET_CONFIGURATION_Handle *cfg)
327{ 328{
328 struct BenchmarkPeer *me = cls; 329 struct BenchmarkPeer *me = cls;
329 struct GNUNET_MQ_MessageHandler handlers[] = { 330 struct GNUNET_MQ_MessageHandler handlers[] = {
330 GNUNET_MQ_hd_fixed_size(ping, 331 GNUNET_MQ_hd_fixed_size (ping,
331 TEST_MESSAGE_TYPE_PING, 332 TEST_MESSAGE_TYPE_PING,
332 struct TestMessage, 333 struct TestMessage,
333 me), 334 me),
334 GNUNET_MQ_hd_fixed_size(pong, 335 GNUNET_MQ_hd_fixed_size (pong,
335 TEST_MESSAGE_TYPE_PONG, 336 TEST_MESSAGE_TYPE_PONG,
336 struct TestMessage, 337 struct TestMessage,
337 me), 338 me),
338 GNUNET_MQ_handler_end() 339 GNUNET_MQ_handler_end ()
339 }; 340 };
340 341
341 me->th = GNUNET_TRANSPORT_core_connect(cfg, 342 me->th = GNUNET_TRANSPORT_core_connect (cfg,
342 &me->id, 343 &me->id,
343 handlers, 344 handlers,
344 me, 345 me,
345 &comm_connect_cb, 346 &comm_connect_cb,
346 &comm_disconnect_cb, 347 &comm_disconnect_cb,
347 NULL); 348 NULL);
348 if (NULL == me->th) 349 if (NULL == me->th)
349 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, 350 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
350 "Failed to create transport connection \n"); 351 "Failed to create transport connection \n");
351 return me->th; 352 return me->th;
352} 353}
353 354
354 355
355static void 356static void
356transport_disconnect_adapter(void *cls, 357transport_disconnect_adapter (void *cls,
357 void *op_result) 358 void *op_result)
358{ 359{
359 struct BenchmarkPeer *me = cls; 360 struct BenchmarkPeer *me = cls;
360 361
361 GNUNET_TRANSPORT_core_disconnect(me->th); 362 GNUNET_TRANSPORT_core_disconnect (me->th);
362 me->th = NULL; 363 me->th = NULL;
363} 364}
364 365
365 366
366static void * 367static void *
367core_connect_adapter(void *cls, 368core_connect_adapter (void *cls,
368 const struct GNUNET_CONFIGURATION_Handle *cfg) 369 const struct GNUNET_CONFIGURATION_Handle *cfg)
369{ 370{
370 struct BenchmarkPeer *me = cls; 371 struct BenchmarkPeer *me = cls;
371 struct GNUNET_MQ_MessageHandler handlers[] = { 372 struct GNUNET_MQ_MessageHandler handlers[] = {
372 GNUNET_MQ_hd_fixed_size(ping, 373 GNUNET_MQ_hd_fixed_size (ping,
373 TEST_MESSAGE_TYPE_PING, 374 TEST_MESSAGE_TYPE_PING,
374 struct TestMessage, 375 struct TestMessage,
375 me), 376 me),
376 GNUNET_MQ_hd_fixed_size(pong, 377 GNUNET_MQ_hd_fixed_size (pong,
377 TEST_MESSAGE_TYPE_PONG, 378 TEST_MESSAGE_TYPE_PONG,
378 struct TestMessage, 379 struct TestMessage,
379 me), 380 me),
380 GNUNET_MQ_handler_end() 381 GNUNET_MQ_handler_end ()
381 }; 382 };
382 383
383 me->ch = GNUNET_CORE_connect(cfg, 384 me->ch = GNUNET_CORE_connect (cfg,
384 me, 385 me,
385 NULL, 386 NULL,
386 &comm_connect_cb, 387 &comm_connect_cb,
387 &comm_disconnect_cb, 388 &comm_disconnect_cb,
388 handlers); 389 handlers);
389 if (NULL == me->ch) 390 if (NULL == me->ch)
390 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, 391 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
391 "Failed to create core connection \n"); 392 "Failed to create core connection \n");
392 return me->ch; 393 return me->ch;
393} 394}
394 395
395 396
396static void 397static void
397core_disconnect_adapter(void *cls, 398core_disconnect_adapter (void *cls,
398 void *op_result) 399 void *op_result)
399{ 400{
400 struct BenchmarkPeer *me = cls; 401 struct BenchmarkPeer *me = cls;
401 402
402 GNUNET_CORE_disconnect(me->ch); 403 GNUNET_CORE_disconnect (me->ch);
403 me->ch = NULL; 404 me->ch = NULL;
404} 405}
405 406
406 407
407static void 408static void
408connect_completion_callback(void *cls, 409connect_completion_callback (void *cls,
409 struct GNUNET_TESTBED_Operation *op, 410 struct GNUNET_TESTBED_Operation *op,
410 const char *emsg) 411 const char *emsg)
411{ 412{
412 struct TestbedConnectOperation *cop = cls; 413 struct TestbedConnectOperation *cop = cls;
413 static int ops = 0; 414 static int ops = 0;
414 int c; 415 int c;
415 416
416 if (NULL == emsg) 417 if (NULL == emsg)
417 { 418 {
418 GNUNET_log(GNUNET_ERROR_TYPE_INFO, 419 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
419 _("Connected master [%u] with slave [%u]\n"), 420 _ ("Connected master [%u] with slave [%u]\n"),
420 cop->master->no, 421 cop->master->no,
421 cop->slave->no); 422 cop->slave->no);
422 } 423 }
423 else 424 else
424 { 425 {
425 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, 426 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
426 _("Failed to connect master peer [%u] with slave [%u]\n"), 427 _ ("Failed to connect master peer [%u] with slave [%u]\n"),
427 cop->master->no, cop->slave->no); 428 cop->master->no, cop->slave->no);
428 GNUNET_break(0); 429 GNUNET_break (0);
429 GNUNET_SCHEDULER_shutdown(); 430 GNUNET_SCHEDULER_shutdown ();
430 } 431 }
431 GNUNET_TESTBED_operation_done(op); 432 GNUNET_TESTBED_operation_done (op);
432 ops++; 433 ops++;
433 for (c = 0; c < top->num_slaves; c++) 434 for (c = 0; c < top->num_slaves; c++)
434 { 435 {
435 if (cop == &cop->master->core_connect_ops[c]) 436 if (cop == &cop->master->core_connect_ops[c])
436 cop->master->core_connect_ops[c].connect_op = NULL; 437 cop->master->core_connect_ops[c].connect_op = NULL;
437 } 438 }
438 if (ops == top->num_masters * top->num_slaves) 439 if (ops == top->num_masters * top->num_slaves)
439 { 440 {
440 top->state.connected_PEERS = GNUNET_YES; 441 top->state.connected_PEERS = GNUNET_YES;
441 } 442 }
442} 443}
443 444
444 445
445static void 446static void
446do_connect_peers(void *cls) 447do_connect_peers (void *cls)
447{ 448{
448 int c_m; 449 int c_m;
449 int c_s; 450 int c_s;
@@ -453,143 +454,144 @@ do_connect_peers(void *cls)
453 (top->state.connected_COMM_service == GNUNET_NO)) 454 (top->state.connected_COMM_service == GNUNET_NO))
454 return; 455 return;
455 456
456 GNUNET_log(GNUNET_ERROR_TYPE_INFO, 457 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
457 "Connecting peers on CORE level\n"); 458 "Connecting peers on CORE level\n");
458 for (c_m = 0; c_m < top->num_masters; c_m++) 459 for (c_m = 0; c_m < top->num_masters; c_m++)
460 {
461 p = &top->mps[c_m];
462 p->core_connect_ops = GNUNET_malloc (top->num_slaves
463 * sizeof(struct
464 TestbedConnectOperation));
465
466 for (c_s = 0; c_s < top->num_slaves; c_s++)
459 { 467 {
460 p = &top->mps[c_m]; 468 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
461 p->core_connect_ops = GNUNET_malloc(top->num_slaves * 469 "Connecting master [%u] with slave [%u]\n",
462 sizeof(struct TestbedConnectOperation)); 470 p->no,
463 471 top->sps[c_s].no);
464 for (c_s = 0; c_s < top->num_slaves; c_s++) 472 p->core_connect_ops[c_s].master = p;
465 { 473 p->core_connect_ops[c_s].slave = &top->sps[c_s];
466 GNUNET_log(GNUNET_ERROR_TYPE_INFO, 474 p->core_connect_ops[c_s].connect_op
467 "Connecting master [%u] with slave [%u]\n", 475 = GNUNET_TESTBED_overlay_connect (NULL,
468 p->no, 476 &connect_completion_callback,
469 top->sps[c_s].no); 477 &p->core_connect_ops[c_s],
470 p->core_connect_ops[c_s].master = p; 478 top->sps[c_s].peer,
471 p->core_connect_ops[c_s].slave = &top->sps[c_s]; 479 p->peer);
472 p->core_connect_ops[c_s].connect_op 480 if (NULL == p->core_connect_ops[c_s].connect_op)
473 = GNUNET_TESTBED_overlay_connect(NULL, 481 {
474 &connect_completion_callback, 482 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
475 &p->core_connect_ops[c_s], 483 "Could not connect master [%u] and slave [%u]\n",
476 top->sps[c_s].peer, 484 p->no,
477 p->peer); 485 top->sps[c_s].no);
478 if (NULL == p->core_connect_ops[c_s].connect_op) 486 GNUNET_break (0);
479 { 487 GNUNET_SCHEDULER_shutdown ();
480 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, 488 return;
481 "Could not connect master [%u] and slave [%u]\n", 489 }
482 p->no,
483 top->sps[c_s].no);
484 GNUNET_break(0);
485 GNUNET_SCHEDULER_shutdown();
486 return;
487 }
488 }
489 } 490 }
491 }
490} 492}
491 493
492 494
493static void 495static void
494comm_connect_completion_cb(void *cls, 496comm_connect_completion_cb (void *cls,
495 struct GNUNET_TESTBED_Operation *op, 497 struct GNUNET_TESTBED_Operation *op,
496 void *ca_result, 498 void *ca_result,
497 const char *emsg) 499 const char *emsg)
498{ 500{
499 static int comm_done = 0; 501 static int comm_done = 0;
500 502
501 if ((NULL != emsg) || (NULL == ca_result)) 503 if ((NULL != emsg) || (NULL == ca_result))
502 { 504 {
503 GNUNET_log(GNUNET_ERROR_TYPE_INFO, 505 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
504 "Initialization failed, shutdown\n"); 506 "Initialization failed, shutdown\n");
505 GNUNET_break(0); 507 GNUNET_break (0);
506 GNUNET_SCHEDULER_shutdown(); 508 GNUNET_SCHEDULER_shutdown ();
507 return; 509 return;
508 } 510 }
509 comm_done++; 511 comm_done++;
510 512
511 if (comm_done == top->num_slaves + top->num_masters) 513 if (comm_done == top->num_slaves + top->num_masters)
512 { 514 {
513 GNUNET_log(GNUNET_ERROR_TYPE_INFO, 515 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
514 "Connected to all %s services\n", 516 "Connected to all %s services\n",
515 (GNUNET_YES == top->test_core) ? "CORE" : "TRANSPORT"); 517 (GNUNET_YES == top->test_core) ? "CORE" : "TRANSPORT");
516 top->state.connected_COMM_service = GNUNET_YES; 518 top->state.connected_COMM_service = GNUNET_YES;
517 GNUNET_SCHEDULER_add_now(&do_connect_peers, 519 GNUNET_SCHEDULER_add_now (&do_connect_peers,
518 NULL); 520 NULL);
519 } 521 }
520} 522}
521 523
522 524
523static void 525static void
524do_comm_connect(void *cls) 526do_comm_connect (void *cls)
525{ 527{
526 int c_s; 528 int c_s;
527 int c_m; 529 int c_m;
528 530
529 GNUNET_log(GNUNET_ERROR_TYPE_INFO, 531 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
530 "Connecting to all %s services\n", 532 "Connecting to all %s services\n",
531 (GNUNET_YES == top->test_core) ? "CORE" : "TRANSPORT"); 533 (GNUNET_YES == top->test_core) ? "CORE" : "TRANSPORT");
532 for (c_m = 0; c_m < top->num_masters; c_m++) 534 for (c_m = 0; c_m < top->num_masters; c_m++)
535 {
536 if (GNUNET_YES == top->test_core)
537 top->mps[c_m].comm_op
538 = GNUNET_TESTBED_service_connect (NULL,
539 top->mps[c_m].peer,
540 "core",
541 &comm_connect_completion_cb,
542 NULL,
543 &core_connect_adapter,
544 &core_disconnect_adapter,
545 &top->mps[c_m]);
546 else
533 { 547 {
534 if (GNUNET_YES == top->test_core) 548 top->mps[c_m].comm_op
535 top->mps[c_m].comm_op 549 = GNUNET_TESTBED_service_connect (NULL,
536 = GNUNET_TESTBED_service_connect(NULL, 550 top->mps[c_m].peer,
537 top->mps[c_m].peer, 551 "transport",
538 "core", 552 &comm_connect_completion_cb,
539 &comm_connect_completion_cb, 553 NULL,
540 NULL, 554 &transport_connect_adapter,
541 &core_connect_adapter, 555 &transport_disconnect_adapter,
542 &core_disconnect_adapter, 556 &top->mps[c_m]);
543 &top->mps[c_m]);
544 else
545 {
546 top->mps[c_m].comm_op
547 = GNUNET_TESTBED_service_connect(NULL,
548 top->mps[c_m].peer,
549 "transport",
550 &comm_connect_completion_cb,
551 NULL,
552 &transport_connect_adapter,
553 &transport_disconnect_adapter,
554 &top->mps[c_m]);
555 }
556 } 557 }
558 }
557 559
558 for (c_s = 0; c_s < top->num_slaves; c_s++) 560 for (c_s = 0; c_s < top->num_slaves; c_s++)
561 {
562 if (GNUNET_YES == top->test_core)
563 top->sps[c_s].comm_op
564 = GNUNET_TESTBED_service_connect (NULL,
565 top->sps[c_s].peer,
566 "core",
567 &comm_connect_completion_cb,
568 NULL,
569 &core_connect_adapter,
570 &core_disconnect_adapter,
571 &top->sps[c_s]);
572 else
559 { 573 {
560 if (GNUNET_YES == top->test_core) 574 top->sps[c_s].comm_op
561 top->sps[c_s].comm_op 575 = GNUNET_TESTBED_service_connect (NULL,
562 = GNUNET_TESTBED_service_connect(NULL, 576 top->sps[c_s].peer,
563 top->sps[c_s].peer, 577 "transport",
564 "core", 578 &comm_connect_completion_cb,
565 &comm_connect_completion_cb, 579 NULL,
566 NULL, 580 &transport_connect_adapter,
567 &core_connect_adapter, 581 &transport_disconnect_adapter,
568 &core_disconnect_adapter, 582 &top->sps[c_s]);
569 &top->sps[c_s]);
570 else
571 {
572 top->sps[c_s].comm_op
573 = GNUNET_TESTBED_service_connect(NULL,
574 top->sps[c_s].peer,
575 "transport",
576 &comm_connect_completion_cb,
577 NULL,
578 &transport_connect_adapter,
579 &transport_disconnect_adapter,
580 &top->sps[c_s]);
581 }
582 } 583 }
584 }
583} 585}
584 586
585 587
586static void 588static void
587ats_performance_info_cb(void *cls, 589ats_performance_info_cb (void *cls,
588 const struct GNUNET_HELLO_Address *address, 590 const struct GNUNET_HELLO_Address *address,
589 int address_active, 591 int address_active,
590 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, 592 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out,
591 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, 593 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
592 const struct GNUNET_ATS_Properties *ats_prop) 594 const struct GNUNET_ATS_Properties *ats_prop)
593{ 595{
594 struct BenchmarkPeer *me = cls; 596 struct BenchmarkPeer *me = cls;
595 struct BenchmarkPartner *p; 597 struct BenchmarkPartner *p;
@@ -597,36 +599,36 @@ ats_performance_info_cb(void *cls,
597 char *peer_id; 599 char *peer_id;
598 600
599 if (NULL == address) 601 if (NULL == address)
600 { 602 {
601 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, 603 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
602 "Peer %u: ATS Service disconnected!\n", 604 "Peer %u: ATS Service disconnected!\n",
603 me->no); 605 me->no);
604 return; 606 return;
605 } 607 }
606 608
607 p = find_partner(me, 609 p = find_partner (me,
608 &address->peer); 610 &address->peer);
609 if (NULL == p) 611 if (NULL == p)
610 { 612 {
611 /* This is not one of my partners 613 /* This is not one of my partners
612 * Will happen since the peers will connect to each other due to gossiping 614 * Will happen since the peers will connect to each other due to gossiping
613 */ 615 */
614 return; 616 return;
615 } 617 }
616 peer_id = GNUNET_strdup(GNUNET_i2s(&me->id)); 618 peer_id = GNUNET_strdup (GNUNET_i2s (&me->id));
617 619
618 log = GNUNET_NO; 620 log = GNUNET_NO;
619 if ((p->bandwidth_in != ntohl(bandwidth_in.value__)) || 621 if ((p->bandwidth_in != ntohl (bandwidth_in.value__)) ||
620 (p->bandwidth_out != ntohl(bandwidth_out.value__))) 622 (p->bandwidth_out != ntohl (bandwidth_out.value__)))
621 log = GNUNET_YES; 623 log = GNUNET_YES;
622 p->bandwidth_in = ntohl(bandwidth_in.value__); 624 p->bandwidth_in = ntohl (bandwidth_in.value__);
623 p->bandwidth_out = ntohl(bandwidth_out.value__); 625 p->bandwidth_out = ntohl (bandwidth_out.value__);
624 626
625 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 627 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
626 "%s [%u] received ATS information: %s\n", 628 "%s [%u] received ATS information: %s\n",
627 (GNUNET_YES == p->me->master) ? "Master" : "Slave", 629 (GNUNET_YES == p->me->master) ? "Master" : "Slave",
628 p->me->no, 630 p->me->no,
629 GNUNET_i2s(&p->dest->id)); 631 GNUNET_i2s (&p->dest->id));
630 632
631 p->props.utilization_out = ats_prop->utilization_out; 633 p->props.utilization_out = ats_prop->utilization_out;
632 p->props.utilization_in = ats_prop->utilization_in; 634 p->props.utilization_in = ats_prop->utilization_in;
@@ -635,137 +637,137 @@ ats_performance_info_cb(void *cls,
635 p->props.distance = ats_prop->distance; 637 p->props.distance = ats_prop->distance;
636 638
637 if (GNUNET_YES == log) 639 if (GNUNET_YES == log)
638 top->ats_perf_cb(cls, address, 640 top->ats_perf_cb (cls, address,
639 address_active, 641 address_active,
640 bandwidth_out, 642 bandwidth_out,
641 bandwidth_in, 643 bandwidth_in,
642 ats_prop); 644 ats_prop);
643 GNUNET_free(peer_id); 645 GNUNET_free (peer_id);
644} 646}
645 647
646 648
647static void * 649static void *
648ats_perf_connect_adapter(void *cls, 650ats_perf_connect_adapter (void *cls,
649 const struct GNUNET_CONFIGURATION_Handle *cfg) 651 const struct GNUNET_CONFIGURATION_Handle *cfg)
650{ 652{
651 struct BenchmarkPeer *me = cls; 653 struct BenchmarkPeer *me = cls;
652 654
653 me->ats_perf_handle 655 me->ats_perf_handle
654 = GNUNET_ATS_performance_init(cfg, 656 = GNUNET_ATS_performance_init (cfg,
655 &ats_performance_info_cb, 657 &ats_performance_info_cb,
656 me); 658 me);
657 if (NULL == me->ats_perf_handle) 659 if (NULL == me->ats_perf_handle)
658 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, 660 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
659 "Failed to create ATS performance handle \n"); 661 "Failed to create ATS performance handle \n");
660 return me->ats_perf_handle; 662 return me->ats_perf_handle;
661} 663}
662 664
663 665
664static void 666static void
665ats_perf_disconnect_adapter(void *cls, 667ats_perf_disconnect_adapter (void *cls,
666 void *op_result) 668 void *op_result)
667{ 669{
668 struct BenchmarkPeer *me = cls; 670 struct BenchmarkPeer *me = cls;
669 671
670 GNUNET_ATS_performance_done(me->ats_perf_handle); 672 GNUNET_ATS_performance_done (me->ats_perf_handle);
671 me->ats_perf_handle = NULL; 673 me->ats_perf_handle = NULL;
672} 674}
673 675
674 676
675static void 677static void
676ats_connect_completion_cb(void *cls, 678ats_connect_completion_cb (void *cls,
677 struct GNUNET_TESTBED_Operation *op, 679 struct GNUNET_TESTBED_Operation *op,
678 void *ca_result, 680 void *ca_result,
679 const char *emsg) 681 const char *emsg)
680{ 682{
681 static int op_done = 0; 683 static int op_done = 0;
682 684
683 if ((NULL != emsg) || (NULL == ca_result)) 685 if ((NULL != emsg) || (NULL == ca_result))
684 { 686 {
685 GNUNET_log(GNUNET_ERROR_TYPE_INFO, 687 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
686 "Initialization failed, shutdown\n"); 688 "Initialization failed, shutdown\n");
687 GNUNET_break(0); 689 GNUNET_break (0);
688 GNUNET_SCHEDULER_shutdown(); 690 GNUNET_SCHEDULER_shutdown ();
689 return; 691 return;
690 } 692 }
691 op_done++; 693 op_done++;
692 if (op_done == (top->num_masters + top->num_slaves)) 694 if (op_done == (top->num_masters + top->num_slaves))
693 { 695 {
694 GNUNET_log(GNUNET_ERROR_TYPE_INFO, 696 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
695 "Connected to all ATS services\n"); 697 "Connected to all ATS services\n");
696 top->state.connected_ATS_service = GNUNET_YES; 698 top->state.connected_ATS_service = GNUNET_YES;
697 GNUNET_SCHEDULER_add_now(&do_comm_connect, 699 GNUNET_SCHEDULER_add_now (&do_comm_connect,
698 NULL); 700 NULL);
699 } 701 }
700} 702}
701 703
702 704
703static void 705static void
704do_connect_ats(void *cls) 706do_connect_ats (void *cls)
705{ 707{
706 int c_m; 708 int c_m;
707 int c_s; 709 int c_s;
708 710
709 GNUNET_log(GNUNET_ERROR_TYPE_INFO, 711 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
710 "Connecting to all ATS services\n"); 712 "Connecting to all ATS services\n");
711 for (c_m = 0; c_m < top->num_masters; c_m++) 713 for (c_m = 0; c_m < top->num_masters; c_m++)
712 { 714 {
713 top->mps[c_m].ats_perf_op 715 top->mps[c_m].ats_perf_op
714 = GNUNET_TESTBED_service_connect(NULL, 716 = GNUNET_TESTBED_service_connect (NULL,
715 top->mps[c_m].peer, 717 top->mps[c_m].peer,
716 "ats", 718 "ats",
717 &ats_connect_completion_cb, 719 &ats_connect_completion_cb,
718 NULL, 720 NULL,
719 &ats_perf_connect_adapter, 721 &ats_perf_connect_adapter,
720 &ats_perf_disconnect_adapter, 722 &ats_perf_disconnect_adapter,
721 &top->mps[c_m]); 723 &top->mps[c_m]);
722 } 724 }
723 725
724 for (c_s = 0; c_s < top->num_slaves; c_s++) 726 for (c_s = 0; c_s < top->num_slaves; c_s++)
725 { 727 {
726 top->sps[c_s].ats_perf_op 728 top->sps[c_s].ats_perf_op
727 = GNUNET_TESTBED_service_connect(NULL, 729 = GNUNET_TESTBED_service_connect (NULL,
728 top->sps[c_s].peer, 730 top->sps[c_s].peer,
729 "ats", 731 "ats",
730 &ats_connect_completion_cb, 732 &ats_connect_completion_cb,
731 NULL, 733 NULL,
732 &ats_perf_connect_adapter, 734 &ats_perf_connect_adapter,
733 &ats_perf_disconnect_adapter, 735 &ats_perf_disconnect_adapter,
734 &top->sps[c_s]); 736 &top->sps[c_s]);
735 } 737 }
736} 738}
737 739
738 740
739 741
740static void 742static void
741peerinformation_cb(void *cb_cls, 743peerinformation_cb (void *cb_cls,
742 struct GNUNET_TESTBED_Operation *op, 744 struct GNUNET_TESTBED_Operation *op,
743 const struct GNUNET_TESTBED_PeerInformation *pinfo, 745 const struct GNUNET_TESTBED_PeerInformation *pinfo,
744 const char *emsg) 746 const char *emsg)
745{ 747{
746 struct BenchmarkPeer *p = cb_cls; 748 struct BenchmarkPeer *p = cb_cls;
747 static int done = 0; 749 static int done = 0;
748 750
749 GNUNET_assert(pinfo->pit == GNUNET_TESTBED_PIT_IDENTITY); 751 GNUNET_assert (pinfo->pit == GNUNET_TESTBED_PIT_IDENTITY);
750 752
751 p->id = *pinfo->result.id; 753 p->id = *pinfo->result.id;
752 GNUNET_log(GNUNET_ERROR_TYPE_INFO, 754 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
753 "%s [%u] has peer id `%s'\n", 755 "%s [%u] has peer id `%s'\n",
754 (p->master == GNUNET_YES) ? "Master" : "Slave", 756 (p->master == GNUNET_YES) ? "Master" : "Slave",
755 p->no, 757 p->no,
756 GNUNET_i2s(&p->id)); 758 GNUNET_i2s (&p->id));
757 759
758 GNUNET_TESTBED_operation_done(op); 760 GNUNET_TESTBED_operation_done (op);
759 p->peer_id_op = NULL; 761 p->peer_id_op = NULL;
760 done++; 762 done++;
761 763
762 if (done == top->num_slaves + top->num_masters) 764 if (done == top->num_slaves + top->num_masters)
763 { 765 {
764 GNUNET_log(GNUNET_ERROR_TYPE_INFO, 766 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
765 "Retrieved all peer ID, connect to ATS\n"); 767 "Retrieved all peer ID, connect to ATS\n");
766 GNUNET_SCHEDULER_add_now(&do_connect_ats, 768 GNUNET_SCHEDULER_add_now (&do_connect_ats,
767 NULL); 769 NULL);
768 } 770 }
769} 771}
770 772
771 773
@@ -782,85 +784,85 @@ peerinformation_cb(void *cb_cls,
782 * failed 784 * failed
783 */ 785 */
784static void 786static void
785main_run(void *cls, 787main_run (void *cls,
786 struct GNUNET_TESTBED_RunHandle *h, 788 struct GNUNET_TESTBED_RunHandle *h,
787 unsigned int num_peers, 789 unsigned int num_peers,
788 struct GNUNET_TESTBED_Peer **peers_, 790 struct GNUNET_TESTBED_Peer **peers_,
789 unsigned int links_succeeded, 791 unsigned int links_succeeded,
790 unsigned int links_failed) 792 unsigned int links_failed)
791{ 793{
792 int c_m; 794 int c_m;
793 int c_s; 795 int c_s;
794 796
795 GNUNET_assert(NULL == cls); 797 GNUNET_assert (NULL == cls);
796 GNUNET_assert(top->num_masters + top->num_slaves == num_peers); 798 GNUNET_assert (top->num_masters + top->num_slaves == num_peers);
797 GNUNET_assert(NULL != peers_); 799 GNUNET_assert (NULL != peers_);
798 800
799 GNUNET_SCHEDULER_add_shutdown(&do_shutdown, 801 GNUNET_SCHEDULER_add_shutdown (&do_shutdown,
800 top); 802 top);
801 803
802 GNUNET_log(GNUNET_ERROR_TYPE_INFO, 804 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
803 "Setting up %u masters and %u slaves\n", 805 "Setting up %u masters and %u slaves\n",
804 top->num_masters, 806 top->num_masters,
805 top->num_slaves); 807 top->num_slaves);
806 808
807 /* Setup master peers */ 809 /* Setup master peers */
808 for (c_m = 0; c_m < top->num_masters; c_m++) 810 for (c_m = 0; c_m < top->num_masters; c_m++)
811 {
812 GNUNET_assert (NULL != peers_[c_m]);
813 top->mps[c_m].peer = peers_[c_m];
814 top->mps[c_m].no = c_m;
815 top->mps[c_m].master = GNUNET_YES;
816 top->mps[c_m].pref_partner = &top->sps[c_m];
817 top->mps[c_m].pref_value = TEST_ATS_PREFERENCE_DEFAULT;
818 top->mps[c_m].partners =
819 GNUNET_malloc (top->num_slaves * sizeof(struct BenchmarkPartner));
820 top->mps[c_m].num_partners = top->num_slaves;
821 /* Initialize partners */
822 for (c_s = 0; c_s < top->num_slaves; c_s++)
809 { 823 {
810 GNUNET_assert(NULL != peers_[c_m]); 824 top->mps[c_m].partners[c_s].me = &top->mps[c_m];
811 top->mps[c_m].peer = peers_[c_m]; 825 top->mps[c_m].partners[c_s].dest = &top->sps[c_s];
812 top->mps[c_m].no = c_m;
813 top->mps[c_m].master = GNUNET_YES;
814 top->mps[c_m].pref_partner = &top->sps[c_m];
815 top->mps[c_m].pref_value = TEST_ATS_PREFERENCE_DEFAULT;
816 top->mps[c_m].partners =
817 GNUNET_malloc(top->num_slaves * sizeof(struct BenchmarkPartner));
818 top->mps[c_m].num_partners = top->num_slaves;
819 /* Initialize partners */
820 for (c_s = 0; c_s < top->num_slaves; c_s++)
821 {
822 top->mps[c_m].partners[c_s].me = &top->mps[c_m];
823 top->mps[c_m].partners[c_s].dest = &top->sps[c_s];
824 }
825 /* Get configuration */
826 top->mps[c_m].peer_id_op
827 = GNUNET_TESTBED_peer_get_information(top->mps[c_m].peer,
828 GNUNET_TESTBED_PIT_IDENTITY,
829 &peerinformation_cb,
830 &top->mps[c_m]);
831 } 826 }
827 /* Get configuration */
828 top->mps[c_m].peer_id_op
829 = GNUNET_TESTBED_peer_get_information (top->mps[c_m].peer,
830 GNUNET_TESTBED_PIT_IDENTITY,
831 &peerinformation_cb,
832 &top->mps[c_m]);
833 }
832 834
833 /* Setup slave peers */ 835 /* Setup slave peers */
834 for (c_s = 0; c_s < top->num_slaves; c_s++) 836 for (c_s = 0; c_s < top->num_slaves; c_s++)
837 {
838 GNUNET_assert (NULL != peers_[c_s + top->num_masters]);
839 top->sps[c_s].peer = peers_[c_s + top->num_masters];
840 top->sps[c_s].no = c_s + top->num_masters;
841 top->sps[c_s].master = GNUNET_NO;
842 top->sps[c_s].partners =
843 GNUNET_new_array (top->num_masters,
844 struct BenchmarkPartner);
845 top->sps[c_s].num_partners = top->num_masters;
846 /* Initialize partners */
847 for (c_m = 0; c_m < top->num_masters; c_m++)
835 { 848 {
836 GNUNET_assert(NULL != peers_[c_s + top->num_masters]); 849 top->sps[c_s].partners[c_m].me = &top->sps[c_s];
837 top->sps[c_s].peer = peers_[c_s + top->num_masters]; 850 top->sps[c_s].partners[c_m].dest = &top->mps[c_m];
838 top->sps[c_s].no = c_s + top->num_masters; 851
839 top->sps[c_s].master = GNUNET_NO; 852 /* Initialize properties */
840 top->sps[c_s].partners = 853 top->sps[c_s].partners[c_m].props.delay = GNUNET_TIME_UNIT_ZERO;
841 GNUNET_new_array(top->num_masters, 854 top->sps[c_s].partners[c_m].props.distance = 0;
842 struct BenchmarkPartner); 855 top->sps[c_s].partners[c_m].props.scope = GNUNET_NT_UNSPECIFIED;
843 top->sps[c_s].num_partners = top->num_masters; 856 top->sps[c_s].partners[c_m].props.utilization_in = 0;
844 /* Initialize partners */ 857 top->sps[c_s].partners[c_m].props.utilization_out = 0;
845 for (c_m = 0; c_m < top->num_masters; c_m++)
846 {
847 top->sps[c_s].partners[c_m].me = &top->sps[c_s];
848 top->sps[c_s].partners[c_m].dest = &top->mps[c_m];
849
850 /* Initialize properties */
851 top->sps[c_s].partners[c_m].props.delay = GNUNET_TIME_UNIT_ZERO;
852 top->sps[c_s].partners[c_m].props.distance = 0;
853 top->sps[c_s].partners[c_m].props.scope = GNUNET_NT_UNSPECIFIED;
854 top->sps[c_s].partners[c_m].props.utilization_in = 0;
855 top->sps[c_s].partners[c_m].props.utilization_out = 0;
856 }
857 /* Get configuration */
858 top->sps[c_s].peer_id_op
859 = GNUNET_TESTBED_peer_get_information(top->sps[c_s].peer,
860 GNUNET_TESTBED_PIT_IDENTITY,
861 &peerinformation_cb,
862 &top->sps[c_s]);
863 } 858 }
859 /* Get configuration */
860 top->sps[c_s].peer_id_op
861 = GNUNET_TESTBED_peer_get_information (top->sps[c_s].peer,
862 GNUNET_TESTBED_PIT_IDENTITY,
863 &peerinformation_cb,
864 &top->sps[c_s]);
865 }
864} 866}
865 867
866 868
@@ -871,26 +873,26 @@ main_run(void *cls,
871 * @param event the controller event 873 * @param event the controller event
872 */ 874 */
873static void 875static void
874controller_event_cb(void *cls, 876controller_event_cb (void *cls,
875 const struct GNUNET_TESTBED_EventInformation *event) 877 const struct GNUNET_TESTBED_EventInformation *event)
876{ 878{
877 switch (event->type) 879 switch (event->type)
878 { 880 {
879 case GNUNET_TESTBED_ET_CONNECT: 881 case GNUNET_TESTBED_ET_CONNECT:
880 break; 882 break;
881 883
882 case GNUNET_TESTBED_ET_OPERATION_FINISHED: 884 case GNUNET_TESTBED_ET_OPERATION_FINISHED:
883 break; 885 break;
884 886
885 default: 887 default:
886 GNUNET_break(0); 888 GNUNET_break (0);
887 GNUNET_SCHEDULER_shutdown(); 889 GNUNET_SCHEDULER_shutdown ();
888 } 890 }
889} 891}
890 892
891 893
892struct BenchmarkPeer * 894struct BenchmarkPeer *
893GNUNET_ATS_TEST_get_peer(int src) 895GNUNET_ATS_TEST_get_peer (int src)
894{ 896{
895 if (src > top->num_masters) 897 if (src > top->num_masters)
896 return NULL; 898 return NULL;
@@ -899,8 +901,8 @@ GNUNET_ATS_TEST_get_peer(int src)
899 901
900 902
901struct BenchmarkPartner * 903struct BenchmarkPartner *
902GNUNET_ATS_TEST_get_partner(int src, 904GNUNET_ATS_TEST_get_partner (int src,
903 int dest) 905 int dest)
904{ 906{
905 if (src > top->num_masters) 907 if (src > top->num_masters)
906 return NULL; 908 return NULL;
@@ -923,37 +925,39 @@ GNUNET_ATS_TEST_get_partner(int src,
923 * @param log_request_cb callback to call when logging is required 925 * @param log_request_cb callback to call when logging is required
924 */ 926 */
925void 927void
926GNUNET_ATS_TEST_create_topology(char *name, char *cfg_file, 928GNUNET_ATS_TEST_create_topology (char *name, char *cfg_file,
927 unsigned int num_slaves, 929 unsigned int num_slaves,
928 unsigned int num_masters, 930 unsigned int num_masters,
929 int test_core, 931 int test_core,
930 GNUNET_ATS_TEST_TopologySetupDoneCallback done_cb, 932 GNUNET_ATS_TEST_TopologySetupDoneCallback
931 void *done_cb_cls, 933 done_cb,
932 GNUNET_ATS_AddressInformationCallback log_request_cb) 934 void *done_cb_cls,
935 GNUNET_ATS_AddressInformationCallback
936 log_request_cb)
933{ 937{
934 top = GNUNET_new(struct GNUNET_ATS_TEST_Topology); 938 top = GNUNET_new (struct GNUNET_ATS_TEST_Topology);
935 top->num_masters = num_masters; 939 top->num_masters = num_masters;
936 top->num_slaves = num_slaves; 940 top->num_slaves = num_slaves;
937 top->done_cb = done_cb; 941 top->done_cb = done_cb;
938 top->done_cb_cls = done_cb_cls; 942 top->done_cb_cls = done_cb_cls;
939 top->test_core = test_core; 943 top->test_core = test_core;
940 top->ats_perf_cb = log_request_cb; 944 top->ats_perf_cb = log_request_cb;
941 top->mps = GNUNET_new_array(num_masters, 945 top->mps = GNUNET_new_array (num_masters,
942 struct BenchmarkPeer); 946 struct BenchmarkPeer);
943 top->sps = GNUNET_new_array(num_slaves, 947 top->sps = GNUNET_new_array (num_slaves,
944 struct BenchmarkPeer); 948 struct BenchmarkPeer);
945 949
946 /* Start topology */ 950 /* Start topology */
947 uint64_t event_mask; 951 uint64_t event_mask;
948 event_mask = 0; 952 event_mask = 0;
949 event_mask |= (1LL << GNUNET_TESTBED_ET_CONNECT); 953 event_mask |= (1LL << GNUNET_TESTBED_ET_CONNECT);
950 event_mask |= (1LL << GNUNET_TESTBED_ET_OPERATION_FINISHED); 954 event_mask |= (1LL << GNUNET_TESTBED_ET_OPERATION_FINISHED);
951 (void)GNUNET_TESTBED_test_run(name, 955 (void) GNUNET_TESTBED_test_run (name,
952 cfg_file, 956 cfg_file,
953 num_slaves + num_masters, 957 num_slaves + num_masters,
954 event_mask, 958 event_mask,
955 &controller_event_cb, NULL, 959 &controller_event_cb, NULL,
956 &main_run, NULL); 960 &main_run, NULL);
957} 961}
958 962
959 963
@@ -961,11 +965,11 @@ GNUNET_ATS_TEST_create_topology(char *name, char *cfg_file,
961 * Shutdown topology 965 * Shutdown topology
962 */ 966 */
963void 967void
964GNUNET_ATS_TEST_shutdown_topology(void) 968GNUNET_ATS_TEST_shutdown_topology (void)
965{ 969{
966 if (NULL == top) 970 if (NULL == top)
967 return; 971 return;
968 GNUNET_SCHEDULER_shutdown(); 972 GNUNET_SCHEDULER_shutdown ();
969} 973}
970 974
971 975