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-tests/ats-testing.h
22 * @brief ats testing library: setup topology and provide logging to test ats
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"
32 #define TEST_ATS_PREFERENCE_DEFAULT 1.0
34 #define TEST_MESSAGE_TYPE_PING 12345
35 #define TEST_MESSAGE_TYPE_PONG 12346
36 #define TEST_MESSAGE_SIZE 100
38 struct BenchmarkPartner;
40 struct GNUNET_ATS_TEST_Topology;
41 struct TrafficGenerator;
44 typedef void (*GNUNET_ATS_TEST_TopologySetupDoneCallback) (void *cls,
45 struct BenchmarkPeer *masters,
46 struct BenchmarkPeer *slaves);
49 (*GNUNET_ATS_TEST_LogRequest) (void *cls,
50 const struct GNUNET_HELLO_Address *address, int address_active,
51 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out,
52 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
53 const struct GNUNET_ATS_Information *ats, uint32_t ats_count);
56 * Information we track for a peer in the testbed.
61 * Handle with testbed.
63 struct GNUNET_TESTBED_Peer *peer;
71 * Is this peer a measter: GNUNET_YES/GNUNET_NO
78 struct GNUNET_PeerIdentity id;
81 * Testbed operation to get peer information
83 struct GNUNET_TESTBED_Operation *peer_id_op;
86 * Testbed operation to connect to ATS performance service
88 struct GNUNET_TESTBED_Operation *ats_perf_op;
91 * Testbed operation to connect to core
93 struct GNUNET_TESTBED_Operation *comm_op;
96 * ATS performance handle
98 struct GNUNET_ATS_PerformanceHandle *ats_perf_handle;
102 * Testbed connect operations to connect masters to slaves
104 struct TestbedConnectOperation *core_connect_ops;
109 struct GNUNET_CORE_Handle *ch;
114 struct GNUNET_TRANSPORT_Handle *th;
118 * Peer to set ATS preferences for
120 struct BenchmarkPeer *pref_partner;
126 GNUNET_SCHEDULER_TaskIdentifier ats_task;
135 * Array of partners with num_slaves entries (if master) or
136 * num_master entries (if slave)
138 struct BenchmarkPartner *partners;
146 * Number of core connections
148 int core_connections;
152 * Number of connections to slave peers
154 int core_slave_connections;
157 * Total number of messages this peer has sent
159 unsigned int total_messages_sent;
162 * Total number of bytes this peer has sent
164 unsigned int total_bytes_sent;
167 * Total number of messages this peer has received
169 unsigned int total_messages_received;
172 * Total number of bytes this peer has received
174 unsigned int total_bytes_received;
177 struct TrafficGenerator
179 struct TrafficGenerator *prev;
180 struct TrafficGenerator *next;
182 struct BenchmarkPeer *src;
183 struct BenchmarkPartner *dest;
185 GNUNET_SCHEDULER_TaskIdentifier send_task;
186 struct GNUNET_TIME_Absolute next_ping_transmission;
187 struct GNUNET_TIME_Relative delta;
192 * Information about a benchmarking partner
194 struct BenchmarkPartner
197 * The peer itself this partner belongs to
199 struct BenchmarkPeer *me;
204 struct BenchmarkPeer *dest;
207 * Core transmit handles
209 struct GNUNET_CORE_TransmitHandle *cth;
212 * Transport transmit handles
214 struct GNUNET_TRANSPORT_TransmitHandle *tth;
216 struct TrafficGenerator *tg;
219 * Timestamp to calculate communication layer delay
221 struct GNUNET_TIME_Absolute last_message_sent;
224 * Accumulated RTT for all messages
226 unsigned int total_app_rtt;
229 * Number of messages sent to this partner
231 unsigned int messages_sent;
234 * Number of bytes sent to this partner
236 unsigned int bytes_sent;
239 * Number of messages received from this partner
241 unsigned int messages_received;
244 * Number of bytes received from this partner
246 unsigned int bytes_received;
248 /* Current ATS properties */
250 uint32_t ats_distance;
254 uint32_t bandwidth_in;
256 uint32_t bandwidth_out;
258 uint32_t ats_utilization_up;
260 uint32_t ats_utilization_down;
262 uint32_t ats_network_type;
264 uint32_t ats_cost_wan;
266 uint32_t ats_cost_lan;
268 uint32_t ats_cost_wlan;
272 * Overall state of the performance benchmark
274 struct BenchmarkState
277 * Are we connected to ATS service of all peers: GNUNET_YES/NO
279 int connected_ATS_service;
282 * Are we connected to CORE service of all peers: GNUNET_YES/NO
284 int connected_COMM_service;
287 * Are we connected to all peers: GNUNET_YES/NO
292 * Are we connected to all slave peers on CORE level: GNUNET_YES/NO
297 * Are we connected to CORE service of all peers: GNUNET_YES/NO
303 struct GNUNET_ATS_TEST_Topology
308 GNUNET_SCHEDULER_TaskIdentifier shutdown_task;
313 GNUNET_SCHEDULER_TaskIdentifier progress_task;
320 /**Test core (GNUNET_YES) or transport (GNUNET_NO)
340 * ATS preference value
345 * Number master peers
347 unsigned int num_masters;
350 * Array of master peers
352 struct BenchmarkPeer *mps;
357 unsigned int num_slaves;
360 * Array of slave peers
362 struct BenchmarkPeer *sps;
367 struct GNUNET_TIME_Relative perf_duration;
372 struct GNUNET_TIME_Relative log_frequency;
377 struct BenchmarkState state;
379 struct GNUNET_CORE_MessageHandler *handlers;
381 GNUNET_TRANSPORT_ReceiveCallback transport_recv_cb;
383 GNUNET_ATS_TEST_TopologySetupDoneCallback done_cb;
384 GNUNET_ATS_AddressInformationCallback ats_perf_cb;
392 typedef void (*GNUNET_ATS_TESTING_EpisodeDoneCallback) (
395 typedef void (*GNUNET_ATS_TESTING_ExperimentDoneCallback) (
396 struct Experiment *e, int success);
403 unsigned long long int num_masters;
404 unsigned long long int num_slaves;
405 struct GNUNET_TIME_Relative max_duration;
406 struct GNUNET_TIME_Relative total_duration;
407 struct GNUNET_TIME_Absolute start_time;
408 unsigned int num_episodes;
409 struct Episode *start;
411 GNUNET_SCHEDULER_TaskIdentifier experiment_timeout_task;
412 GNUNET_SCHEDULER_TaskIdentifier episode_timeout_task;
415 GNUNET_ATS_TESTING_EpisodeDoneCallback ep_done_cb;
416 GNUNET_ATS_TESTING_ExperimentDoneCallback e_done_cb;
422 struct Episode *next;
423 struct GNUNET_TIME_Relative duration;
427 GNUNET_ATS_TEST_experimentation_run (struct Experiment *e,
428 GNUNET_ATS_TESTING_EpisodeDoneCallback ep_done_cb,
429 GNUNET_ATS_TESTING_ExperimentDoneCallback e_done_cb);
432 GNUNET_ATS_TEST_experimentation_load (char *filename);
435 GNUNET_ATS_TEST_experimentation_stop (struct Experiment *e);
438 struct TrafficGenerator *
439 GNUNET_ATS_TEST_generate_traffic_start (struct BenchmarkPeer *src,
440 struct BenchmarkPartner *dest, unsigned int rate,
441 struct GNUNET_TIME_Relative duration);
444 GNUNET_ATS_TEST_generate_traffic_stop (struct TrafficGenerator *tg);
447 * Stop all traffic generators
450 GNUNET_ATS_TEST_generate_traffic_stop_all ();
455 struct LoggingHandle *
456 GNUNET_ATS_TEST_logging_start (struct GNUNET_TIME_Relative log_frequency,
457 char * testname, struct BenchmarkPeer *masters, int num_masters);
463 GNUNET_ATS_TEST_logging_stop (struct LoggingHandle *);
469 GNUNET_ATS_TEST_logging_now (struct LoggingHandle *);
472 GNUNET_ATS_TEST_logging_write_to_file (struct LoggingHandle *, char *test);
475 GNUNET_ATS_TEST_traffic_handle_ping (struct BenchmarkPartner *p);
478 GNUNET_ATS_TEST_traffic_handle_pong (struct BenchmarkPartner *p);
482 GNUNET_ATS_TEST_create_topology (char *name, char *cfg_file,
483 unsigned int num_slaves,
484 unsigned int num_masters,
486 GNUNET_ATS_TEST_TopologySetupDoneCallback done_cb,
488 GNUNET_TRANSPORT_ReceiveCallback transport_recv_cb,
489 GNUNET_ATS_TEST_LogRequest ats_perf_cb);
492 GNUNET_ATS_TEST_shutdown_topology (void);
494 /* end of file ats-testing.h */