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, _("Benchmarking done\n"));
73 GNUNET_ATS_TEST_generate_traffic_stop_all ();
75 for (c_m = 0; c_m < top->num_masters; c_m++)
78 if (NULL != top->mps[c_m].peer_id_op)
80 GNUNET_TESTBED_operation_done (p->peer_id_op);
84 if (NULL != p->ats_task)
85 GNUNET_SCHEDULER_cancel (p->ats_task);
88 for (c_op = 0; c_op < p->num_partners; c_op++)
90 if (NULL != p->partners[c_op].cth)
92 GNUNET_CORE_notify_transmit_ready_cancel (p->partners[c_op].cth);
93 p->partners[c_op].cth = NULL;
95 if (NULL != p->partners[c_op].tth)
97 GNUNET_TRANSPORT_notify_transmit_ready_cancel (p->partners[c_op].tth);
98 p->partners[c_op].tth = NULL;
100 if ( (NULL != p->core_connect_ops) &&
101 (NULL != p->core_connect_ops[c_op].connect_op) )
103 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
104 _("Failed to connect peer 0 and %u\n"), c_op);
105 GNUNET_TESTBED_operation_done (
106 p->core_connect_ops[c_op].connect_op);
107 p->core_connect_ops[c_op].connect_op = NULL;
111 if (NULL != p->ats_perf_op)
113 GNUNET_TESTBED_operation_done (p->ats_perf_op);
114 p->ats_perf_op = NULL;
117 if (NULL != p->comm_op)
119 GNUNET_TESTBED_operation_done (p->comm_op);
122 GNUNET_free_non_null (p->core_connect_ops);
123 GNUNET_free(p->partners);
127 for (c_s = 0; c_s < top->num_slaves; c_s++)
130 if (NULL != p->peer_id_op)
132 GNUNET_TESTBED_operation_done (p->peer_id_op);
133 p->peer_id_op = NULL;
136 for (c_op = 0; c_op < p->num_partners; c_op++)
138 if (NULL != p->partners[c_op].cth)
140 GNUNET_CORE_notify_transmit_ready_cancel (p->partners[c_op].cth);
141 p->partners[c_op].cth = NULL;
143 if (NULL != p->partners[c_op].tth)
145 GNUNET_TRANSPORT_notify_transmit_ready_cancel (p->partners[c_op].tth);
146 p->partners[c_op].tth = NULL;
149 if (NULL != p->ats_perf_op)
151 GNUNET_TESTBED_operation_done (p->ats_perf_op);
152 p->ats_perf_op = NULL;
154 if (NULL != p->comm_op)
156 GNUNET_TESTBED_operation_done (p->comm_op);
159 GNUNET_free(p->partners);
162 GNUNET_SCHEDULER_shutdown ();
167 static struct BenchmarkPartner *
168 find_partner (struct BenchmarkPeer *me, const struct GNUNET_PeerIdentity * peer)
171 GNUNET_assert (NULL != me);
172 GNUNET_assert (NULL != peer);
174 for (c_m = 0; c_m < me->num_partners; c_m++)
176 /* Find a partner with other as destination */
177 if (0 == memcmp (peer, &me->partners[c_m].dest->id,
178 sizeof(struct GNUNET_PeerIdentity)))
180 return &me->partners[c_m];
188 static struct BenchmarkPeer *
189 find_peer (const struct GNUNET_PeerIdentity * peer)
193 for (c_p = 0; c_p < top->num_masters; c_p++)
195 if (0 == memcmp (&top->mps[c_p].id, peer, sizeof(struct GNUNET_PeerIdentity)))
196 return &top->mps[c_p];
199 for (c_p = 0; c_p < top->num_slaves; c_p++)
201 if (0 == memcmp (&top->sps[c_p].id, peer, sizeof(struct GNUNET_PeerIdentity)))
202 return &top->sps[c_p];
209 * Method called whenever a given peer connects.
212 * @param peer peer identity this notification is about
215 comm_connect_cb (void *cls, const struct GNUNET_PeerIdentity * peer)
217 struct BenchmarkPeer *me = cls;
218 struct BenchmarkPeer *remote;
223 remote = find_peer (peer);
226 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Unknown peer connected: `%s'\n", GNUNET_i2s (peer));
231 id = GNUNET_strdup (GNUNET_i2s (&me->id));
232 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "%s [%u] `%s' connected to %s [%u] %s\n",
233 (me->master == GNUNET_YES) ? "Master": "Slave", me->no, id,
234 (remote->master == GNUNET_YES) ? "Master": "Slave", remote->no,
237 me->core_connections++;
238 if ((GNUNET_YES == me->master) && (GNUNET_NO == remote->master)
239 && (GNUNET_NO == top->state.connected_CORE))
241 me->core_slave_connections++;
243 if (me->core_slave_connections == top->num_slaves)
245 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
246 "Master [%u] connected all slaves\n",
249 completed = GNUNET_YES;
250 for (c = 0; c < top->num_masters; c++)
252 if (top->mps[c].core_slave_connections != top->num_slaves)
253 completed = GNUNET_NO;
255 if (GNUNET_YES == completed)
257 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
258 "All master peers connected all slave peers\n");
259 top->state.connected_CORE = GNUNET_YES;
260 /* Notify about setup done */
261 if (NULL != top->done_cb)
262 top->done_cb (top->done_cb_cls, top->mps, top->sps);
269 comm_disconnect_cb (void *cls, const struct GNUNET_PeerIdentity * peer)
271 struct BenchmarkPeer *me = cls;
272 struct BenchmarkPartner *p;
275 if (NULL == (p = find_partner (me, peer)))
278 id = GNUNET_strdup (GNUNET_i2s (&me->id));
279 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "%s disconnected from %s \n", id,
281 GNUNET_assert(me->core_connections > 0);
282 me->core_connections--;
284 if ((GNUNET_YES == top->state.benchmarking)
285 && ((GNUNET_YES == me->master) || (GNUNET_YES == p->dest->master)))
287 GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
288 "%s disconnected from %s while benchmarking \n", id, GNUNET_i2s (peer));
291 GNUNET_TRANSPORT_notify_transmit_ready_cancel (p->tth);
296 GNUNET_CORE_notify_transmit_ready_cancel (p->cth);
305 core_connect_adapter (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg)
307 struct BenchmarkPeer *me = cls;
309 me->ch = GNUNET_CORE_connect (cfg, me, NULL, comm_connect_cb,
310 comm_disconnect_cb, NULL, GNUNET_NO, NULL, GNUNET_NO, top->handlers);
312 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Failed to create core connection \n");
317 core_disconnect_adapter (void *cls, void *op_result)
319 struct BenchmarkPeer *me = cls;
321 GNUNET_CORE_disconnect (me->ch);
329 comm_handle_pong (void *cls, const struct GNUNET_PeerIdentity *other,
330 const struct GNUNET_MessageHeader *message)
332 struct BenchmarkPeer *me = cls;
333 struct BenchmarkPartner *p = NULL;
335 if (NULL == (p = find_partner (me, other)))
338 return GNUNET_SYSERR;
341 GNUNET_ATS_TEST_traffic_handle_pong (p);
347 comm_handle_ping (void *cls, const struct GNUNET_PeerIdentity *other,
348 const struct GNUNET_MessageHeader *message)
350 struct BenchmarkPeer *me = cls;
351 struct BenchmarkPartner *p = NULL;
353 if (NULL == (p = find_partner(me, other)))
356 return GNUNET_SYSERR;
358 GNUNET_ATS_TEST_traffic_handle_ping (p);
363 test_recv_cb (void *cls,
364 const struct GNUNET_PeerIdentity * peer,
365 const struct GNUNET_MessageHeader * message)
367 if (TEST_MESSAGE_SIZE != ntohs (message->size) ||
368 (TEST_MESSAGE_TYPE_PING != ntohs (message->type) &&
369 TEST_MESSAGE_TYPE_PONG != ntohs (message->type)))
373 if (TEST_MESSAGE_TYPE_PING == ntohs (message->type))
374 comm_handle_ping (cls, peer, message);
375 if (TEST_MESSAGE_TYPE_PONG == ntohs (message->type))
376 comm_handle_pong (cls, peer, message);
381 transport_connect_adapter (void *cls,
382 const struct GNUNET_CONFIGURATION_Handle *cfg)
384 struct BenchmarkPeer *me = cls;
386 me->th = GNUNET_TRANSPORT_connect (cfg, &me->id, me, &test_recv_cb,
387 &comm_connect_cb, &comm_disconnect_cb);
389 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Failed to create transport connection \n");
395 transport_disconnect_adapter (void *cls, void *op_result)
397 struct BenchmarkPeer *me = cls;
399 GNUNET_TRANSPORT_disconnect (me->th);
405 connect_completion_callback (void *cls,
406 struct GNUNET_TESTBED_Operation *op,
409 struct TestbedConnectOperation *cop = cls;
414 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
415 _("Connected master [%u] with slave [%u]\n"),
421 GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
422 _("Failed to connect master peer [%u] with slave [%u]\n"),
423 cop->master->no, cop->slave->no);
425 GNUNET_SCHEDULER_shutdown ();
427 GNUNET_TESTBED_operation_done (op);
429 for (c = 0; c < top->num_slaves; c++)
431 if (cop == &cop->master->core_connect_ops[c])
432 cop->master->core_connect_ops[c].connect_op = NULL;
434 if (ops == top->num_masters * top->num_slaves)
436 top->state.connected_PEERS = GNUNET_YES;
442 do_connect_peers (void *cls)
446 struct BenchmarkPeer *p;
448 if ((top->state.connected_ATS_service == GNUNET_NO) ||
449 (top->state.connected_COMM_service == GNUNET_NO))
452 GNUNET_log(GNUNET_ERROR_TYPE_INFO, _("Connecting peers on CORE level\n"));
454 for (c_m = 0; c_m < top->num_masters; c_m++)
457 p->core_connect_ops = GNUNET_malloc (top->num_slaves *
458 sizeof (struct TestbedConnectOperation));
460 for (c_s = 0; c_s < top->num_slaves; c_s++)
462 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
463 _("Connecting master [%u] with slave [%u]\n"), p->no, top->sps[c_s].no);
464 p->core_connect_ops[c_s].master = p;
465 p->core_connect_ops[c_s].slave = &top->sps[c_s];
466 p->core_connect_ops[c_s].connect_op = GNUNET_TESTBED_overlay_connect (
467 NULL, &connect_completion_callback, &p->core_connect_ops[c_s],
468 top->sps[c_s].peer, p->peer);
469 if (NULL == p->core_connect_ops[c_s].connect_op)
471 GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
472 _("Could not connect master [%u] and slave [%u]\n"), p->no,
475 GNUNET_SCHEDULER_shutdown ();
484 comm_connect_completion_cb (void *cls,
485 struct GNUNET_TESTBED_Operation *op,
489 static int comm_done = 0;
491 if ((NULL != emsg) || (NULL == ca_result))
493 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
494 "Initialization failed, shutdown\n");
496 GNUNET_SCHEDULER_shutdown ();
501 if (comm_done == top->num_slaves + top->num_masters)
503 GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Connected to all %s services\n",
504 (GNUNET_YES == top->test_core) ? "CORE" : "TRANSPORT");
505 top->state.connected_COMM_service = GNUNET_YES;
506 GNUNET_SCHEDULER_add_now (&do_connect_peers, NULL );
512 do_comm_connect (void *cls)
516 GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Connecting to all %s services\n",
517 (GNUNET_YES == top->test_core) ? "CORE" : "TRANSPORT");
518 for (c_m = 0; c_m < top->num_masters; c_m++)
520 if (GNUNET_YES == top->test_core)
521 top->mps[c_m].comm_op = GNUNET_TESTBED_service_connect (NULL, top->mps[c_m].peer,
522 "core", &comm_connect_completion_cb, NULL, &core_connect_adapter,
523 &core_disconnect_adapter, &top->mps[c_m]);
526 top->mps[c_m].comm_op = GNUNET_TESTBED_service_connect (NULL, top->mps[c_m].peer,
527 "transport", &comm_connect_completion_cb, NULL, &transport_connect_adapter,
528 &transport_disconnect_adapter, &top->mps[c_m]);
532 for (c_s = 0; c_s < top->num_slaves; c_s++)
534 if (GNUNET_YES == top->test_core)
535 top->sps[c_s].comm_op = GNUNET_TESTBED_service_connect (NULL, top->sps[c_s].peer,
536 "core", &comm_connect_completion_cb, NULL, &core_connect_adapter,
537 &core_disconnect_adapter, &top->sps[c_s]);
540 top->sps[c_s].comm_op = GNUNET_TESTBED_service_connect (NULL, top->sps[c_s].peer,
541 "transport", &comm_connect_completion_cb, NULL, &transport_connect_adapter,
542 &transport_disconnect_adapter, &top->sps[c_s]);
549 ats_performance_info_cb (void *cls,
550 const struct GNUNET_HELLO_Address *address,
552 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out,
553 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
554 const struct GNUNET_ATS_Properties *ats_prop)
556 struct BenchmarkPeer *me = cls;
557 struct BenchmarkPartner *p;
563 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Peer %u: ATS Service disconnected!\n",
568 p = find_partner (me, &address->peer);
571 /* This is not one of my partners
572 * Will happen since the peers will connect to each other due to gossiping
576 peer_id = GNUNET_strdup (GNUNET_i2s (&me->id));
579 if ((p->bandwidth_in != ntohl (bandwidth_in.value__)) ||
580 (p->bandwidth_out != ntohl (bandwidth_out.value__)))
582 p->bandwidth_in = ntohl (bandwidth_in.value__);
583 p->bandwidth_out = ntohl (bandwidth_out.value__);
585 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "%s [%u] received ATS information: %s\n",
586 (GNUNET_YES == p->me->master) ? "Master" : "Slave",
588 GNUNET_i2s (&p->dest->id));
590 p->props.utilization_out = ats_prop->utilization_out;
591 p->props.utilization_in = ats_prop->utilization_in;
592 p->props.scope = ats_prop->scope;
593 p->props.delay = ats_prop->delay;
594 p->props.distance = ats_prop->distance;
596 if (GNUNET_YES == log)
597 top->ats_perf_cb (cls, address,
602 GNUNET_free(peer_id);
607 ats_perf_connect_adapter (void *cls,
608 const struct GNUNET_CONFIGURATION_Handle *cfg)
610 struct BenchmarkPeer *me = cls;
612 me->ats_perf_handle = GNUNET_ATS_performance_init (cfg,
613 &ats_performance_info_cb, me);
614 if (NULL == me->ats_perf_handle)
615 GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
616 "Failed to create ATS performance handle \n");
617 return me->ats_perf_handle;
621 ats_perf_disconnect_adapter (void *cls, void *op_result)
623 struct BenchmarkPeer *me = cls;
625 GNUNET_ATS_performance_done (me->ats_perf_handle);
626 me->ats_perf_handle = NULL;
630 ats_connect_completion_cb (void *cls, struct GNUNET_TESTBED_Operation *op,
631 void *ca_result, const char *emsg)
633 static int op_done = 0;
635 if ((NULL != emsg) || (NULL == ca_result))
637 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
638 "Initialization failed, shutdown\n");
640 GNUNET_SCHEDULER_shutdown ();
644 if (op_done == (top->num_masters + top->num_slaves))
646 GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Connected to all ATS services\n");
647 top->state.connected_ATS_service = GNUNET_YES;
648 GNUNET_SCHEDULER_add_now (&do_comm_connect, NULL );
654 do_connect_ats (void *cls)
659 GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Connecting to all ATS services\n");
660 for (c_m = 0; c_m < top->num_masters; c_m++)
662 top->mps[c_m].ats_perf_op = GNUNET_TESTBED_service_connect (NULL,
664 "ats", ats_connect_completion_cb, NULL,
665 &ats_perf_connect_adapter,
666 &ats_perf_disconnect_adapter, &top->mps[c_m]);
669 for (c_s = 0; c_s < top->num_slaves; c_s++)
671 top->sps[c_s].ats_perf_op = GNUNET_TESTBED_service_connect (NULL, top->sps[c_s].peer,
672 "ats", ats_connect_completion_cb, NULL, &ats_perf_connect_adapter,
673 &ats_perf_disconnect_adapter, &top->sps[c_s]);
680 peerinformation_cb (void *cb_cls, struct GNUNET_TESTBED_Operation *op,
681 const struct GNUNET_TESTBED_PeerInformation*pinfo, const char *emsg)
683 struct BenchmarkPeer *p = cb_cls;
686 GNUNET_assert(pinfo->pit == GNUNET_TESTBED_PIT_IDENTITY);
688 p->id = *pinfo->result.id;
689 GNUNET_log(GNUNET_ERROR_TYPE_INFO, "%s [%u] has peer id `%s'\n",
690 (p->master == GNUNET_YES) ? "Master" : "Slave", p->no,
691 GNUNET_i2s (&p->id));
693 GNUNET_TESTBED_operation_done (op);
694 p->peer_id_op = NULL;
697 if (done == top->num_slaves + top->num_masters)
699 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
700 "Retrieved all peer ID, connect to ATS\n");
701 GNUNET_SCHEDULER_add_now (&do_connect_ats, NULL );
706 * Signature of a main function for a testcase.
709 * @param h testbed handle
710 * @param num_peers number of peers in 'peers'
711 * @param peers_ handle to peers run in the testbed
712 * @param links_succeeded the number of overlay link connection attempts that
714 * @param links_failed the number of overlay link connection attempts that
718 main_run (void *cls, struct GNUNET_TESTBED_RunHandle *h,
719 unsigned int num_peers,
720 struct GNUNET_TESTBED_Peer **peers_,
721 unsigned int links_succeeded,
722 unsigned int links_failed)
727 GNUNET_assert(NULL == cls);
728 GNUNET_assert(top->num_masters + top->num_slaves == num_peers);
729 GNUNET_assert(NULL != peers_);
731 GNUNET_SCHEDULER_add_shutdown (&do_shutdown,
734 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
735 "Setting up %u masters and %u slaves\n",
739 /* Setup master peers */
740 for (c_m = 0; c_m < top->num_masters; c_m++)
742 GNUNET_assert(NULL != peers_[c_m]);
743 top->mps[c_m].peer = peers_[c_m];
744 top->mps[c_m].no = c_m;
745 top->mps[c_m].master = GNUNET_YES;
746 top->mps[c_m].pref_partner = &top->sps[c_m];
747 top->mps[c_m].pref_value = TEST_ATS_PREFERENCE_DEFAULT;
748 top->mps[c_m].partners =
749 GNUNET_malloc (top->num_slaves * sizeof (struct BenchmarkPartner));
750 top->mps[c_m].num_partners = top->num_slaves;
751 /* Initialize partners */
752 for (c_s = 0; c_s < top->num_slaves; c_s++)
754 top->mps[c_m].partners[c_s].me = &top->mps[c_m];
755 top->mps[c_m].partners[c_s].dest = &top->sps[c_s];
757 /* Get configuration */
758 top->mps[c_m].peer_id_op = GNUNET_TESTBED_peer_get_information (top->mps[c_m].peer,
759 GNUNET_TESTBED_PIT_IDENTITY, &peerinformation_cb, &top->mps[c_m]);
762 /* Setup slave peers */
763 for (c_s = 0; c_s < top->num_slaves; c_s++)
765 GNUNET_assert(NULL != peers_[c_s + top->num_masters]);
766 top->sps[c_s].peer = peers_[c_s + top->num_masters];
767 top->sps[c_s].no = c_s + top->num_masters;
768 top->sps[c_s].master = GNUNET_NO;
769 top->sps[c_s].partners =
770 GNUNET_malloc (top->num_masters * sizeof (struct BenchmarkPartner));
771 top->sps[c_s].num_partners = top->num_masters;
772 /* Initialize partners */
773 for (c_m = 0; c_m < top->num_masters; c_m++)
775 top->sps[c_s].partners[c_m].me = &top->sps[c_s];
776 top->sps[c_s].partners[c_m].dest = &top->mps[c_m];
778 /* Initialize properties */
779 top->sps[c_s].partners[c_m].props.delay = GNUNET_TIME_UNIT_ZERO;
780 top->sps[c_s].partners[c_m].props.distance = 0;
781 top->sps[c_s].partners[c_m].props.scope = GNUNET_ATS_NET_UNSPECIFIED;
782 top->sps[c_s].partners[c_m].props.utilization_in = 0;
783 top->sps[c_s].partners[c_m].props.utilization_out = 0;
785 /* Get configuration */
786 top->sps[c_s].peer_id_op = GNUNET_TESTBED_peer_get_information (top->sps[c_s].peer,
787 GNUNET_TESTBED_PIT_IDENTITY, &peerinformation_cb, &top->sps[c_s]);
792 * Controller event callback
795 * @param event the controller event
798 controller_event_cb (void *cls,
799 const struct GNUNET_TESTBED_EventInformation *event)
803 case GNUNET_TESTBED_ET_CONNECT:
805 case GNUNET_TESTBED_ET_OPERATION_FINISHED:
809 GNUNET_SCHEDULER_shutdown ();
814 struct BenchmarkPeer *
815 GNUNET_ATS_TEST_get_peer (int src)
817 if (src > top->num_masters)
819 return &top->mps[src];
823 struct BenchmarkPartner *
824 GNUNET_ATS_TEST_get_partner (int src, int dest)
826 if (src > top->num_masters)
828 if (dest > top->num_slaves)
830 return &top->mps[src].partners[dest];
835 * Create a topology for ats testing
837 * @param name test name
838 * @param cfg_file configuration file to use for the peers
839 * @param num_slaves number of slaves
840 * @param num_masters number of masters
841 * @param test_core connect to CORE service (GNUNET_YES) or transport (GNUNET_NO)
842 * @param done_cb function to call when topology is setup
843 * @param done_cb_cls cls for callback
844 * @param log_request_cb callback to call when logging is required
847 GNUNET_ATS_TEST_create_topology (char *name, char *cfg_file,
848 unsigned int num_slaves,
849 unsigned int num_masters,
851 GNUNET_ATS_TEST_TopologySetupDoneCallback done_cb,
853 GNUNET_ATS_AddressInformationCallback log_request_cb)
855 static struct GNUNET_CORE_MessageHandler handlers[] = {
856 {&comm_handle_ping, TEST_MESSAGE_TYPE_PING, 0 },
857 {&comm_handle_pong, TEST_MESSAGE_TYPE_PONG, 0 },
860 top = GNUNET_new (struct GNUNET_ATS_TEST_Topology);
861 top->num_masters = num_masters;
862 top->num_slaves = num_slaves;
863 top->handlers = handlers;
864 top->done_cb = done_cb;
865 top->done_cb_cls = done_cb_cls;
866 top->test_core = test_core;
867 top->ats_perf_cb = log_request_cb;
869 top->mps = GNUNET_new_array (num_masters,
870 struct BenchmarkPeer);
871 top->sps = GNUNET_new_array (num_slaves,
872 struct BenchmarkPeer);
877 event_mask |= (1LL << GNUNET_TESTBED_ET_CONNECT);
878 event_mask |= (1LL << GNUNET_TESTBED_ET_OPERATION_FINISHED);
879 (void) GNUNET_TESTBED_test_run (name, cfg_file,
880 num_slaves + num_masters,
882 &controller_event_cb, NULL,
891 GNUNET_ATS_TEST_shutdown_topology (void)
895 GNUNET_SCHEDULER_shutdown();
902 /* end of file ats-testing.c */