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;
259 comm_disconnect_cb (void *cls, const struct GNUNET_PeerIdentity * peer)
261 struct BenchmarkPeer *me = cls;
262 struct BenchmarkPartner *p;
265 if (NULL == (p = find_partner (me, peer)))
268 id = GNUNET_strdup (GNUNET_i2s (&me->id));
269 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "%s disconnected from %s \n", id,
271 GNUNET_assert(me->core_connections > 0);
272 me->core_connections--;
274 if ((GNUNET_YES == top->state.benchmarking)
275 && ((GNUNET_YES == me->master) || (GNUNET_YES == p->dest->master)))
277 GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
278 "%s disconnected from %s while benchmarking \n", id, GNUNET_i2s (peer));
281 GNUNET_TRANSPORT_notify_transmit_ready_cancel (p->tth);
286 GNUNET_CORE_notify_transmit_ready_cancel (p->cth);
295 core_connect_adapter (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg)
297 struct BenchmarkPeer *me = cls;
299 me->ch = GNUNET_CORE_connect (cfg, me, NULL, comm_connect_cb,
300 comm_disconnect_cb, NULL, GNUNET_NO, NULL, GNUNET_NO, top->handlers);
302 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Failed to create core connection \n");
307 core_disconnect_adapter (void *cls, void *op_result)
309 struct BenchmarkPeer *me = cls;
311 GNUNET_CORE_disconnect (me->ch);
317 transport_connect_adapter (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg)
319 struct BenchmarkPeer *me = cls;
321 me->th = GNUNET_TRANSPORT_connect (cfg, &me->id, me, top->transport_recv_cb,
322 &comm_connect_cb, &comm_disconnect_cb);
324 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Failed to create transport connection \n");
329 transport_disconnect_adapter (void *cls, void *op_result)
331 struct BenchmarkPeer *me = cls;
333 GNUNET_TRANSPORT_disconnect (me->th);
339 connect_completion_callback (void *cls, struct GNUNET_TESTBED_Operation *op,
342 struct TestbedConnectOperation *cop = cls;
347 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
348 _("Connected master [%u] with slave [%u]\n"), cop->master->no,
353 GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
354 _("Failed to connect master peer [%u] with slave [%u]\n"),
355 cop->master->no, cop->slave->no);
357 if (GNUNET_SCHEDULER_NO_TASK != top->shutdown_task)
358 GNUNET_SCHEDULER_cancel (top->shutdown_task);
359 top->shutdown_task = GNUNET_SCHEDULER_add_now (do_shutdown, NULL );
361 GNUNET_TESTBED_operation_done (op);
363 for (c = 0; c < top->num_slaves; c++)
365 if (cop == &cop->master->core_connect_ops[c])
366 cop->master->core_connect_ops[c].connect_op = NULL;
368 if (ops == top->num_masters * top->num_slaves)
370 top->state.connected_PEERS = GNUNET_YES;
371 /* Notify about setup done */
372 if (NULL != top->done_cb)
373 top->done_cb (top->done_cb_cls, top->mps, top->sps);
378 do_connect_peers (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
382 struct BenchmarkPeer *p;
384 if ((top->state.connected_ATS_service == GNUNET_NO) ||
385 (top->state.connected_COMM_service == GNUNET_NO))
388 GNUNET_log(GNUNET_ERROR_TYPE_INFO, _("Connecting peers on CORE level\n"));
390 for (c_m = 0; c_m < top->num_masters; c_m++)
393 p->core_connect_ops = GNUNET_malloc (top->num_slaves *
394 sizeof (struct TestbedConnectOperation));
396 for (c_s = 0; c_s < top->num_slaves; c_s++)
398 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
399 _("Connecting master [%u] with slave [%u]\n"), p->no, top->sps[c_s].no);
400 p->core_connect_ops[c_s].master = p;
401 p->core_connect_ops[c_s].slave = &top->sps[c_s];
402 p->core_connect_ops[c_s].connect_op = GNUNET_TESTBED_overlay_connect (
403 NULL, &connect_completion_callback, &p->core_connect_ops[c_s],
404 top->sps[c_s].peer, p->peer);
405 if (NULL == p->core_connect_ops[c_s].connect_op)
407 GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
408 _("Could not connect master [%u] and slave [%u]\n"), p->no,
411 if (GNUNET_SCHEDULER_NO_TASK != top->shutdown_task)
412 GNUNET_SCHEDULER_cancel (top->shutdown_task);
413 top->shutdown_task = GNUNET_SCHEDULER_add_now (do_shutdown, NULL );
422 comm_connect_completion_cb (void *cls, struct GNUNET_TESTBED_Operation *op,
423 void *ca_result, const char *emsg)
425 static int comm_done = 0;
426 if ((NULL != emsg) || (NULL == ca_result))
428 GNUNET_log(GNUNET_ERROR_TYPE_INFO, _("Initialization failed, shutdown\n"));
430 if (GNUNET_SCHEDULER_NO_TASK != top->shutdown_task)
431 GNUNET_SCHEDULER_cancel (top->shutdown_task);
432 top->shutdown_task = GNUNET_SCHEDULER_add_now (do_shutdown, NULL );
437 if (comm_done == top->num_slaves + top->num_masters)
439 GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Connected to all %s services\n",
440 (GNUNET_YES == top->test_core) ? "CORE" : "TRANSPORT");
441 top->state.connected_COMM_service = GNUNET_YES;
442 GNUNET_SCHEDULER_add_now (&do_connect_peers, NULL );
447 do_comm_connect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
451 GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Connecting to all %s services\n",
452 (GNUNET_YES == top->test_core) ? "CORE" : "TRANSPORT");
453 for (c_m = 0; c_m < top->num_masters; c_m++)
455 if (GNUNET_YES == top->test_core)
456 top->mps[c_m].comm_op = GNUNET_TESTBED_service_connect (NULL, top->mps[c_m].peer,
457 "core", &comm_connect_completion_cb, NULL, &core_connect_adapter,
458 &core_disconnect_adapter, &top->mps[c_m]);
461 top->mps[c_m].comm_op = GNUNET_TESTBED_service_connect (NULL, top->mps[c_m].peer,
462 "transport", &comm_connect_completion_cb, NULL, &transport_connect_adapter,
463 &transport_disconnect_adapter, &top->mps[c_m]);
467 for (c_s = 0; c_s < top->num_slaves; c_s++)
469 if (GNUNET_YES == top->test_core)
470 top->sps[c_s].comm_op = GNUNET_TESTBED_service_connect (NULL, top->sps[c_s].peer,
471 "core", &comm_connect_completion_cb, NULL, &core_connect_adapter,
472 &core_disconnect_adapter, &top->sps[c_s]);
475 top->sps[c_s].comm_op = GNUNET_TESTBED_service_connect (NULL, top->sps[c_s].peer,
476 "transport", &comm_connect_completion_cb, NULL, &transport_connect_adapter,
477 &transport_disconnect_adapter, &top->sps[c_s]);
485 ats_performance_info_cb (void *cls, const struct GNUNET_HELLO_Address *address,
486 int address_active, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out,
487 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
488 const struct GNUNET_ATS_Information *ats, uint32_t ats_count)
490 struct BenchmarkPeer *me = cls;
491 struct BenchmarkPartner *p;
496 p = find_partner (me, &address->peer);
499 /* This is not one of my partners
500 * Will happen since the peers will connect to each other due to gossiping
504 peer_id = GNUNET_strdup (GNUNET_i2s (&me->id));
507 if ((p->bandwidth_in != ntohl (bandwidth_in.value__)) ||
508 (p->bandwidth_out != ntohl (bandwidth_out.value__)))
510 p->bandwidth_in = ntohl (bandwidth_in.value__);
511 p->bandwidth_out = ntohl (bandwidth_out.value__);
513 for (c_a = 0; c_a < ats_count; c_a++)
515 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "%s [%u] received ATS information: %s %s %u\n",
516 (GNUNET_YES == p->me->master) ? "Master" : "Slave",
518 GNUNET_i2s (&p->dest->id),
519 GNUNET_ATS_print_property_type(ntohl(ats[c_a].type)),
520 ntohl(ats[c_a].value));
521 switch (ntohl (ats[c_a].type ))
523 case GNUNET_ATS_ARRAY_TERMINATOR:
525 case GNUNET_ATS_UTILIZATION_OUT:
526 if (p->ats_utilization_up != ntohl (ats[c_a].value))
528 p->ats_utilization_up = ntohl (ats[c_a].value);
531 case GNUNET_ATS_UTILIZATION_IN:
532 if (p->ats_utilization_down != ntohl (ats[c_a].value))
534 p->ats_utilization_down = ntohl (ats[c_a].value);
536 case GNUNET_ATS_NETWORK_TYPE:
537 if (p->ats_network_type != ntohl (ats[c_a].value))
539 p->ats_network_type = ntohl (ats[c_a].value);
541 case GNUNET_ATS_QUALITY_NET_DELAY:
542 if (p->ats_delay != ntohl (ats[c_a].value))
544 p->ats_delay = ntohl (ats[c_a].value);
546 case GNUNET_ATS_QUALITY_NET_DISTANCE:
547 if (p->ats_distance != ntohl (ats[c_a].value))
549 p->ats_distance = ntohl (ats[c_a].value);
552 case GNUNET_ATS_COST_WAN:
553 if (p->ats_cost_wan != ntohl (ats[c_a].value))
555 p->ats_cost_wan = ntohl (ats[c_a].value);
557 case GNUNET_ATS_COST_LAN:
558 if (p->ats_cost_lan != ntohl (ats[c_a].value))
560 p->ats_cost_lan = ntohl (ats[c_a].value);
562 case GNUNET_ATS_COST_WLAN:
563 if (p->ats_cost_wlan != ntohl (ats[c_a].value))
565 p->ats_cost_wlan = ntohl (ats[c_a].value);
571 if ((GNUNET_YES == top->logging) && (GNUNET_YES == log))
573 // collect_log_now();
575 GNUNET_free(peer_id);
580 ats_perf_connect_adapter (void *cls,
581 const struct GNUNET_CONFIGURATION_Handle *cfg)
583 struct BenchmarkPeer *me = cls;
585 me->ats_perf_handle = GNUNET_ATS_performance_init (cfg,
586 &ats_performance_info_cb, me);
587 if (NULL == me->ats_perf_handle)
588 GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
589 "Failed to create ATS performance handle \n");
590 return me->ats_perf_handle;
594 ats_perf_disconnect_adapter (void *cls, void *op_result)
596 struct BenchmarkPeer *me = cls;
598 GNUNET_ATS_performance_done (me->ats_perf_handle);
599 me->ats_perf_handle = NULL;
603 ats_connect_completion_cb (void *cls, struct GNUNET_TESTBED_Operation *op,
604 void *ca_result, const char *emsg)
606 static int op_done = 0;
608 if ((NULL != emsg) || (NULL == ca_result))
610 GNUNET_log(GNUNET_ERROR_TYPE_INFO, _("Initialization failed, shutdown\n"));
612 if (GNUNET_SCHEDULER_NO_TASK != top->shutdown_task)
613 GNUNET_SCHEDULER_cancel (top->shutdown_task);
614 top->shutdown_task = GNUNET_SCHEDULER_add_now (do_shutdown, NULL );
618 if (op_done == (top->num_masters + top->num_slaves))
620 GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Connected to all ATS services\n");
621 top->state.connected_ATS_service = GNUNET_YES;
622 GNUNET_SCHEDULER_add_now (&do_comm_connect, NULL );
628 do_connect_ats (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
633 GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Connecting to all ATS services\n");
634 for (c_m = 0; c_m < top->num_masters; c_m++)
636 top->mps[c_m].ats_perf_op = GNUNET_TESTBED_service_connect (NULL,
638 "ats", ats_connect_completion_cb, NULL,
639 &ats_perf_connect_adapter,
640 &ats_perf_disconnect_adapter, &top->mps[c_m]);
643 for (c_s = 0; c_s < top->num_slaves; c_s++)
645 top->sps[c_s].ats_perf_op = GNUNET_TESTBED_service_connect (NULL, top->sps[c_s].peer,
646 "ats", ats_connect_completion_cb, NULL, &ats_perf_connect_adapter,
647 &ats_perf_disconnect_adapter, &top->sps[c_s]);
654 peerinformation_cb (void *cb_cls, struct GNUNET_TESTBED_Operation *op,
655 const struct GNUNET_TESTBED_PeerInformation*pinfo, const char *emsg)
657 struct BenchmarkPeer *p = cb_cls;
660 GNUNET_assert(pinfo->pit == GNUNET_TESTBED_PIT_IDENTITY);
662 p->id = *pinfo->result.id;
663 GNUNET_log(GNUNET_ERROR_TYPE_INFO, "%s [%u] has peer id `%s'\n",
664 (p->master == GNUNET_YES) ? "Master" : "Slave", p->no,
665 GNUNET_i2s (&p->id));
667 GNUNET_TESTBED_operation_done (op);
668 p->peer_id_op = NULL;
671 if (done == top->num_slaves + top->num_masters)
673 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
674 "Retrieved all peer ID, connect to ATS\n");
675 GNUNET_SCHEDULER_add_now (&do_connect_ats, NULL );
680 * Signature of a main function for a testcase.
683 * @param num_peers number of peers in 'peers'
684 * @param peers_ handle to peers run in the testbed
685 * @param links_succeeded the number of overlay link connection attempts that
687 * @param links_failed the number of overlay link connection attempts that
691 main_run (void *cls, struct GNUNET_TESTBED_RunHandle *h,
692 unsigned int num_peers,
693 struct GNUNET_TESTBED_Peer **peers_,
694 unsigned int links_succeeded,
695 unsigned int links_failed)
699 GNUNET_assert(NULL == cls);
700 GNUNET_assert(top->num_masters + top->num_slaves == num_peers);
701 GNUNET_assert(NULL != peers_);
703 top->shutdown_task = GNUNET_SCHEDULER_add_delayed (
704 GNUNET_TIME_relative_multiply (TEST_TIMEOUT, top->num_masters + top->num_slaves),
707 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Setting up %u masters and %u slaves\n",
708 top->num_masters, top->num_slaves);
710 /* Setup master peers */
711 for (c_m = 0; c_m < top->num_masters; c_m++)
713 GNUNET_assert(NULL != peers_[c_m]);
714 top->mps[c_m].peer = peers_[c_m];
715 top->mps[c_m].no = c_m;
716 top->mps[c_m].master = GNUNET_YES;
717 top->mps[c_m].pref_partner = &top->sps[c_m];
718 top->mps[c_m].pref_value = TEST_ATS_PREFRENCE_START;
719 top->mps[c_m].partners =
720 GNUNET_malloc (top->num_slaves * sizeof (struct BenchmarkPartner));
721 top->mps[c_m].num_partners = top->num_slaves;
722 /* Initialize partners */
723 for (c_s = 0; c_s < top->num_slaves; c_s++)
725 top->mps[c_m].partners[c_s].me = &top->mps[c_m];
726 top->mps[c_m].partners[c_s].dest = &top->sps[c_s];
728 /* Get configuration */
729 top->mps[c_m].peer_id_op = GNUNET_TESTBED_peer_get_information (top->mps[c_m].peer,
730 GNUNET_TESTBED_PIT_IDENTITY, &peerinformation_cb, &top->mps[c_m]);
733 /* Setup slave peers */
734 for (c_s = 0; c_s < top->num_slaves; c_s++)
736 GNUNET_assert(NULL != peers_[c_s + top->num_masters]);
737 top->sps[c_s].peer = peers_[c_s + top->num_masters];
738 top->sps[c_s].no = c_s + top->num_masters;
739 top->sps[c_s].master = GNUNET_NO;
740 top->sps[c_s].partners =
741 GNUNET_malloc (top->num_masters * sizeof (struct BenchmarkPartner));
742 top->sps[c_s].num_partners = top->num_masters;
743 /* Initialize partners */
744 for (c_m = 0; c_m < top->num_masters; c_m++)
746 top->sps[c_s].partners[c_m].me = &top->sps[c_s];
747 top->sps[c_s].partners[c_m].dest = &top->mps[c_m];
749 /* Get configuration */
750 top->sps[c_s].peer_id_op = GNUNET_TESTBED_peer_get_information (top->sps[c_s].peer,
751 GNUNET_TESTBED_PIT_IDENTITY, &peerinformation_cb, &top->sps[c_s]);
756 * Controller event callback
759 * @param event the controller event
762 controller_event_cb (void *cls,
763 const struct GNUNET_TESTBED_EventInformation *event)
765 struct GNUNET_ATS_TEST_Topology *top = cls;
768 case GNUNET_TESTBED_ET_CONNECT:
770 case GNUNET_TESTBED_ET_OPERATION_FINISHED:
774 GNUNET_SCHEDULER_cancel (top->shutdown_task);
775 top->shutdown_task = GNUNET_SCHEDULER_add_now (&do_shutdown, NULL );
780 GNUNET_ATS_TEST_create_topology (char *name, char *cfg_file,
781 unsigned int num_slaves,
782 unsigned int num_masters,
784 GNUNET_ATS_TESTING_TopologySetupDoneCallback done_cb,
786 struct GNUNET_CORE_MessageHandler *handlers,
787 GNUNET_TRANSPORT_ReceiveCallback transport_recv_cb)
790 top = GNUNET_new (struct GNUNET_ATS_TEST_Topology);
791 top->num_masters = num_masters;
792 top->num_slaves = num_slaves;
793 top->handlers = handlers;
794 top->done_cb = done_cb;
795 top->done_cb_cls = done_cb_cls;
796 top->test_core = test_core;
798 top->mps = GNUNET_malloc (num_masters * sizeof (struct BenchmarkPeer));
799 top->sps = GNUNET_malloc (num_slaves * sizeof (struct BenchmarkPeer));
804 event_mask |= (1LL << GNUNET_TESTBED_ET_CONNECT);
805 event_mask |= (1LL << GNUNET_TESTBED_ET_OPERATION_FINISHED);
806 (void) GNUNET_TESTBED_test_run (name, cfg_file,
807 num_slaves + num_masters, event_mask, &controller_event_cb, NULL,
812 GNUNET_ATS_TEST_shutdown_topology (void)
814 GNUNET_SCHEDULER_shutdown();
817 /* end of file perf_ats.c */