summaryrefslogtreecommitdiff
path: root/src/ats-tests/perf_ats.c
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2013-09-18 08:50:22 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2013-09-18 08:50:22 +0000
commit281a7aa769d656ffed541f144b5846205dd45e2d (patch)
tree78362c4873c71b3dd02718822fb7ffb0aa9a022a /src/ats-tests/perf_ats.c
parentba122ae1d2e2c43b5a0832fd7d842bf8b8f5027b (diff)
downloadgnunet-281a7aa769d656ffed541f144b5846205dd45e2d.tar.gz
gnunet-281a7aa769d656ffed541f144b5846205dd45e2d.zip
improved progress
remove master information struct add ats partner
Diffstat (limited to 'src/ats-tests/perf_ats.c')
-rw-r--r--src/ats-tests/perf_ats.c417
1 files changed, 201 insertions, 216 deletions
diff --git a/src/ats-tests/perf_ats.c b/src/ats-tests/perf_ats.c
index 0c36b1fa7..4c2e96877 100644
--- a/src/ats-tests/perf_ats.c
+++ b/src/ats-tests/perf_ats.c
@@ -1,22 +1,22 @@
1/* 1/*
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 (C) 2010-2013 Christian Grothoff (and other contributing authors) 3 (C) 2010-2013 Christian Grothoff (and other contributing authors)
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
7 by the Free Software Foundation; either version 3, or (at your 7 by the Free Software Foundation; either version 3, or (at your
8 option) any later version. 8 option) any later version.
9 9
10 GNUnet is distributed in the hope that it will be useful, but 10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of 11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details. 13 General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the 16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19 */
20/** 20/**
21 * @file ats/perf_ats.c 21 * @file ats/perf_ats.c
22 * @brief ats benchmark: start peers and modify preferences, monitor change over time 22 * @brief ats benchmark: start peers and modify preferences, monitor change over time
@@ -40,7 +40,6 @@
40#define TEST_MESSAGE_SIZE 1000 40#define TEST_MESSAGE_SIZE 1000
41#define TEST_MESSAGE_FREQUENCY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1) 41#define TEST_MESSAGE_FREQUENCY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1)
42 42
43
44/** 43/**
45 * Information about a benchmarking partner 44 * Information about a benchmarking partner
46 */ 45 */
@@ -72,8 +71,8 @@ struct BenchmarkPartner
72 unsigned int bytes_sent; 71 unsigned int bytes_sent;
73 72
74 /** 73 /**
75 * Number of messages received from this partner 74 * Number of messages received from this partner
76 */ 75 */
77 unsigned int messages_received; 76 unsigned int messages_received;
78 77
79 /** 78 /**
@@ -82,17 +81,6 @@ struct BenchmarkPartner
82 unsigned int bytes_received; 81 unsigned int bytes_received;
83}; 82};
84 83
85
86struct MasterInformation
87{
88 int core_slave_connections;
89
90 /**
91 * Testbed connect operation
92 */
93};
94
95
96/** 84/**
97 * Connect peers with testbed 85 * Connect peers with testbed
98 */ 86 */
@@ -114,8 +102,6 @@ struct TestbedConnectOperation
114 struct GNUNET_TESTBED_Operation *connect_op; 102 struct GNUNET_TESTBED_Operation *connect_op;
115}; 103};
116 104
117
118
119/** 105/**
120 * Information we track for a peer in the testbed. 106 * Information we track for a peer in the testbed.
121 */ 107 */
@@ -162,8 +148,8 @@ struct BenchmarkPeer
162 struct GNUNET_ATS_PerformanceHandle *ats_perf_handle; 148 struct GNUNET_ATS_PerformanceHandle *ats_perf_handle;
163 149
164 /** 150 /**
151 * Masters only:
165 * Testbed connect operations to connect masters to slaves 152 * Testbed connect operations to connect masters to slaves
166 * For masters peers only
167 */ 153 */
168 struct TestbedConnectOperation *core_connect_ops; 154 struct TestbedConnectOperation *core_connect_ops;
169 155
@@ -173,14 +159,27 @@ struct BenchmarkPeer
173 struct GNUNET_CORE_Handle *ch; 159 struct GNUNET_CORE_Handle *ch;
174 160
175 /** 161 /**
162 * Masters only:
163 * Peer to set ATS preferences for
164 */
165 struct BenchmarkPeer *pref_partner;
166
167 /**
176 * Array of partners with num_slaves entries (if master) or 168 * Array of partners with num_slaves entries (if master) or
177 * num_master entries (if slave) 169 * num_master entries (if slave)
178 */ 170 */
179 struct BenchmarkPartner *partners; 171 struct BenchmarkPartner *partners;
180 172
173 /**
174 * Number of core connections
175 */
181 int core_connections; 176 int core_connections;
182 177
183 struct MasterInformation mi; 178 /**
179 * Masters only:
180 * Number of connections to slave peers
181 */
182 int core_slave_connections;
184 183
185 /** 184 /**
186 * Total number of messages this peer has sent 185 * Total number of messages this peer has sent
@@ -203,7 +202,6 @@ struct BenchmarkPeer
203 unsigned int total_bytes_received; 202 unsigned int total_bytes_received;
204}; 203};
205 204
206
207/** 205/**
208 * Overall state of the performance benchmark 206 * Overall state of the performance benchmark
209 */ 207 */
@@ -225,7 +223,6 @@ struct BenchmarkState
225 int benchmarking; 223 int benchmarking;
226}; 224};
227 225
228
229/** 226/**
230 * Shutdown task 227 * Shutdown task
231 */ 228 */
@@ -280,7 +277,6 @@ struct BenchmarkPeer *sps;
280 */ 277 */
281static struct BenchmarkState state; 278static struct BenchmarkState state;
282 279
283
284static void 280static void
285evaluate () 281evaluate ()
286{ 282{
@@ -293,27 +289,24 @@ evaluate ()
293 for (c_m = 0; c_m < num_masters; c_m++) 289 for (c_m = 0; c_m < num_masters; c_m++)
294 { 290 {
295 mp = &mps[c_m]; 291 mp = &mps[c_m];
296 fprintf (stderr, _("Master [%u]: sent: %u KiB in %u sec. = %u KiB/s, received: %u KiB in %u sec. = %u KiB/s\n"), 292 fprintf (stderr,
297 mp->no, 293 _("Master [%u]: sent: %u KiB in %u sec. = %u KiB/s, received: %u KiB in %u sec. = %u KiB/s\n"),
298 mp->total_bytes_sent / 1024, 294 mp->no, mp->total_bytes_sent / 1024, duration,
299 duration, 295 (mp->total_bytes_sent / 1024) / duration,
300 (mp->total_bytes_sent / 1024) / duration , 296 mp->total_bytes_received / 1024, duration,
301 mp->total_bytes_received / 1024,
302 duration,
303 (mp->total_bytes_received / 1024) / duration); 297 (mp->total_bytes_received / 1024) / duration);
304 298
305 for (c_s = 0; c_s < num_slaves; c_s ++) 299 for (c_s = 0; c_s < num_slaves; c_s++)
306 { 300 {
307 fprintf (stderr, "Master [%u] -> Slave [%u]: sent %u KiB/s, received %u KiB/s \n", 301 fprintf (stderr,
308 mp->no, 302 "Master [%u] -> Slave [%u]: sent %u KiB/s, received %u KiB/s \n",
309 mp->partners[c_s].dest->no, 303 mp->no, mp->partners[c_s].dest->no,
310 (mp->partners[c_s].bytes_sent / 1024) / duration, 304 (mp->partners[c_s].bytes_sent / 1024) / duration,
311 (mp->partners[c_s].bytes_received / 1024) / duration); 305 (mp->partners[c_s].bytes_received / 1024) / duration);
312 } 306 }
313 } 307 }
314} 308}
315 309
316
317/** 310/**
318 * Shutdown nicely 311 * Shutdown nicely
319 * 312 *
@@ -330,12 +323,12 @@ do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
330 shutdown_task = GNUNET_SCHEDULER_NO_TASK; 323 shutdown_task = GNUNET_SCHEDULER_NO_TASK;
331 if (GNUNET_SCHEDULER_NO_TASK != progress_task) 324 if (GNUNET_SCHEDULER_NO_TASK != progress_task)
332 { 325 {
333 fprintf (stderr, "\n"); 326 fprintf (stderr, "0\n");
334 GNUNET_SCHEDULER_cancel (progress_task); 327 GNUNET_SCHEDULER_cancel (progress_task);
335 } 328 }
336 progress_task = GNUNET_SCHEDULER_NO_TASK; 329 progress_task = GNUNET_SCHEDULER_NO_TASK;
337 330
338 evaluate(); 331 evaluate ();
339 state.benchmarking = GNUNET_NO; 332 state.benchmarking = GNUNET_NO;
340 GNUNET_log(GNUNET_ERROR_TYPE_INFO, _("Benchmarking done\n")); 333 GNUNET_log(GNUNET_ERROR_TYPE_INFO, _("Benchmarking done\n"));
341 334
@@ -378,12 +371,11 @@ do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
378 GNUNET_TESTBED_operation_done (mps[c_m].core_op); 371 GNUNET_TESTBED_operation_done (mps[c_m].core_op);
379 mps[c_m].core_op = NULL; 372 mps[c_m].core_op = NULL;
380 } 373 }
381 GNUNET_free (mps[c_m].core_connect_ops); 374 GNUNET_free(mps[c_m].core_connect_ops);
382 GNUNET_free (mps[c_m].partners); 375 GNUNET_free(mps[c_m].partners);
383 mps[c_m].partners = NULL; 376 mps[c_m].partners = NULL;
384 } 377 }
385 378
386
387 for (c_s = 0; c_s < num_slaves; c_s++) 379 for (c_s = 0; c_s < num_slaves; c_s++)
388 { 380 {
389 if (NULL != sps[c_s].peer_id_op) 381 if (NULL != sps[c_s].peer_id_op)
@@ -401,7 +393,6 @@ do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
401 } 393 }
402 } 394 }
403 395
404
405 if (NULL != sps[c_s].ats_perf_op) 396 if (NULL != sps[c_s].ats_perf_op)
406 { 397 {
407 GNUNET_TESTBED_operation_done (sps[c_s].ats_perf_op); 398 GNUNET_TESTBED_operation_done (sps[c_s].ats_perf_op);
@@ -413,14 +404,13 @@ do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
413 sps[c_s].core_op = NULL; 404 sps[c_s].core_op = NULL;
414 } 405 }
415 406
416 GNUNET_free (sps[c_s].partners); 407 GNUNET_free(sps[c_s].partners);
417 sps[c_s].partners = NULL; 408 sps[c_s].partners = NULL;
418 } 409 }
419 410
420 GNUNET_SCHEDULER_shutdown (); 411 GNUNET_SCHEDULER_shutdown ();
421} 412}
422 413
423
424static struct BenchmarkPeer * 414static struct BenchmarkPeer *
425find_peer (const struct GNUNET_PeerIdentity * peer) 415find_peer (const struct GNUNET_PeerIdentity * peer)
426{ 416{
@@ -428,22 +418,18 @@ find_peer (const struct GNUNET_PeerIdentity * peer)
428 418
429 for (c_p = 0; c_p < num_masters; c_p++) 419 for (c_p = 0; c_p < num_masters; c_p++)
430 { 420 {
431 if (0 421 if (0 == memcmp (&mps[c_p].id, peer, sizeof(struct GNUNET_PeerIdentity)))
432 == memcmp (&mps[c_p].id, peer,
433 sizeof(struct GNUNET_PeerIdentity)))
434 return &mps[c_p]; 422 return &mps[c_p];
435 } 423 }
436 424
437 for (c_p = 0; c_p < num_slaves; c_p++) 425 for (c_p = 0; c_p < num_slaves; c_p++)
438 { 426 {
439 if (0 == memcmp (&sps[c_p].id, peer, 427 if (0 == memcmp (&sps[c_p].id, peer, sizeof(struct GNUNET_PeerIdentity)))
440 sizeof(struct GNUNET_PeerIdentity)))
441 return &sps[c_p]; 428 return &sps[c_p];
442 } 429 }
443 return NULL; 430 return NULL ;
444} 431}
445 432
446
447/** 433/**
448 * Controller event callback 434 * Controller event callback
449 * 435 *
@@ -469,7 +455,6 @@ controller_event_cb (void *cls,
469 } 455 }
470} 456}
471 457
472
473static size_t 458static size_t
474core_send_ready (void *cls, size_t size, void *buf) 459core_send_ready (void *cls, size_t size, void *buf)
475{ 460{
@@ -478,12 +463,12 @@ core_send_ready (void *cls, size_t size, void *buf)
478 struct GNUNET_MessageHeader *msg; 463 struct GNUNET_MessageHeader *msg;
479 464
480 partner->cth = NULL; 465 partner->cth = NULL;
481 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Master [%u]: Sending PING to [%u]\n", 466 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Master [%u]: Sending PING to [%u]\n",
482 partner->me->no, partner->dest->no); 467 partner->me->no, partner->dest->no);
483 468
484 partner->messages_sent ++; 469 partner->messages_sent++;
485 partner->bytes_sent += TEST_MESSAGE_SIZE; 470 partner->bytes_sent += TEST_MESSAGE_SIZE;
486 partner->me->total_messages_sent ++; 471 partner->me->total_messages_sent++;
487 partner->me->total_bytes_sent += TEST_MESSAGE_SIZE; 472 partner->me->total_bytes_sent += TEST_MESSAGE_SIZE;
488 473
489 msg = (struct GNUNET_MessageHeader *) &msgbuf; 474 msg = (struct GNUNET_MessageHeader *) &msgbuf;
@@ -497,15 +482,17 @@ core_send_ready (void *cls, size_t size, void *buf)
497static void 482static void
498print_progress () 483print_progress ()
499{ 484{
485 static int calls;
500 progress_task = GNUNET_SCHEDULER_NO_TASK; 486 progress_task = GNUNET_SCHEDULER_NO_TASK;
501 487
502 fprintf (stderr, "."); 488 fprintf (stderr, "%llu..",
489 (long long unsigned) BENCHMARK_DURATION.rel_value_us / (1000 * 1000) - calls);
490 calls++;
503 491
504 progress_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, 492 progress_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
505 &print_progress, NULL ); 493 &print_progress, NULL );
506} 494}
507 495
508
509static void 496static void
510do_benchmark () 497do_benchmark ()
511{ 498{
@@ -533,14 +520,13 @@ do_benchmark ()
533 { 520 {
534 for (c_s = 0; c_s < num_slaves; c_s++) 521 for (c_s = 0; c_s < num_slaves; c_s++)
535 { 522 {
536 mps[c_m].partners[c_s].cth = GNUNET_CORE_notify_transmit_ready (mps[c_m].ch, 523 mps[c_m].partners[c_s].cth = GNUNET_CORE_notify_transmit_ready (
537 GNUNET_NO, 0, GNUNET_TIME_UNIT_MINUTES, &sps[c_s].id, 524 mps[c_m].ch, GNUNET_NO, 0, GNUNET_TIME_UNIT_MINUTES, &sps[c_s].id,
538 TEST_MESSAGE_SIZE, &core_send_ready, &mps[c_m].partners[c_s]); 525 TEST_MESSAGE_SIZE, &core_send_ready, &mps[c_m].partners[c_s]);
539 } 526 }
540 } 527 }
541} 528}
542 529
543
544static void 530static void
545connect_completion_callback (void *cls, struct GNUNET_TESTBED_Operation *op, 531connect_completion_callback (void *cls, struct GNUNET_TESTBED_Operation *op,
546 const char *emsg) 532 const char *emsg)
@@ -551,8 +537,7 @@ connect_completion_callback (void *cls, struct GNUNET_TESTBED_Operation *op,
551 if (NULL == emsg) 537 if (NULL == emsg)
552 { 538 {
553 GNUNET_log(GNUNET_ERROR_TYPE_INFO, 539 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
554 _("Connected master [%u] with slave [%u]\n"), 540 _("Connected master [%u] with slave [%u]\n"), cop->master->no,
555 cop->master->no,
556 cop->slave->no); 541 cop->slave->no);
557 } 542 }
558 else 543 else
@@ -579,7 +564,6 @@ connect_completion_callback (void *cls, struct GNUNET_TESTBED_Operation *op,
579 } 564 }
580} 565}
581 566
582
583static void 567static void
584do_connect_peers (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 568do_connect_peers (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
585{ 569{
@@ -602,12 +586,11 @@ do_connect_peers (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
602 for (c_s = 0; c_s < num_slaves; c_s++) 586 for (c_s = 0; c_s < num_slaves; c_s++)
603 { 587 {
604 GNUNET_log(GNUNET_ERROR_TYPE_INFO, 588 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
605 _("Connecting master [%u] with slave [%u]\n"), p->no, 589 _("Connecting master [%u] with slave [%u]\n"), p->no, sps[c_s].no);
606 sps[c_s].no);
607 p->core_connect_ops[c_s].master = p; 590 p->core_connect_ops[c_s].master = p;
608 p->core_connect_ops[c_s].slave = &sps[c_s]; 591 p->core_connect_ops[c_s].slave = &sps[c_s];
609 p->core_connect_ops[c_s].connect_op = GNUNET_TESTBED_overlay_connect (NULL, 592 p->core_connect_ops[c_s].connect_op = GNUNET_TESTBED_overlay_connect (
610 &connect_completion_callback, &p->core_connect_ops[c_s], 593 NULL, &connect_completion_callback, &p->core_connect_ops[c_s],
611 sps[c_s].peer, p->peer); 594 sps[c_s].peer, p->peer);
612 if (NULL == p->core_connect_ops[c_s].connect_op) 595 if (NULL == p->core_connect_ops[c_s].connect_op)
613 { 596 {
@@ -624,7 +607,6 @@ do_connect_peers (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
624 } 607 }
625} 608}
626 609
627
628/** 610/**
629 * Method called whenever a given peer connects. 611 * Method called whenever a given peer connects.
630 * 612 *
@@ -634,7 +616,7 @@ do_connect_peers (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
634static void 616static void
635core_connect_cb (void *cls, const struct GNUNET_PeerIdentity * peer) 617core_connect_cb (void *cls, const struct GNUNET_PeerIdentity * peer)
636{ 618{
637 struct BenchmarkPeer *p = cls; 619 struct BenchmarkPeer *me = cls;
638 struct BenchmarkPeer *remote; 620 struct BenchmarkPeer *remote;
639 char *id; 621 char *id;
640 int c; 622 int c;
@@ -647,26 +629,27 @@ core_connect_cb (void *cls, const struct GNUNET_PeerIdentity * peer)
647 return; 629 return;
648 } 630 }
649 631
650 id = GNUNET_strdup (GNUNET_i2s (&p->id)); 632 id = GNUNET_strdup (GNUNET_i2s (&me->id));
651 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "%s [%u] `%s' connected to %s [%u] %s\n", 633 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "%s [%u] `%s' connected to %s [%u] %s\n",
652 (p->master == GNUNET_YES) ? "Master": "Slave", p->no, id, 634 (me->master == GNUNET_YES) ? "Master": "Slave", me->no, id,
653 (remote->master == GNUNET_YES) ? "Master": "Slave", remote->no, GNUNET_i2s (peer)); 635 (remote->master == GNUNET_YES) ? "Master": "Slave", remote->no,
636 GNUNET_i2s (peer));
654 637
655 p->core_connections++; 638 me->core_connections++;
656 if ((GNUNET_YES == p->master) && (GNUNET_NO == remote->master) 639 if ((GNUNET_YES == me->master) && (GNUNET_NO == remote->master)
657 && (GNUNET_NO == state.connected_CORE)) 640 && (GNUNET_NO == state.connected_CORE))
658 { 641 {
659 p->mi.core_slave_connections++; 642 me->core_slave_connections++;
660 643
661 if (p->mi.core_slave_connections == num_slaves) 644 if (me->core_slave_connections == num_slaves)
662 { 645 {
663 GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Master [%u] connected all slaves\n", 646 GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Master [%u] connected all slaves\n",
664 p->no); 647 me->no);
665 } 648 }
666 completed = GNUNET_YES; 649 completed = GNUNET_YES;
667 for (c = 0; c < num_masters; c++) 650 for (c = 0; c < num_masters; c++)
668 { 651 {
669 if (mps[c].mi.core_slave_connections != num_slaves) 652 if (mps[c].core_slave_connections != num_slaves)
670 completed = GNUNET_NO; 653 completed = GNUNET_NO;
671 } 654 }
672 if (GNUNET_YES == completed) 655 if (GNUNET_YES == completed)
@@ -681,29 +664,28 @@ core_connect_cb (void *cls, const struct GNUNET_PeerIdentity * peer)
681 GNUNET_free(id); 664 GNUNET_free(id);
682} 665}
683 666
684
685static void 667static void
686core_disconnect_cb (void *cls, const struct GNUNET_PeerIdentity * peer) 668core_disconnect_cb (void *cls, const struct GNUNET_PeerIdentity * peer)
687{ 669{
688 struct BenchmarkPeer *p = cls; 670 struct BenchmarkPeer *me = cls;
689 struct BenchmarkPeer *t; 671 struct BenchmarkPeer *remote;
690 char *id; 672 char *id;
691 673
692 t = find_peer (peer); 674 remote = find_peer (peer);
693 if (NULL == t) 675 if (NULL == remote)
694 { 676 {
695 GNUNET_break(0); 677 GNUNET_break(0);
696 return; 678 return;
697 } 679 }
698 680
699 id = GNUNET_strdup (GNUNET_i2s (&p->id)); 681 id = GNUNET_strdup (GNUNET_i2s (&me->id));
700 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "%s disconnected from %s \n", id, 682 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "%s disconnected from %s \n", id,
701 GNUNET_i2s (peer)); 683 GNUNET_i2s (peer));
702 GNUNET_assert(p->core_connections > 0); 684 GNUNET_assert(me->core_connections > 0);
703 p->core_connections--; 685 me->core_connections--;
704 686
705 if ((GNUNET_YES == state.benchmarking) 687 if ((GNUNET_YES == state.benchmarking)
706 && ((GNUNET_YES == p->master) || (GNUNET_YES == t->master))) 688 && ((GNUNET_YES == me->master) || (GNUNET_YES == remote->master)))
707 { 689 {
708 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, 690 GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
709 "%s disconnected from %s while benchmarking \n", id, GNUNET_i2s (peer)); 691 "%s disconnected from %s while benchmarking \n", id, GNUNET_i2s (peer));
@@ -720,9 +702,9 @@ core_send_echo_ready (void *cls, size_t size, void *buf)
720 702
721 p->cth = NULL; 703 p->cth = NULL;
722 704
723 p->messages_sent ++; 705 p->messages_sent++;
724 p->bytes_sent += TEST_MESSAGE_SIZE; 706 p->bytes_sent += TEST_MESSAGE_SIZE;
725 p->me->total_messages_sent ++; 707 p->me->total_messages_sent++;
726 p->me->total_bytes_sent += TEST_MESSAGE_SIZE; 708 p->me->total_bytes_sent += TEST_MESSAGE_SIZE;
727 709
728 msg = (struct GNUNET_MessageHeader *) &msgbuf; 710 msg = (struct GNUNET_MessageHeader *) &msgbuf;
@@ -734,7 +716,6 @@ core_send_echo_ready (void *cls, size_t size, void *buf)
734 return TEST_MESSAGE_SIZE; 716 return TEST_MESSAGE_SIZE;
735} 717}
736 718
737
738static int 719static int
739core_handle_ping (void *cls, const struct GNUNET_PeerIdentity *other, 720core_handle_ping (void *cls, const struct GNUNET_PeerIdentity *other,
740 const struct GNUNET_MessageHeader *message) 721 const struct GNUNET_MessageHeader *message)
@@ -744,7 +725,9 @@ core_handle_ping (void *cls, const struct GNUNET_PeerIdentity *other,
744 struct BenchmarkPartner *p = NULL; 725 struct BenchmarkPartner *p = NULL;
745 for (c_m = 0; c_m < num_masters; c_m++) 726 for (c_m = 0; c_m < num_masters; c_m++)
746 { 727 {
747 if (0 == memcmp (other, &me->partners[c_m].dest->id, sizeof (struct GNUNET_PeerIdentity))) 728 if (0
729 == memcmp (other, &me->partners[c_m].dest->id,
730 sizeof(struct GNUNET_PeerIdentity)))
748 { 731 {
749 p = &me->partners[c_m]; 732 p = &me->partners[c_m];
750 break; 733 break;
@@ -752,18 +735,18 @@ core_handle_ping (void *cls, const struct GNUNET_PeerIdentity *other,
752 } 735 }
753 if (NULL == p) 736 if (NULL == p)
754 { 737 {
755 GNUNET_break (0); 738 GNUNET_break(0);
756 return GNUNET_SYSERR; 739 return GNUNET_SYSERR;
757 } 740 }
758 GNUNET_assert (NULL == p->cth); 741 GNUNET_assert(NULL == p->cth);
759 742
760 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 743 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
761 "Slave [%u]: Received PING from [%u], sending PONG\n", 744 "Slave [%u]: Received PING from [%u], sending PONG\n", me->no,
762 me->no, p->dest->no); 745 p->dest->no);
763 746
764 p->messages_received ++; 747 p->messages_received++;
765 p->bytes_received += TEST_MESSAGE_SIZE; 748 p->bytes_received += TEST_MESSAGE_SIZE;
766 p->me->total_messages_received ++; 749 p->me->total_messages_received++;
767 p->me->total_bytes_received += TEST_MESSAGE_SIZE; 750 p->me->total_bytes_received += TEST_MESSAGE_SIZE;
768 751
769 p->cth = GNUNET_CORE_notify_transmit_ready (me->ch, GNUNET_NO, 0, 752 p->cth = GNUNET_CORE_notify_transmit_ready (me->ch, GNUNET_NO, 0,
@@ -782,7 +765,9 @@ core_handle_pong (void *cls, const struct GNUNET_PeerIdentity *other,
782 765
783 for (c_s = 0; c_s < num_slaves; c_s++) 766 for (c_s = 0; c_s < num_slaves; c_s++)
784 { 767 {
785 if (0 == memcmp (other, &me->partners[c_s].dest->id, sizeof (struct GNUNET_PeerIdentity))) 768 if (0
769 == memcmp (other, &me->partners[c_s].dest->id,
770 sizeof(struct GNUNET_PeerIdentity)))
786 { 771 {
787 p = &me->partners[c_s]; 772 p = &me->partners[c_s];
788 break; 773 break;
@@ -790,23 +775,23 @@ core_handle_pong (void *cls, const struct GNUNET_PeerIdentity *other,
790 } 775 }
791 if (NULL == p) 776 if (NULL == p)
792 { 777 {
793 GNUNET_break (0); 778 GNUNET_break(0);
794 return GNUNET_SYSERR; 779 return GNUNET_SYSERR;
795 } 780 }
796 GNUNET_assert (NULL == p->cth); 781 GNUNET_assert(NULL == p->cth);
797 782
798 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 783 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
799 "Master [%u]: Received PONG from [%u], next message\n", 784 "Master [%u]: Received PONG from [%u], next message\n", me->no,
800 me->no, p->dest->no); 785 p->dest->no);
801 786
802 p->messages_received ++; 787 p->messages_received++;
803 p->bytes_received += TEST_MESSAGE_SIZE; 788 p->bytes_received += TEST_MESSAGE_SIZE;
804 p->me->total_messages_received ++; 789 p->me->total_messages_received++;
805 p->me->total_bytes_received += TEST_MESSAGE_SIZE; 790 p->me->total_bytes_received += TEST_MESSAGE_SIZE;
806 791
807 p->cth = GNUNET_CORE_notify_transmit_ready (me->ch, 792 p->cth = GNUNET_CORE_notify_transmit_ready (me->ch, GNUNET_NO, 0,
808 GNUNET_NO, 0, GNUNET_TIME_UNIT_MINUTES, &p->dest->id, 793 GNUNET_TIME_UNIT_MINUTES, &p->dest->id, TEST_MESSAGE_SIZE,
809 TEST_MESSAGE_SIZE, &core_send_ready, p); 794 &core_send_ready, p);
810 795
811 return GNUNET_OK; 796 return GNUNET_OK;
812} 797}
@@ -814,31 +799,28 @@ core_handle_pong (void *cls, const struct GNUNET_PeerIdentity *other,
814static void * 799static void *
815core_connect_adapter (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg) 800core_connect_adapter (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg)
816{ 801{
817 struct BenchmarkPeer *peer = cls; 802 struct BenchmarkPeer *me = cls;
818 803
819 static const struct GNUNET_CORE_MessageHandler handlers[] = { 804 static const struct GNUNET_CORE_MessageHandler handlers[] = { {
820 {&core_handle_ping, TEST_MESSAGE_TYPE_PING, 0 }, 805 &core_handle_ping, TEST_MESSAGE_TYPE_PING, 0 }, { &core_handle_pong,
821 {&core_handle_pong, TEST_MESSAGE_TYPE_PONG, 0 }, 806 TEST_MESSAGE_TYPE_PONG, 0 }, { NULL, 0, 0 } };
822 { NULL, 0, 0 } };
823 807
824 peer->ch = GNUNET_CORE_connect (cfg, peer, NULL, core_connect_cb, 808 me->ch = GNUNET_CORE_connect (cfg, me, NULL, core_connect_cb,
825 core_disconnect_cb, NULL, GNUNET_NO, NULL, GNUNET_NO, handlers); 809 core_disconnect_cb, NULL, GNUNET_NO, NULL, GNUNET_NO, handlers);
826 if (NULL == peer->ch) 810 if (NULL == me->ch)
827 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Failed to create core connection \n"); 811 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Failed to create core connection \n");
828 return peer->ch; 812 return me->ch;
829} 813}
830 814
831
832static void 815static void
833core_disconnect_adapter (void *cls, void *op_result) 816core_disconnect_adapter (void *cls, void *op_result)
834{ 817{
835 struct BenchmarkPeer *peer = cls; 818 struct BenchmarkPeer *me = cls;
836 819
837 GNUNET_CORE_disconnect (peer->ch); 820 GNUNET_CORE_disconnect (me->ch);
838 peer->ch = NULL; 821 me->ch = NULL;
839} 822}
840 823
841
842static void 824static void
843core_connect_completion_cb (void *cls, struct GNUNET_TESTBED_Operation *op, 825core_connect_completion_cb (void *cls, struct GNUNET_TESTBED_Operation *op,
844 void *ca_result, const char *emsg) 826 void *ca_result, const char *emsg)
@@ -863,7 +845,6 @@ core_connect_completion_cb (void *cls, struct GNUNET_TESTBED_Operation *op,
863 } 845 }
864} 846}
865 847
866
867static void 848static void
868do_connect_core (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 849do_connect_core (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
869{ 850{
@@ -872,16 +853,16 @@ do_connect_core (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
872 GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Connecting to all CORE services\n"); 853 GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Connecting to all CORE services\n");
873 for (c_m = 0; c_m < num_masters; c_m++) 854 for (c_m = 0; c_m < num_masters; c_m++)
874 { 855 {
875 mps[c_m].core_op = GNUNET_TESTBED_service_connect (NULL, 856 mps[c_m].core_op = GNUNET_TESTBED_service_connect (NULL, mps[c_m].peer,
876 mps[c_m].peer, "core", core_connect_completion_cb, NULL, 857 "core", core_connect_completion_cb, NULL, &core_connect_adapter,
877 &core_connect_adapter, &core_disconnect_adapter, &mps[c_m]); 858 &core_disconnect_adapter, &mps[c_m]);
878 } 859 }
879 860
880 for (c_s = 0; c_s < num_slaves; c_s++) 861 for (c_s = 0; c_s < num_slaves; c_s++)
881 { 862 {
882 sps[c_s].core_op = GNUNET_TESTBED_service_connect (NULL, 863 sps[c_s].core_op = GNUNET_TESTBED_service_connect (NULL, sps[c_s].peer,
883 sps[c_s].peer, "core", core_connect_completion_cb, NULL, 864 "core", core_connect_completion_cb, NULL, &core_connect_adapter,
884 &core_connect_adapter, &core_disconnect_adapter, &sps[c_s]); 865 &core_disconnect_adapter, &sps[c_s]);
885 } 866 }
886} 867}
887 868
@@ -891,11 +872,11 @@ ats_performance_info_cb (void *cls, const struct GNUNET_HELLO_Address *address,
891 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, 872 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
892 const struct GNUNET_ATS_Information *ats, uint32_t ats_count) 873 const struct GNUNET_ATS_Information *ats, uint32_t ats_count)
893{ 874{
894 struct BenchmarkPeer *p = cls; 875 struct BenchmarkPeer *me = cls;
895 int c_a; 876 int c_a;
896 char *peer_id; 877 char *peer_id;
897 878
898 peer_id = GNUNET_strdup (GNUNET_i2s (&p->id)); 879 peer_id = GNUNET_strdup (GNUNET_i2s (&me->id));
899 for (c_a = 0; c_a < ats_count; c_a++) 880 for (c_a = 0; c_a < ats_count; c_a++)
900 { 881 {
901 /*GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("%c %03u: %s %s %u\n"), 882 /*GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("%c %03u: %s %s %u\n"),
@@ -906,12 +887,12 @@ ats_performance_info_cb (void *cls, const struct GNUNET_HELLO_Address *address,
906 ntohl(ats[c_a].value));*/ 887 ntohl(ats[c_a].value));*/
907 } 888 }
908#if 0 889#if 0
909 if ((GNUNET_YES == p->master) 890 if ((GNUNET_YES == me->master)
910 && (0 == memcmp (&address->peer, &p->destination->id, 891 && (0 == memcmp (&address->peer, &me->destination->id,
911 sizeof(struct GNUNET_PeerIdentity)))) 892 sizeof(struct GNUNET_PeerIdentity))))
912 { 893 {
913 GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Bandwidth for master %u: %lu %lu\n", 894 GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Bandwidth for master %u: %lu %lu\n",
914 p->no, (long unsigned int ) ntohl (bandwidth_in.value__), 895 me->no, (long unsigned int ) ntohl (bandwidth_in.value__),
915 (long unsigned int ) ntohl (bandwidth_in.value__)); 896 (long unsigned int ) ntohl (bandwidth_in.value__));
916 } 897 }
917 898
@@ -921,29 +902,27 @@ ats_performance_info_cb (void *cls, const struct GNUNET_HELLO_Address *address,
921 GNUNET_free(peer_id); 902 GNUNET_free(peer_id);
922} 903}
923 904
924
925static void * 905static void *
926ats_perf_connect_adapter (void *cls, 906ats_perf_connect_adapter (void *cls,
927 const struct GNUNET_CONFIGURATION_Handle *cfg) 907 const struct GNUNET_CONFIGURATION_Handle *cfg)
928{ 908{
929 struct BenchmarkPeer *peer = cls; 909 struct BenchmarkPeer *me = cls;
930 910
931 peer->ats_perf_handle = GNUNET_ATS_performance_init (cfg, &ats_performance_info_cb, 911 me->ats_perf_handle = GNUNET_ATS_performance_init (cfg,
932 peer); 912 &ats_performance_info_cb, me);
933 if (NULL == peer->ats_perf_handle) 913 if (NULL == me->ats_perf_handle)
934 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, 914 GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
935 "Failed to create ATS performance handle \n"); 915 "Failed to create ATS performance handle \n");
936 return peer->ats_perf_handle; 916 return me->ats_perf_handle;
937} 917}
938 918
939
940static void 919static void
941ats_perf_disconnect_adapter (void *cls, void *op_result) 920ats_perf_disconnect_adapter (void *cls, void *op_result)
942{ 921{
943 struct BenchmarkPeer *peer = cls; 922 struct BenchmarkPeer *me = cls;
944 923
945 GNUNET_ATS_performance_done (peer->ats_perf_handle); 924 GNUNET_ATS_performance_done (me->ats_perf_handle);
946 peer->ats_perf_handle = NULL; 925 me->ats_perf_handle = NULL;
947} 926}
948 927
949static void 928static void
@@ -962,7 +941,7 @@ ats_connect_completion_cb (void *cls, struct GNUNET_TESTBED_Operation *op,
962 return; 941 return;
963 } 942 }
964 op_done++; 943 op_done++;
965 if (op_done == (num_masters+ num_slaves)) 944 if (op_done == (num_masters + num_slaves))
966 { 945 {
967 GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Connected to all ATS services\n"); 946 GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Connected to all ATS services\n");
968 state.connected_ATS_service = GNUNET_YES; 947 state.connected_ATS_service = GNUNET_YES;
@@ -970,7 +949,6 @@ ats_connect_completion_cb (void *cls, struct GNUNET_TESTBED_Operation *op,
970 } 949 }
971} 950}
972 951
973
974static void 952static void
975do_connect_ats (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 953do_connect_ats (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
976{ 954{
@@ -980,19 +958,17 @@ do_connect_ats (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
980 GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Connecting to all ATS services\n"); 958 GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Connecting to all ATS services\n");
981 for (c_m = 0; c_m < num_masters; c_m++) 959 for (c_m = 0; c_m < num_masters; c_m++)
982 { 960 {
983 mps[c_m].ats_perf_op = GNUNET_TESTBED_service_connect (NULL, 961 mps[c_m].ats_perf_op = GNUNET_TESTBED_service_connect (NULL, mps[c_m].peer,
984 mps[c_m].peer, "ats", ats_connect_completion_cb, NULL, 962 "ats", ats_connect_completion_cb, NULL, &ats_perf_connect_adapter,
985 &ats_perf_connect_adapter, &ats_perf_disconnect_adapter, 963 &ats_perf_disconnect_adapter, &mps[c_m]);
986 &mps[c_m]);
987 964
988 } 965 }
989 966
990 for (c_s = 0; c_s < num_slaves; c_s++) 967 for (c_s = 0; c_s < num_slaves; c_s++)
991 { 968 {
992 sps[c_s].ats_perf_op = GNUNET_TESTBED_service_connect (NULL, 969 sps[c_s].ats_perf_op = GNUNET_TESTBED_service_connect (NULL, sps[c_s].peer,
993 sps[c_s].peer, "ats", ats_connect_completion_cb, NULL, 970 "ats", ats_connect_completion_cb, NULL, &ats_perf_connect_adapter,
994 &ats_perf_connect_adapter, &ats_perf_disconnect_adapter, 971 &ats_perf_disconnect_adapter, &sps[c_s]);
995 &sps[c_s]);
996 } 972 }
997 973
998} 974}
@@ -1004,12 +980,12 @@ peerinformation_cb (void *cb_cls, struct GNUNET_TESTBED_Operation *op,
1004 struct BenchmarkPeer *p = cb_cls; 980 struct BenchmarkPeer *p = cb_cls;
1005 static int done = 0; 981 static int done = 0;
1006 982
1007 GNUNET_assert (pinfo->pit == GNUNET_TESTBED_PIT_IDENTITY); 983 GNUNET_assert(pinfo->pit == GNUNET_TESTBED_PIT_IDENTITY);
1008 984
1009 p->id = *pinfo->result.id; 985 p->id = *pinfo->result.id;
1010 GNUNET_log(GNUNET_ERROR_TYPE_INFO, "%s [%u] has peer id `%s'\n", 986 GNUNET_log(GNUNET_ERROR_TYPE_INFO, "%s [%u] has peer id `%s'\n",
1011 (p->master == GNUNET_YES) ? "Master" : "Slave", 987 (p->master == GNUNET_YES) ? "Master" : "Slave", p->no,
1012 p->no, GNUNET_i2s_full (&p->id)); 988 GNUNET_i2s (&p->id));
1013 989
1014 GNUNET_TESTBED_operation_done (op); 990 GNUNET_TESTBED_operation_done (op);
1015 p->peer_id_op = NULL; 991 p->peer_id_op = NULL;
@@ -1035,9 +1011,9 @@ peerinformation_cb (void *cb_cls, struct GNUNET_TESTBED_Operation *op,
1035 * failed 1011 * failed
1036 */ 1012 */
1037static void 1013static void
1038main_run (void *cls, struct GNUNET_TESTBED_RunHandle *h, 1014main_run (void *cls, struct GNUNET_TESTBED_RunHandle *h, unsigned int num_peers,
1039 unsigned int num_peers, struct GNUNET_TESTBED_Peer **peers_, 1015 struct GNUNET_TESTBED_Peer **peers_, unsigned int links_succeeded,
1040 unsigned int links_succeeded, unsigned int links_failed) 1016 unsigned int links_failed)
1041{ 1017{
1042 int c_m; 1018 int c_m;
1043 int c_s; 1019 int c_s;
@@ -1050,8 +1026,8 @@ main_run (void *cls, struct GNUNET_TESTBED_RunHandle *h,
1050 solver, pref_str, num_masters, num_slaves); 1026 solver, pref_str, num_masters, num_slaves);
1051 1027
1052 shutdown_task = GNUNET_SCHEDULER_add_delayed ( 1028 shutdown_task = GNUNET_SCHEDULER_add_delayed (
1053 GNUNET_TIME_relative_multiply (TEST_TIMEOUT, 1029 GNUNET_TIME_relative_multiply (TEST_TIMEOUT, num_masters + num_slaves),
1054 num_masters + num_slaves), &do_shutdown, NULL ); 1030 &do_shutdown, NULL );
1055 1031
1056 /* Setup master peers */ 1032 /* Setup master peers */
1057 for (c_m = 0; c_m < num_masters; c_m++) 1033 for (c_m = 0; c_m < num_masters; c_m++)
@@ -1060,17 +1036,17 @@ main_run (void *cls, struct GNUNET_TESTBED_RunHandle *h,
1060 mps[c_m].peer = peers_[c_m]; 1036 mps[c_m].peer = peers_[c_m];
1061 mps[c_m].no = c_m; 1037 mps[c_m].no = c_m;
1062 mps[c_m].master = GNUNET_YES; 1038 mps[c_m].master = GNUNET_YES;
1063 mps[c_m].partners = GNUNET_malloc (num_slaves * sizeof (struct BenchmarkPeer)); 1039 mps[c_m].pref_partner = &sps[c_m];
1040 mps[c_m].partners =
1041 GNUNET_malloc (num_slaves * sizeof (struct BenchmarkPeer));
1064 /* Initialize partners */ 1042 /* Initialize partners */
1065 for (c_s = 0; c_s < num_slaves; c_s++) 1043 for (c_s = 0; c_s < num_slaves; c_s++)
1066 { 1044 {
1067 mps[c_m].partners[c_s].me = &mps[c_m]; 1045 mps[c_m].partners[c_s].me = &mps[c_m];
1068 mps[c_m].partners[c_s].dest = &sps[c_s]; 1046 mps[c_m].partners[c_s].dest = &sps[c_s];
1069 } 1047 }
1070 mps[c_m].peer_id_op = GNUNET_TESTBED_peer_get_information ( 1048 mps[c_m].peer_id_op = GNUNET_TESTBED_peer_get_information (mps[c_m].peer,
1071 mps[c_m].peer, GNUNET_TESTBED_PIT_IDENTITY, 1049 GNUNET_TESTBED_PIT_IDENTITY, &peerinformation_cb, &mps[c_m]);
1072 &peerinformation_cb,
1073 &mps[c_m]);
1074 } 1050 }
1075 1051
1076 /* Setup slave peers */ 1052 /* Setup slave peers */
@@ -1080,17 +1056,16 @@ main_run (void *cls, struct GNUNET_TESTBED_RunHandle *h,
1080 sps[c_s].peer = peers_[c_s + num_masters]; 1056 sps[c_s].peer = peers_[c_s + num_masters];
1081 sps[c_s].no = c_s + num_masters; 1057 sps[c_s].no = c_s + num_masters;
1082 sps[c_s].master = GNUNET_NO; 1058 sps[c_s].master = GNUNET_NO;
1083 sps[c_s].partners = GNUNET_malloc (num_masters * sizeof (struct BenchmarkPeer)); 1059 sps[c_s].partners =
1060 GNUNET_malloc (num_masters * sizeof (struct BenchmarkPeer));
1084 /* Initialize partners */ 1061 /* Initialize partners */
1085 for (c_m = 0; c_m < num_masters; c_m++) 1062 for (c_m = 0; c_m < num_masters; c_m++)
1086 { 1063 {
1087 sps[c_s].partners[c_m].me = &sps[c_s]; 1064 sps[c_s].partners[c_m].me = &sps[c_s];
1088 sps[c_s].partners[c_m].dest = &mps[c_m]; 1065 sps[c_s].partners[c_m].dest = &mps[c_m];
1089 } 1066 }
1090 sps[c_s].peer_id_op = GNUNET_TESTBED_peer_get_information ( 1067 sps[c_s].peer_id_op = GNUNET_TESTBED_peer_get_information (sps[c_s].peer,
1091 sps[c_s].peer, GNUNET_TESTBED_PIT_IDENTITY, 1068 GNUNET_TESTBED_PIT_IDENTITY, &peerinformation_cb, &sps[c_s]);
1092 &peerinformation_cb,
1093 &sps[c_s]);
1094 } 1069 }
1095} 1070}
1096 1071
@@ -1155,40 +1130,51 @@ main (int argc, char *argv[])
1155 if (-1 == pref_val) 1130 if (-1 == pref_val)
1156 { 1131 {
1157 fprintf (stderr, "Unknown preference: `%s'\n", pref_str); 1132 fprintf (stderr, "Unknown preference: `%s'\n", pref_str);
1158 GNUNET_free (solver); 1133 GNUNET_free(solver);
1159 GNUNET_free (pref_str); 1134 GNUNET_free(pref_str);
1160 return -1; 1135 return -1;
1161 } 1136 }
1162 1137
1163 for (c = 0; c < (argc -1); c++) 1138 for (c = 0; c < (argc - 1); c++)
1164 { 1139 {
1165 if (0 == strcmp(argv[c], "-s")) 1140 if (0 == strcmp (argv[c], "-s"))
1166 break; 1141 break;
1167 } 1142 }
1168 if (c < argc-1) 1143 if (c < argc - 1)
1169 { 1144 {
1170 if ((0L != (num_slaves = strtol (argv[c + 1], NULL, 10))) && (num_slaves >= 1)) 1145 if ((0L != (num_slaves = strtol (argv[c + 1], NULL, 10)))
1146 && (num_slaves >= 1))
1171 fprintf (stderr, "Starting %u slave peers\n", num_slaves); 1147 fprintf (stderr, "Starting %u slave peers\n", num_slaves);
1172 else 1148 else
1173 num_slaves = DEFAULT_SLAVES_NUM; 1149 num_slaves = DEFAULT_SLAVES_NUM;
1174 } 1150 }
1175 else 1151 else
1176 num_slaves = DEFAULT_SLAVES_NUM; 1152 num_slaves = DEFAULT_SLAVES_NUM;
1177 1153
1178 for (c = 0; c < (argc -1); c++) 1154 for (c = 0; c < (argc - 1); c++)
1179 { 1155 {
1180 if (0 == strcmp(argv[c], "-m")) 1156 if (0 == strcmp (argv[c], "-m"))
1181 break; 1157 break;
1182 } 1158 }
1183 if (c < argc-1) 1159 if (c < argc - 1)
1184 { 1160 {
1185 if ((0L != (num_masters = strtol (argv[c + 1], NULL, 10))) && (num_masters >= 2)) 1161 if ((0L != (num_masters = strtol (argv[c + 1], NULL, 10)))
1162 && (num_masters >= 2))
1186 fprintf (stderr, "Starting %u master peers\n", num_masters); 1163 fprintf (stderr, "Starting %u master peers\n", num_masters);
1187 else 1164 else
1188 num_masters = DEFAULT_MASTERS_NUM; 1165 num_masters = DEFAULT_MASTERS_NUM;
1189 } 1166 }
1190 else 1167 else
1191 num_masters = DEFAULT_MASTERS_NUM; 1168 num_masters = DEFAULT_MASTERS_NUM;
1169
1170 if (num_slaves < num_masters)
1171 {
1172 fprintf (stderr, "Number of master peers is lower than slaves! exit...\n");
1173 GNUNET_free(test_name);
1174 GNUNET_free(solver);
1175 GNUNET_free(pref_str);
1176 return GNUNET_SYSERR;
1177 }
1192 1178
1193 state.connected_ATS_service = GNUNET_NO; 1179 state.connected_ATS_service = GNUNET_NO;
1194 state.connected_CORE_service = GNUNET_NO; 1180 state.connected_CORE_service = GNUNET_NO;
@@ -1204,17 +1190,16 @@ main (int argc, char *argv[])
1204 event_mask = 0; 1190 event_mask = 0;
1205 event_mask |= (1LL << GNUNET_TESTBED_ET_CONNECT); 1191 event_mask |= (1LL << GNUNET_TESTBED_ET_CONNECT);
1206 event_mask |= (1LL << GNUNET_TESTBED_ET_OPERATION_FINISHED); 1192 event_mask |= (1LL << GNUNET_TESTBED_ET_OPERATION_FINISHED);
1207 (void) GNUNET_TESTBED_test_run ("perf_ats", 1193 (void) GNUNET_TESTBED_test_run ("perf_ats", conf_name,
1208 conf_name, num_slaves + num_masters, 1194 num_slaves + num_masters, event_mask, &controller_event_cb, NULL,
1209 event_mask, &controller_event_cb, NULL, 1195 &main_run, NULL );
1210 &main_run, NULL); 1196
1211 1197 GNUNET_free(solver);
1212 GNUNET_free (solver); 1198 GNUNET_free(pref_str);
1213 GNUNET_free (pref_str); 1199 GNUNET_free(conf_name);
1214 GNUNET_free (conf_name); 1200 GNUNET_free(test_name);
1215 GNUNET_free (test_name); 1201 GNUNET_free(mps);
1216 GNUNET_free (mps); 1202 GNUNET_free(sps);
1217 GNUNET_free (sps);
1218 1203
1219 return result; 1204 return result;
1220} 1205}