2 This file is part of GNUnet.
3 Copyright (C) 2010-2013 GNUnet e.V.
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., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
21 * @file ats-tests/ats-testing.c
22 * @brief ats testing library: setup topology
24 * @author Christian Grothoff
25 * @author Matthias Wachs
27 #include "ats-testing.h"
31 * Connect peers with testbed
33 struct TestbedConnectOperation
36 * The benchmarking master initiating this connection
38 struct BenchmarkPeer *master;
41 * The benchmarking slave to connect to
43 struct BenchmarkPeer *slave;
46 * Testbed operation to connect peers
48 struct GNUNET_TESTBED_Operation *connect_op;
51 struct GNUNET_CONFIGURATION_Handle *cfg;
53 struct GNUNET_ATS_TEST_Topology *top;
62 do_shutdown (void *cls)
67 struct BenchmarkPeer *p;
69 top->state.benchmarking = GNUNET_NO;
71 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
72 "Benchmarking done\n");
74 GNUNET_ATS_TEST_generate_traffic_stop_all ();
76 for (c_m = 0; c_m < top->num_masters; c_m++)
79 if (NULL != top->mps[c_m].peer_id_op)
81 GNUNET_TESTBED_operation_done (p->peer_id_op);
85 if (NULL != p->ats_task)
86 GNUNET_SCHEDULER_cancel (p->ats_task);
89 for (c_op = 0; c_op < p->num_partners; c_op++)
91 if (NULL != p->partners[c_op].cth)
93 GNUNET_CORE_notify_transmit_ready_cancel (p->partners[c_op].cth);
94 p->partners[c_op].cth = NULL;
96 if (NULL != p->partners[c_op].tth)
98 GNUNET_TRANSPORT_notify_transmit_ready_cancel (p->partners[c_op].tth);
99 p->partners[c_op].tth = NULL;
101 if ( (NULL != p->core_connect_ops) &&
102 (NULL != p->core_connect_ops[c_op].connect_op) )
104 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
105 _("Failed to connect peer 0 and %u\n"), c_op);
106 GNUNET_TESTBED_operation_done (
107 p->core_connect_ops[c_op].connect_op);
108 p->core_connect_ops[c_op].connect_op = NULL;
112 if (NULL != p->ats_perf_op)
114 GNUNET_TESTBED_operation_done (p->ats_perf_op);
115 p->ats_perf_op = NULL;
118 if (NULL != p->comm_op)
120 GNUNET_TESTBED_operation_done (p->comm_op);
123 GNUNET_free_non_null (p->core_connect_ops);
124 GNUNET_free(p->partners);
128 for (c_s = 0; c_s < top->num_slaves; c_s++)
131 if (NULL != p->peer_id_op)
133 GNUNET_TESTBED_operation_done (p->peer_id_op);
134 p->peer_id_op = NULL;
137 for (c_op = 0; c_op < p->num_partners; c_op++)
139 if (NULL != p->partners[c_op].cth)
141 GNUNET_CORE_notify_transmit_ready_cancel (p->partners[c_op].cth);
142 p->partners[c_op].cth = NULL;
144 if (NULL != p->partners[c_op].tth)
146 GNUNET_TRANSPORT_notify_transmit_ready_cancel (p->partners[c_op].tth);
147 p->partners[c_op].tth = NULL;
150 if (NULL != p->ats_perf_op)
152 GNUNET_TESTBED_operation_done (p->ats_perf_op);
153 p->ats_perf_op = NULL;
155 if (NULL != p->comm_op)
157 GNUNET_TESTBED_operation_done (p->comm_op);
160 GNUNET_free(p->partners);
163 GNUNET_SCHEDULER_shutdown ();
169 static struct BenchmarkPartner *
170 find_partner (struct BenchmarkPeer *me,
171 const struct GNUNET_PeerIdentity *peer)
175 for (c_m = 0; c_m < me->num_partners; c_m++)
177 /* Find a partner with other as destination */
178 if (0 == memcmp (peer,
179 &me->partners[c_m].dest->id,
180 sizeof (struct GNUNET_PeerIdentity)))
182 return &me->partners[c_m];
190 static struct BenchmarkPeer *
191 find_peer (const struct GNUNET_PeerIdentity * peer)
195 for (c_p = 0; c_p < top->num_masters; c_p++)
197 if (0 == memcmp (&top->mps[c_p].id,
199 sizeof(struct GNUNET_PeerIdentity)))
200 return &top->mps[c_p];
203 for (c_p = 0; c_p < top->num_slaves; c_p++)
205 if (0 == memcmp (&top->sps[c_p].id,
207 sizeof(struct GNUNET_PeerIdentity)))
208 return &top->sps[c_p];
215 * Method called whenever a given peer connects.
218 * @param peer peer identity this notification is about
221 comm_connect_cb (void *cls,
222 const struct GNUNET_PeerIdentity *peer)
224 struct BenchmarkPeer *me = cls;
225 struct BenchmarkPeer *remote;
230 remote = find_peer (peer);
233 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
234 "Unknown peer connected: `%s'\n",
240 id = GNUNET_strdup (GNUNET_i2s (&me->id));
241 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
242 "%s [%u] `%s' connected to %s [%u] %s\n",
243 (me->master == GNUNET_YES) ? "Master": "Slave", me->no, id,
244 (remote->master == GNUNET_YES) ? "Master": "Slave", remote->no,
247 me->core_connections++;
248 if ((GNUNET_YES == me->master) && (GNUNET_NO == remote->master)
249 && (GNUNET_NO == top->state.connected_CORE))
251 me->core_slave_connections++;
253 if (me->core_slave_connections == top->num_slaves)
255 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
256 "Master [%u] connected all slaves\n",
259 completed = GNUNET_YES;
260 for (c = 0; c < top->num_masters; c++)
262 if (top->mps[c].core_slave_connections != top->num_slaves)
263 completed = GNUNET_NO;
265 if (GNUNET_YES == completed)
267 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
268 "All master peers connected all slave peers\n");
269 top->state.connected_CORE = GNUNET_YES;
270 /* Notify about setup done */
271 if (NULL != top->done_cb)
272 top->done_cb (top->done_cb_cls, top->mps, top->sps);
280 comm_disconnect_cb (void *cls,
281 const struct GNUNET_PeerIdentity *peer)
283 struct BenchmarkPeer *me = cls;
284 struct BenchmarkPartner *p;
287 if (NULL == (p = find_partner (me, peer)))
290 id = GNUNET_strdup (GNUNET_i2s (&me->id));
291 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
292 "%s disconnected from %s\n",
295 GNUNET_assert(me->core_connections > 0);
296 me->core_connections--;
298 if ( (GNUNET_YES == top->state.benchmarking) &&
299 ( (GNUNET_YES == me->master) ||
300 (GNUNET_YES == p->dest->master) ) )
302 GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
303 "%s disconnected from %s while benchmarking\n",
308 GNUNET_TRANSPORT_notify_transmit_ready_cancel (p->tth);
313 GNUNET_CORE_notify_transmit_ready_cancel (p->cth);
322 core_connect_adapter (void *cls,
323 const struct GNUNET_CONFIGURATION_Handle *cfg)
325 struct BenchmarkPeer *me = cls;
327 me->ch = GNUNET_CORE_connect (cfg,
338 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
339 "Failed to create core connection \n");
345 core_disconnect_adapter (void *cls, void *op_result)
347 struct BenchmarkPeer *me = cls;
349 GNUNET_CORE_disconnect (me->ch);
355 comm_handle_pong (void *cls,
356 const struct GNUNET_PeerIdentity *other,
357 const struct GNUNET_MessageHeader *message)
359 struct BenchmarkPeer *me = cls;
360 struct BenchmarkPartner *p = NULL;
362 if (NULL == (p = find_partner (me, other)))
365 return GNUNET_SYSERR;
368 GNUNET_ATS_TEST_traffic_handle_pong (p);
375 comm_handle_ping (void *cls,
376 const struct GNUNET_PeerIdentity *other,
377 const struct GNUNET_MessageHeader *message)
379 struct BenchmarkPeer *me = cls;
380 struct BenchmarkPartner *p = NULL;
382 if (NULL == (p = find_partner(me, other)))
385 return GNUNET_SYSERR;
387 GNUNET_ATS_TEST_traffic_handle_ping (p);
393 test_recv_cb (void *cls,
394 const struct GNUNET_PeerIdentity *peer,
395 const struct GNUNET_MessageHeader *message)
397 if ( (TEST_MESSAGE_SIZE != ntohs (message->size)) ||
398 ( (TEST_MESSAGE_TYPE_PING != ntohs (message->type)) &&
399 (TEST_MESSAGE_TYPE_PONG != ntohs (message->type)) ) )
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);
411 transport_connect_adapter (void *cls,
412 const struct GNUNET_CONFIGURATION_Handle *cfg)
414 struct BenchmarkPeer *me = cls;
416 me->th = GNUNET_TRANSPORT_connect (cfg,
421 &comm_disconnect_cb);
423 GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
424 "Failed to create transport connection \n");
430 transport_disconnect_adapter (void *cls, void *op_result)
432 struct BenchmarkPeer *me = cls;
434 GNUNET_TRANSPORT_disconnect (me->th);
440 connect_completion_callback (void *cls,
441 struct GNUNET_TESTBED_Operation *op,
444 struct TestbedConnectOperation *cop = cls;
449 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
450 _("Connected master [%u] with slave [%u]\n"),
456 GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
457 _("Failed to connect master peer [%u] with slave [%u]\n"),
458 cop->master->no, cop->slave->no);
460 GNUNET_SCHEDULER_shutdown ();
462 GNUNET_TESTBED_operation_done (op);
464 for (c = 0; c < top->num_slaves; c++)
466 if (cop == &cop->master->core_connect_ops[c])
467 cop->master->core_connect_ops[c].connect_op = NULL;
469 if (ops == top->num_masters * top->num_slaves)
471 top->state.connected_PEERS = GNUNET_YES;
477 do_connect_peers (void *cls)
481 struct BenchmarkPeer *p;
483 if ((top->state.connected_ATS_service == GNUNET_NO) ||
484 (top->state.connected_COMM_service == GNUNET_NO))
487 GNUNET_log(GNUNET_ERROR_TYPE_INFO, _("Connecting peers on CORE level\n"));
489 for (c_m = 0; c_m < top->num_masters; c_m++)
492 p->core_connect_ops = GNUNET_malloc (top->num_slaves *
493 sizeof (struct TestbedConnectOperation));
495 for (c_s = 0; c_s < top->num_slaves; c_s++)
497 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
498 _("Connecting master [%u] with slave [%u]\n"), p->no, top->sps[c_s].no);
499 p->core_connect_ops[c_s].master = p;
500 p->core_connect_ops[c_s].slave = &top->sps[c_s];
501 p->core_connect_ops[c_s].connect_op = GNUNET_TESTBED_overlay_connect (
502 NULL, &connect_completion_callback, &p->core_connect_ops[c_s],
503 top->sps[c_s].peer, p->peer);
504 if (NULL == p->core_connect_ops[c_s].connect_op)
506 GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
507 _("Could not connect master [%u] and slave [%u]\n"), p->no,
510 GNUNET_SCHEDULER_shutdown ();
519 comm_connect_completion_cb (void *cls,
520 struct GNUNET_TESTBED_Operation *op,
524 static int comm_done = 0;
526 if ((NULL != emsg) || (NULL == ca_result))
528 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
529 "Initialization failed, shutdown\n");
531 GNUNET_SCHEDULER_shutdown ();
536 if (comm_done == top->num_slaves + top->num_masters)
538 GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Connected to all %s services\n",
539 (GNUNET_YES == top->test_core) ? "CORE" : "TRANSPORT");
540 top->state.connected_COMM_service = GNUNET_YES;
541 GNUNET_SCHEDULER_add_now (&do_connect_peers, NULL );
547 do_comm_connect (void *cls)
551 GNUNET_log(GNUNET_ERROR_TYPE_INFO, "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++)
555 if (GNUNET_YES == top->test_core)
556 top->mps[c_m].comm_op = GNUNET_TESTBED_service_connect (NULL, top->mps[c_m].peer,
557 "core", &comm_connect_completion_cb, NULL, &core_connect_adapter,
558 &core_disconnect_adapter, &top->mps[c_m]);
561 top->mps[c_m].comm_op = GNUNET_TESTBED_service_connect (NULL, top->mps[c_m].peer,
562 "transport", &comm_connect_completion_cb, NULL, &transport_connect_adapter,
563 &transport_disconnect_adapter, &top->mps[c_m]);
567 for (c_s = 0; c_s < top->num_slaves; c_s++)
569 if (GNUNET_YES == top->test_core)
570 top->sps[c_s].comm_op = GNUNET_TESTBED_service_connect (NULL, top->sps[c_s].peer,
571 "core", &comm_connect_completion_cb, NULL, &core_connect_adapter,
572 &core_disconnect_adapter, &top->sps[c_s]);
575 top->sps[c_s].comm_op = GNUNET_TESTBED_service_connect (NULL, top->sps[c_s].peer,
576 "transport", &comm_connect_completion_cb, NULL, &transport_connect_adapter,
577 &transport_disconnect_adapter, &top->sps[c_s]);
584 ats_performance_info_cb (void *cls,
585 const struct GNUNET_HELLO_Address *address,
587 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out,
588 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
589 const struct GNUNET_ATS_Properties *ats_prop)
591 struct BenchmarkPeer *me = cls;
592 struct BenchmarkPartner *p;
598 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Peer %u: ATS Service disconnected!\n",
603 p = find_partner (me, &address->peer);
606 /* This is not one of my partners
607 * Will happen since the peers will connect to each other due to gossiping
611 peer_id = GNUNET_strdup (GNUNET_i2s (&me->id));
614 if ((p->bandwidth_in != ntohl (bandwidth_in.value__)) ||
615 (p->bandwidth_out != ntohl (bandwidth_out.value__)))
617 p->bandwidth_in = ntohl (bandwidth_in.value__);
618 p->bandwidth_out = ntohl (bandwidth_out.value__);
620 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
621 "%s [%u] received ATS information: %s\n",
622 (GNUNET_YES == p->me->master) ? "Master" : "Slave",
624 GNUNET_i2s (&p->dest->id));
626 p->props.utilization_out = ats_prop->utilization_out;
627 p->props.utilization_in = ats_prop->utilization_in;
628 p->props.scope = ats_prop->scope;
629 p->props.delay = ats_prop->delay;
630 p->props.distance = ats_prop->distance;
632 if (GNUNET_YES == log)
633 top->ats_perf_cb (cls, address,
638 GNUNET_free(peer_id);
643 ats_perf_connect_adapter (void *cls,
644 const struct GNUNET_CONFIGURATION_Handle *cfg)
646 struct BenchmarkPeer *me = cls;
649 = GNUNET_ATS_performance_init (cfg,
650 &ats_performance_info_cb,
652 if (NULL == me->ats_perf_handle)
653 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
654 "Failed to create ATS performance handle \n");
655 return me->ats_perf_handle;
660 ats_perf_disconnect_adapter (void *cls, void *op_result)
662 struct BenchmarkPeer *me = cls;
664 GNUNET_ATS_performance_done (me->ats_perf_handle);
665 me->ats_perf_handle = NULL;
670 ats_connect_completion_cb (void *cls,
671 struct GNUNET_TESTBED_Operation *op,
675 static int op_done = 0;
677 if ((NULL != emsg) || (NULL == ca_result))
679 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
680 "Initialization failed, shutdown\n");
682 GNUNET_SCHEDULER_shutdown ();
686 if (op_done == (top->num_masters + top->num_slaves))
688 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
689 "Connected to all ATS services\n");
690 top->state.connected_ATS_service = GNUNET_YES;
691 GNUNET_SCHEDULER_add_now (&do_comm_connect,
698 do_connect_ats (void *cls)
703 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
704 "Connecting to all ATS services\n");
705 for (c_m = 0; c_m < top->num_masters; c_m++)
707 top->mps[c_m].ats_perf_op
708 = GNUNET_TESTBED_service_connect (NULL,
711 &ats_connect_completion_cb,
713 &ats_perf_connect_adapter,
714 &ats_perf_disconnect_adapter,
718 for (c_s = 0; c_s < top->num_slaves; c_s++)
720 top->sps[c_s].ats_perf_op
721 = GNUNET_TESTBED_service_connect (NULL,
724 &ats_connect_completion_cb,
726 &ats_perf_connect_adapter,
727 &ats_perf_disconnect_adapter,
735 peerinformation_cb (void *cb_cls,
736 struct GNUNET_TESTBED_Operation *op,
737 const struct GNUNET_TESTBED_PeerInformation *pinfo,
740 struct BenchmarkPeer *p = cb_cls;
743 GNUNET_assert(pinfo->pit == GNUNET_TESTBED_PIT_IDENTITY);
745 p->id = *pinfo->result.id;
746 GNUNET_log(GNUNET_ERROR_TYPE_INFO, "%s [%u] has peer id `%s'\n",
747 (p->master == GNUNET_YES) ? "Master" : "Slave", p->no,
748 GNUNET_i2s (&p->id));
750 GNUNET_TESTBED_operation_done (op);
751 p->peer_id_op = NULL;
754 if (done == top->num_slaves + top->num_masters)
756 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
757 "Retrieved all peer ID, connect to ATS\n");
758 GNUNET_SCHEDULER_add_now (&do_connect_ats, NULL );
763 * Signature of a main function for a testcase.
766 * @param h testbed handle
767 * @param num_peers number of peers in 'peers'
768 * @param peers_ handle to peers run in the testbed
769 * @param links_succeeded the number of overlay link connection attempts that
771 * @param links_failed the number of overlay link connection attempts that
775 main_run (void *cls, struct GNUNET_TESTBED_RunHandle *h,
776 unsigned int num_peers,
777 struct GNUNET_TESTBED_Peer **peers_,
778 unsigned int links_succeeded,
779 unsigned int links_failed)
784 GNUNET_assert(NULL == cls);
785 GNUNET_assert(top->num_masters + top->num_slaves == num_peers);
786 GNUNET_assert(NULL != peers_);
788 GNUNET_SCHEDULER_add_shutdown (&do_shutdown,
791 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
792 "Setting up %u masters and %u slaves\n",
796 /* Setup master peers */
797 for (c_m = 0; c_m < top->num_masters; c_m++)
799 GNUNET_assert(NULL != peers_[c_m]);
800 top->mps[c_m].peer = peers_[c_m];
801 top->mps[c_m].no = c_m;
802 top->mps[c_m].master = GNUNET_YES;
803 top->mps[c_m].pref_partner = &top->sps[c_m];
804 top->mps[c_m].pref_value = TEST_ATS_PREFERENCE_DEFAULT;
805 top->mps[c_m].partners =
806 GNUNET_malloc (top->num_slaves * sizeof (struct BenchmarkPartner));
807 top->mps[c_m].num_partners = top->num_slaves;
808 /* Initialize partners */
809 for (c_s = 0; c_s < top->num_slaves; c_s++)
811 top->mps[c_m].partners[c_s].me = &top->mps[c_m];
812 top->mps[c_m].partners[c_s].dest = &top->sps[c_s];
814 /* Get configuration */
815 top->mps[c_m].peer_id_op = GNUNET_TESTBED_peer_get_information (top->mps[c_m].peer,
816 GNUNET_TESTBED_PIT_IDENTITY, &peerinformation_cb, &top->mps[c_m]);
819 /* Setup slave peers */
820 for (c_s = 0; c_s < top->num_slaves; c_s++)
822 GNUNET_assert(NULL != peers_[c_s + top->num_masters]);
823 top->sps[c_s].peer = peers_[c_s + top->num_masters];
824 top->sps[c_s].no = c_s + top->num_masters;
825 top->sps[c_s].master = GNUNET_NO;
826 top->sps[c_s].partners =
827 GNUNET_malloc (top->num_masters * sizeof (struct BenchmarkPartner));
828 top->sps[c_s].num_partners = top->num_masters;
829 /* Initialize partners */
830 for (c_m = 0; c_m < top->num_masters; c_m++)
832 top->sps[c_s].partners[c_m].me = &top->sps[c_s];
833 top->sps[c_s].partners[c_m].dest = &top->mps[c_m];
835 /* Initialize properties */
836 top->sps[c_s].partners[c_m].props.delay = GNUNET_TIME_UNIT_ZERO;
837 top->sps[c_s].partners[c_m].props.distance = 0;
838 top->sps[c_s].partners[c_m].props.scope = GNUNET_ATS_NET_UNSPECIFIED;
839 top->sps[c_s].partners[c_m].props.utilization_in = 0;
840 top->sps[c_s].partners[c_m].props.utilization_out = 0;
842 /* Get configuration */
843 top->sps[c_s].peer_id_op = GNUNET_TESTBED_peer_get_information (top->sps[c_s].peer,
844 GNUNET_TESTBED_PIT_IDENTITY, &peerinformation_cb, &top->sps[c_s]);
849 * Controller event callback
852 * @param event the controller event
855 controller_event_cb (void *cls,
856 const struct GNUNET_TESTBED_EventInformation *event)
860 case GNUNET_TESTBED_ET_CONNECT:
862 case GNUNET_TESTBED_ET_OPERATION_FINISHED:
866 GNUNET_SCHEDULER_shutdown ();
871 struct BenchmarkPeer *
872 GNUNET_ATS_TEST_get_peer (int src)
874 if (src > top->num_masters)
876 return &top->mps[src];
880 struct BenchmarkPartner *
881 GNUNET_ATS_TEST_get_partner (int src, int dest)
883 if (src > top->num_masters)
885 if (dest > top->num_slaves)
887 return &top->mps[src].partners[dest];
892 * Create a topology for ats testing
894 * @param name test name
895 * @param cfg_file configuration file to use for the peers
896 * @param num_slaves number of slaves
897 * @param num_masters number of masters
898 * @param test_core connect to CORE service (GNUNET_YES) or transport (GNUNET_NO)
899 * @param done_cb function to call when topology is setup
900 * @param done_cb_cls cls for callback
901 * @param log_request_cb callback to call when logging is required
904 GNUNET_ATS_TEST_create_topology (char *name, char *cfg_file,
905 unsigned int num_slaves,
906 unsigned int num_masters,
908 GNUNET_ATS_TEST_TopologySetupDoneCallback done_cb,
910 GNUNET_ATS_AddressInformationCallback log_request_cb)
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 },
917 top = GNUNET_new (struct GNUNET_ATS_TEST_Topology);
918 top->num_masters = num_masters;
919 top->num_slaves = num_slaves;
920 top->handlers = handlers;
921 top->done_cb = done_cb;
922 top->done_cb_cls = done_cb_cls;
923 top->test_core = test_core;
924 top->ats_perf_cb = log_request_cb;
926 top->mps = GNUNET_new_array (num_masters,
927 struct BenchmarkPeer);
928 top->sps = GNUNET_new_array (num_slaves,
929 struct BenchmarkPeer);
934 event_mask |= (1LL << GNUNET_TESTBED_ET_CONNECT);
935 event_mask |= (1LL << GNUNET_TESTBED_ET_OPERATION_FINISHED);
936 (void) GNUNET_TESTBED_test_run (name, cfg_file,
938 num_slaves + num_masters,
940 &controller_event_cb, NULL,
949 GNUNET_ATS_TEST_shutdown_topology (void)
953 GNUNET_SCHEDULER_shutdown();
960 /* end of file ats-testing.c */