2 This file is part of GNUnet.
3 (C) 2010-2013 Christian Grothoff (and other contributing authors)
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
7 by the Free Software Foundation; either version 3, or (at your
8 option) any later version.
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
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
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
21 * @file ats/perf_ats.c
22 * @brief ats benchmark: start peers and modify preferences, monitor change over time
23 * @author Christian Grothoff
24 * @author Matthias Wachs
27 #include "gnunet_util_lib.h"
28 #include "gnunet_testbed_service.h"
29 #include "gnunet_ats_service.h"
30 #include "gnunet_core_service.h"
31 #include "ats-testing.h"
36 static struct GNUNET_ATS_TEST_Topology *top;
42 * @param tc the task context
45 do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
50 struct BenchmarkPeer *p;
52 if (GNUNET_YES == logging)
55 top->shutdown_task = GNUNET_SCHEDULER_NO_TASK;
57 if (GNUNET_SCHEDULER_NO_TASK != progress_task)
59 fprintf (stderr, "0\n");
60 GNUNET_SCHEDULER_cancel (progress_task);
62 progress_task = GNUNET_SCHEDULER_NO_TASK;
66 top->state.benchmarking = GNUNET_NO;
67 GNUNET_log(GNUNET_ERROR_TYPE_INFO, _("Benchmarking done\n"));
69 for (c_m = 0; c_m < top->num_masters; c_m++)
72 if (NULL != top->mps[c_m].peer_id_op)
74 GNUNET_TESTBED_operation_done (p->peer_id_op);
78 if (GNUNET_SCHEDULER_NO_TASK != p->ats_task)
79 GNUNET_SCHEDULER_cancel (p->ats_task);
80 p->ats_task = GNUNET_SCHEDULER_NO_TASK;
82 for (c_op = 0; c_op < p->num_partners; c_op++)
84 if (NULL != p->partners[c_op].cth)
86 GNUNET_CORE_notify_transmit_ready_cancel (p->partners[c_op].cth);
87 p->partners[c_op].cth = NULL;
89 if (NULL != p->partners[c_op].tth)
91 GNUNET_TRANSPORT_notify_transmit_ready_cancel (p->partners[c_op].tth);
92 p->partners[c_op].tth = NULL;
94 if ( (NULL != p->core_connect_ops) &&
95 (NULL != p->core_connect_ops[c_op].connect_op) )
97 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
98 _("Failed to connect peer 0 and %u\n"), c_op);
99 GNUNET_TESTBED_operation_done (
100 p->core_connect_ops[c_op].connect_op);
101 p->core_connect_ops[c_op].connect_op = NULL;
105 if (NULL != p->ats_perf_op)
107 GNUNET_TESTBED_operation_done (p->ats_perf_op);
108 p->ats_perf_op = NULL;
111 if (NULL != p->comm_op)
113 GNUNET_TESTBED_operation_done (p->comm_op);
116 GNUNET_free_non_null (p->core_connect_ops);
117 GNUNET_free(p->partners);
121 for (c_s = 0; c_s < top->num_slaves; c_s++)
124 if (NULL != p->peer_id_op)
126 GNUNET_TESTBED_operation_done (p->peer_id_op);
127 p->peer_id_op = NULL;
130 for (c_op = 0; c_op < p->num_partners; c_op++)
132 if (NULL != p->partners[c_op].cth)
134 GNUNET_CORE_notify_transmit_ready_cancel (p->partners[c_op].cth);
135 p->partners[c_op].cth = NULL;
137 if (NULL != p->partners[c_op].tth)
139 GNUNET_TRANSPORT_notify_transmit_ready_cancel (p->partners[c_op].tth);
140 p->partners[c_op].tth = NULL;
143 if (NULL != p->ats_perf_op)
145 GNUNET_TESTBED_operation_done (p->ats_perf_op);
146 p->ats_perf_op = NULL;
148 if (NULL != p->comm_op)
150 GNUNET_TESTBED_operation_done (p->comm_op);
153 GNUNET_free(p->partners);
157 GNUNET_SCHEDULER_shutdown ();
160 static struct BenchmarkPartner *
161 find_partner (struct BenchmarkPeer *me, const struct GNUNET_PeerIdentity * peer)
164 GNUNET_assert (NULL != me);
165 GNUNET_assert (NULL != peer);
167 for (c_m = 0; c_m < me->num_partners; c_m++)
169 /* Find a partner with other as destination */
170 if (0 == memcmp (peer, &me->partners[c_m].dest->id,
171 sizeof(struct GNUNET_PeerIdentity)))
173 return &me->partners[c_m];
181 static struct BenchmarkPeer *
182 find_peer (const struct GNUNET_PeerIdentity * peer)
186 for (c_p = 0; c_p < top->num_masters; c_p++)
188 if (0 == memcmp (&top->mps[c_p].id, peer, sizeof(struct GNUNET_PeerIdentity)))
189 return &top->mps[c_p];
192 for (c_p = 0; c_p < top->num_slaves; c_p++)
194 if (0 == memcmp (&top->sps[c_p].id, peer, sizeof(struct GNUNET_PeerIdentity)))
195 return &top->sps[c_p];
202 * Method called whenever a given peer connects.
205 * @param peer peer identity this notification is about
208 comm_connect_cb (void *cls, const struct GNUNET_PeerIdentity * peer)
210 struct BenchmarkPeer *me = cls;
211 struct BenchmarkPeer *remote;
216 remote = find_peer (peer);
219 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Unknown peer connected: `%s'\n", GNUNET_i2s (peer));
224 id = GNUNET_strdup (GNUNET_i2s (&me->id));
225 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "%s [%u] `%s' connected to %s [%u] %s\n",
226 (me->master == GNUNET_YES) ? "Master": "Slave", me->no, id,
227 (remote->master == GNUNET_YES) ? "Master": "Slave", remote->no,
230 me->core_connections++;
231 if ((GNUNET_YES == me->master) && (GNUNET_NO == remote->master)
232 && (GNUNET_NO == top->state.connected_CORE))
234 me->core_slave_connections++;
236 if (me->core_slave_connections == top->num_slaves)
238 GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Master [%u] connected all slaves\n",
241 completed = GNUNET_YES;
242 for (c = 0; c < top->num_masters; c++)
244 if (top->mps[c].core_slave_connections != top->num_slaves)
245 completed = GNUNET_NO;
247 if (GNUNET_YES == completed)
249 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
250 "All master peers connected all slave peers\n", id,
252 top->state.connected_CORE = GNUNET_YES;
254 //GNUNET_SCHEDULER_add_now (&do_benchmark, NULL );
261 comm_disconnect_cb (void *cls, const struct GNUNET_PeerIdentity * peer)
263 struct BenchmarkPeer *me = cls;
264 struct BenchmarkPartner *p;
267 if (NULL == (p = find_partner (me, peer)))
270 id = GNUNET_strdup (GNUNET_i2s (&me->id));
271 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "%s disconnected from %s \n", id,
273 GNUNET_assert(me->core_connections > 0);
274 me->core_connections--;
276 if ((GNUNET_YES == top->state.benchmarking)
277 && ((GNUNET_YES == me->master) || (GNUNET_YES == p->dest->master)))
279 GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
280 "%s disconnected from %s while benchmarking \n", id, GNUNET_i2s (peer));
283 GNUNET_TRANSPORT_notify_transmit_ready_cancel (p->tth);
288 GNUNET_CORE_notify_transmit_ready_cancel (p->cth);
297 core_connect_adapter (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg)
299 struct BenchmarkPeer *me = cls;
301 me->ch = GNUNET_CORE_connect (cfg, me, NULL, comm_connect_cb,
302 comm_disconnect_cb, NULL, GNUNET_NO, NULL, GNUNET_NO, top->handlers);
304 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Failed to create core connection \n");
309 core_disconnect_adapter (void *cls, void *op_result)
311 struct BenchmarkPeer *me = cls;
313 GNUNET_CORE_disconnect (me->ch);
319 transport_connect_adapter (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg)
321 struct BenchmarkPeer *me = cls;
323 me->th = GNUNET_TRANSPORT_connect (cfg, &me->id, me, top->transport_recv_cb,
324 &comm_connect_cb, &comm_disconnect_cb);
326 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Failed to create transport connection \n");
331 transport_disconnect_adapter (void *cls, void *op_result)
333 struct BenchmarkPeer *me = cls;
335 GNUNET_TRANSPORT_disconnect (me->th);
341 connect_completion_callback (void *cls, struct GNUNET_TESTBED_Operation *op,
344 struct TestbedConnectOperation *cop = cls;
349 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
350 _("Connected master [%u] with slave [%u]\n"), cop->master->no,
355 GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
356 _("Failed to connect master peer [%u] with slave [%u]\n"),
357 cop->master->no, cop->slave->no);
359 if (GNUNET_SCHEDULER_NO_TASK != top->shutdown_task)
360 GNUNET_SCHEDULER_cancel (top->shutdown_task);
361 top->shutdown_task = GNUNET_SCHEDULER_add_now (do_shutdown, NULL );
363 GNUNET_TESTBED_operation_done (op);
365 for (c = 0; c < top->num_slaves; c++)
367 if (cop == &cop->master->core_connect_ops[c])
368 cop->master->core_connect_ops[c].connect_op = NULL;
370 if (ops == top->num_masters * top->num_slaves)
372 top->state.connected_PEERS = GNUNET_YES;
374 //GNUNET_SCHEDULER_add_now (&do_benchmark, NULL );
379 do_connect_peers (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
383 struct BenchmarkPeer *p;
385 if ((top->state.connected_ATS_service == GNUNET_NO) ||
386 (top->state.connected_COMM_service == GNUNET_NO))
389 GNUNET_log(GNUNET_ERROR_TYPE_INFO, _("Connecting peers on CORE level\n"));
391 for (c_m = 0; c_m < top->num_masters; c_m++)
394 p->core_connect_ops = GNUNET_malloc (top->num_slaves *
395 sizeof (struct TestbedConnectOperation));
397 for (c_s = 0; c_s < top->num_slaves; c_s++)
399 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
400 _("Connecting master [%u] with slave [%u]\n"), p->no, top->sps[c_s].no);
401 p->core_connect_ops[c_s].master = p;
402 p->core_connect_ops[c_s].slave = &top->sps[c_s];
403 p->core_connect_ops[c_s].connect_op = GNUNET_TESTBED_overlay_connect (
404 NULL, &connect_completion_callback, &p->core_connect_ops[c_s],
405 top->sps[c_s].peer, p->peer);
406 if (NULL == p->core_connect_ops[c_s].connect_op)
408 GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
409 _("Could not connect master [%u] and slave [%u]\n"), p->no,
412 if (GNUNET_SCHEDULER_NO_TASK != top->shutdown_task)
413 GNUNET_SCHEDULER_cancel (top->shutdown_task);
414 top->shutdown_task = GNUNET_SCHEDULER_add_now (do_shutdown, NULL );
423 comm_connect_completion_cb (void *cls, struct GNUNET_TESTBED_Operation *op,
424 void *ca_result, const char *emsg)
426 static int comm_done = 0;
427 if ((NULL != emsg) || (NULL == ca_result))
429 GNUNET_log(GNUNET_ERROR_TYPE_INFO, _("Initialization failed, shutdown\n"));
431 if (GNUNET_SCHEDULER_NO_TASK != top->shutdown_task)
432 GNUNET_SCHEDULER_cancel (top->shutdown_task);
433 top->shutdown_task = GNUNET_SCHEDULER_add_now (do_shutdown, NULL );
438 if (comm_done == top->num_slaves + top->num_masters)
440 GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Connected to all %s services\n",
441 (GNUNET_YES == top->test_core) ? "CORE" : "TRANSPORT");
442 top->state.connected_COMM_service = GNUNET_YES;
444 GNUNET_SCHEDULER_add_now (&do_connect_peers, NULL );
449 do_comm_connect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
453 GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Connecting to all %s services\n",
454 (GNUNET_YES == top->test_core) ? "CORE" : "TRANSPORT");
455 for (c_m = 0; c_m < top->num_masters; c_m++)
457 if (GNUNET_YES == top->test_core)
458 top->mps[c_m].comm_op = GNUNET_TESTBED_service_connect (NULL, top->mps[c_m].peer,
459 "core", &comm_connect_completion_cb, NULL, &core_connect_adapter,
460 &core_disconnect_adapter, &top->mps[c_m]);
463 top->mps[c_m].comm_op = GNUNET_TESTBED_service_connect (NULL, top->mps[c_m].peer,
464 "transport", &comm_connect_completion_cb, NULL, &transport_connect_adapter,
465 &transport_disconnect_adapter, &top->mps[c_m]);
469 for (c_s = 0; c_s < top->num_slaves; c_s++)
471 if (GNUNET_YES == top->test_core)
472 top->sps[c_s].comm_op = GNUNET_TESTBED_service_connect (NULL, top->sps[c_s].peer,
473 "core", &comm_connect_completion_cb, NULL, &core_connect_adapter,
474 &core_disconnect_adapter, &top->sps[c_s]);
477 top->sps[c_s].comm_op = GNUNET_TESTBED_service_connect (NULL, top->sps[c_s].peer,
478 "transport", &comm_connect_completion_cb, NULL, &transport_connect_adapter,
479 &transport_disconnect_adapter, &top->sps[c_s]);
487 ats_performance_info_cb (void *cls, const struct GNUNET_HELLO_Address *address,
488 int address_active, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out,
489 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
490 const struct GNUNET_ATS_Information *ats, uint32_t ats_count)
492 struct BenchmarkPeer *me = cls;
493 struct BenchmarkPartner *p;
498 p = find_partner (me, &address->peer);
501 /* This is not one of my partners
502 * Will happen since the peers will connect to each other due to gossiping
506 peer_id = GNUNET_strdup (GNUNET_i2s (&me->id));
509 if ((p->bandwidth_in != ntohl (bandwidth_in.value__)) ||
510 (p->bandwidth_out != ntohl (bandwidth_out.value__)))
512 p->bandwidth_in = ntohl (bandwidth_in.value__);
513 p->bandwidth_out = ntohl (bandwidth_out.value__);
515 for (c_a = 0; c_a < ats_count; c_a++)
517 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "%s [%u] received ATS information: %s %s %u\n",
518 (GNUNET_YES == p->me->master) ? "Master" : "Slave",
520 GNUNET_i2s (&p->dest->id),
521 GNUNET_ATS_print_property_type(ntohl(ats[c_a].type)),
522 ntohl(ats[c_a].value));
523 switch (ntohl (ats[c_a].type ))
525 case GNUNET_ATS_ARRAY_TERMINATOR:
527 case GNUNET_ATS_UTILIZATION_OUT:
528 if (p->ats_utilization_up != ntohl (ats[c_a].value))
530 p->ats_utilization_up = ntohl (ats[c_a].value);
533 case GNUNET_ATS_UTILIZATION_IN:
534 if (p->ats_utilization_down != ntohl (ats[c_a].value))
536 p->ats_utilization_down = ntohl (ats[c_a].value);
538 case GNUNET_ATS_NETWORK_TYPE:
539 if (p->ats_network_type != ntohl (ats[c_a].value))
541 p->ats_network_type = ntohl (ats[c_a].value);
543 case GNUNET_ATS_QUALITY_NET_DELAY:
544 if (p->ats_delay != ntohl (ats[c_a].value))
546 p->ats_delay = ntohl (ats[c_a].value);
548 case GNUNET_ATS_QUALITY_NET_DISTANCE:
549 if (p->ats_distance != ntohl (ats[c_a].value))
551 p->ats_distance = ntohl (ats[c_a].value);
554 case GNUNET_ATS_COST_WAN:
555 if (p->ats_cost_wan != ntohl (ats[c_a].value))
557 p->ats_cost_wan = ntohl (ats[c_a].value);
559 case GNUNET_ATS_COST_LAN:
560 if (p->ats_cost_lan != ntohl (ats[c_a].value))
562 p->ats_cost_lan = ntohl (ats[c_a].value);
564 case GNUNET_ATS_COST_WLAN:
565 if (p->ats_cost_wlan != ntohl (ats[c_a].value))
567 p->ats_cost_wlan = ntohl (ats[c_a].value);
573 if ((GNUNET_YES == top->logging) && (GNUNET_YES == log))
575 // collect_log_now();
577 GNUNET_free(peer_id);
582 ats_perf_connect_adapter (void *cls,
583 const struct GNUNET_CONFIGURATION_Handle *cfg)
585 struct BenchmarkPeer *me = cls;
587 me->ats_perf_handle = GNUNET_ATS_performance_init (cfg,
588 &ats_performance_info_cb, me);
589 if (NULL == me->ats_perf_handle)
590 GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
591 "Failed to create ATS performance handle \n");
592 return me->ats_perf_handle;
596 ats_perf_disconnect_adapter (void *cls, void *op_result)
598 struct BenchmarkPeer *me = cls;
600 GNUNET_ATS_performance_done (me->ats_perf_handle);
601 me->ats_perf_handle = NULL;
605 ats_connect_completion_cb (void *cls, struct GNUNET_TESTBED_Operation *op,
606 void *ca_result, const char *emsg)
608 static int op_done = 0;
610 if ((NULL != emsg) || (NULL == ca_result))
612 GNUNET_log(GNUNET_ERROR_TYPE_INFO, _("Initialization failed, shutdown\n"));
614 if (GNUNET_SCHEDULER_NO_TASK != top->shutdown_task)
615 GNUNET_SCHEDULER_cancel (top->shutdown_task);
616 top->shutdown_task = GNUNET_SCHEDULER_add_now (do_shutdown, NULL );
620 if (op_done == (top->num_masters + top->num_slaves))
622 GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Connected to all ATS services\n");
623 top->state.connected_ATS_service = GNUNET_YES;
624 GNUNET_SCHEDULER_add_now (&do_comm_connect, NULL );
630 do_connect_ats (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
635 GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Connecting to all ATS services\n");
636 for (c_m = 0; c_m < top->num_masters; c_m++)
638 top->mps[c_m].ats_perf_op = GNUNET_TESTBED_service_connect (NULL,
640 "ats", ats_connect_completion_cb, NULL,
641 &ats_perf_connect_adapter,
642 &ats_perf_disconnect_adapter, &top->mps[c_m]);
645 for (c_s = 0; c_s < top->num_slaves; c_s++)
647 top->sps[c_s].ats_perf_op = GNUNET_TESTBED_service_connect (NULL, top->sps[c_s].peer,
648 "ats", ats_connect_completion_cb, NULL, &ats_perf_connect_adapter,
649 &ats_perf_disconnect_adapter, &top->sps[c_s]);
656 peerinformation_cb (void *cb_cls, struct GNUNET_TESTBED_Operation *op,
657 const struct GNUNET_TESTBED_PeerInformation*pinfo, const char *emsg)
659 struct BenchmarkPeer *p = cb_cls;
662 GNUNET_assert(pinfo->pit == GNUNET_TESTBED_PIT_IDENTITY);
664 p->id = *pinfo->result.id;
665 GNUNET_log(GNUNET_ERROR_TYPE_INFO, "%s [%u] has peer id `%s'\n",
666 (p->master == GNUNET_YES) ? "Master" : "Slave", p->no,
667 GNUNET_i2s (&p->id));
669 GNUNET_TESTBED_operation_done (op);
670 p->peer_id_op = NULL;
673 if (done == top->num_slaves + top->num_masters)
675 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
676 "Retrieved all peer ID, connect to ATS\n");
677 GNUNET_SCHEDULER_add_now (&do_connect_ats, NULL );
682 * Signature of a main function for a testcase.
685 * @param num_peers number of peers in 'peers'
686 * @param peers_ handle to peers run in the testbed
687 * @param links_succeeded the number of overlay link connection attempts that
689 * @param links_failed the number of overlay link connection attempts that
693 main_run (void *cls, struct GNUNET_TESTBED_RunHandle *h,
694 unsigned int num_peers,
695 struct GNUNET_TESTBED_Peer **peers_,
696 unsigned int links_succeeded,
697 unsigned int links_failed)
701 GNUNET_assert(NULL == cls);
702 GNUNET_assert(top->num_masters + top->num_slaves == num_peers);
703 GNUNET_assert(NULL != peers_);
705 top->shutdown_task = GNUNET_SCHEDULER_add_delayed (
706 GNUNET_TIME_relative_multiply (TEST_TIMEOUT, top->num_masters + top->num_slaves),
709 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Setting up %u masters and %u slaves\n",
710 top->num_masters, top->num_slaves);
712 /* Setup master peers */
713 for (c_m = 0; c_m < top->num_masters; c_m++)
715 GNUNET_assert(NULL != peers_[c_m]);
716 top->mps[c_m].peer = peers_[c_m];
717 top->mps[c_m].no = c_m;
718 top->mps[c_m].master = GNUNET_YES;
719 top->mps[c_m].pref_partner = &top->sps[c_m];
720 top->mps[c_m].pref_value = TEST_ATS_PREFRENCE_START;
721 top->mps[c_m].partners =
722 GNUNET_malloc (top->num_slaves * sizeof (struct BenchmarkPartner));
723 top->mps[c_m].num_partners = top->num_slaves;
724 /* Initialize partners */
725 for (c_s = 0; c_s < top->num_slaves; c_s++)
727 top->mps[c_m].partners[c_s].me = &top->mps[c_m];
728 top->mps[c_m].partners[c_s].dest = &top->sps[c_s];
730 /* Get configuration */
731 top->mps[c_m].peer_id_op = GNUNET_TESTBED_peer_get_information (top->mps[c_m].peer,
732 GNUNET_TESTBED_PIT_IDENTITY, &peerinformation_cb, &top->mps[c_m]);
735 /* Setup slave peers */
736 for (c_s = 0; c_s < top->num_slaves; c_s++)
738 GNUNET_assert(NULL != peers_[c_s + top->num_masters]);
739 top->sps[c_s].peer = peers_[c_s + top->num_masters];
740 top->sps[c_s].no = c_s + top->num_masters;
741 top->sps[c_s].master = GNUNET_NO;
742 top->sps[c_s].partners =
743 GNUNET_malloc (top->num_masters * sizeof (struct BenchmarkPartner));
744 top->sps[c_s].num_partners = top->num_masters;
745 /* Initialize partners */
746 for (c_m = 0; c_m < top->num_masters; c_m++)
748 top->sps[c_s].partners[c_m].me = &top->sps[c_s];
749 top->sps[c_s].partners[c_m].dest = &top->mps[c_m];
751 /* Get configuration */
752 top->sps[c_s].peer_id_op = GNUNET_TESTBED_peer_get_information (top->sps[c_s].peer,
753 GNUNET_TESTBED_PIT_IDENTITY, &peerinformation_cb, &top->sps[c_s]);
758 * Controller event callback
761 * @param event the controller event
764 controller_event_cb (void *cls,
765 const struct GNUNET_TESTBED_EventInformation *event)
767 struct GNUNET_ATS_TEST_Topology *top = cls;
770 case GNUNET_TESTBED_ET_CONNECT:
772 case GNUNET_TESTBED_ET_OPERATION_FINISHED:
776 GNUNET_SCHEDULER_cancel (top->shutdown_task);
777 top->shutdown_task = GNUNET_SCHEDULER_add_now (&do_shutdown, NULL );
781 struct GNUNET_ATS_TEST_Topology *
782 GNUNET_ATS_TEST_create_topology (char *name, char *cfg_file,
783 unsigned int num_slaves,
784 unsigned int num_masters,
785 struct GNUNET_CORE_MessageHandler *handlers,
786 GNUNET_TRANSPORT_ReceiveCallback transport_recv_cb)
788 top = GNUNET_new (struct GNUNET_ATS_TEST_Topology);
789 top->num_masters = num_masters;
790 top->num_slaves = num_slaves;
791 top->handlers = handlers;
793 top->mps = GNUNET_malloc (num_masters * sizeof (struct BenchmarkPeer));
794 top->sps = GNUNET_malloc (num_slaves * sizeof (struct BenchmarkPeer));
799 event_mask |= (1LL << GNUNET_TESTBED_ET_CONNECT);
800 event_mask |= (1LL << GNUNET_TESTBED_ET_OPERATION_FINISHED);
801 (void) GNUNET_TESTBED_test_run (name, cfg_file,
802 num_slaves + num_masters, event_mask, &controller_event_cb, NULL,
809 GNUNET_ATS_TEST_destroy_topology (struct GNUNET_ATS_TEST_Topology *top)
814 /* end of file perf_ats.c */