aboutsummaryrefslogtreecommitdiff
path: root/src/ats-tests/ats-testing.c
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/ats-testing.c
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/ats-testing.c')
-rw-r--r--src/ats-tests/ats-testing.c397
1 files changed, 214 insertions, 183 deletions
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 */