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"
32 #define TEST_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 120)
33 #define BENCHMARK_DURATION GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10)
34 #define LOGGING_FREQUENCY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 500)
35 #define TESTNAME_PREFIX "perf_ats_"
36 #define DEFAULT_SLAVES_NUM 2
37 #define DEFAULT_MASTERS_NUM 1
39 #define TEST_ATS_PREFRENCE_FREQUENCY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1)
40 #define TEST_ATS_PREFRENCE_START 1.0
41 #define TEST_ATS_PREFRENCE_DELTA 1.0
43 #define TEST_MESSAGE_TYPE_PING 12345
44 #define TEST_MESSAGE_TYPE_PONG 12346
45 #define TEST_MESSAGE_SIZE 1000
46 #define TEST_MESSAGE_FREQUENCY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1)
50 * Overall state of the performance benchmark
55 * Are we connected to ATS service of all peers: GNUNET_YES/NO
57 int connected_ATS_service;
60 * Are we connected to CORE service of all peers: GNUNET_YES/NO
62 int connected_COMM_service;
65 * Are we connected to all peers: GNUNET_YES/NO
70 * Are we connected to all slave peers on CORE level: GNUNET_YES/NO
75 * Are we connected to CORE service of all peers: GNUNET_YES/NO
82 * Information about a benchmarking partner
84 struct BenchmarkPartner
87 * The peer itself this partner belongs to
89 struct BenchmarkPeer *me;
94 struct BenchmarkPeer *dest;
97 * Core transmit handles
99 struct GNUNET_CORE_TransmitHandle *cth;
102 * Transport transmit handles
104 struct GNUNET_TRANSPORT_TransmitHandle *tth;
107 * Timestamp to calculate communication layer delay
109 struct GNUNET_TIME_Absolute last_message_sent;
112 * Accumulated RTT for all messages
114 unsigned int total_app_rtt;
117 * Number of messages sent to this partner
119 unsigned int messages_sent;
122 * Number of bytes sent to this partner
124 unsigned int bytes_sent;
127 * Number of messages received from this partner
129 unsigned int messages_received;
132 * Number of bytes received from this partner
134 unsigned int bytes_received;
136 /* Current ATS properties */
138 uint32_t ats_distance;
142 uint32_t bandwidth_in;
144 uint32_t bandwidth_out;
146 uint32_t ats_utilization_up;
148 uint32_t ats_utilization_down;
150 uint32_t ats_network_type;
152 uint32_t ats_cost_wan;
154 uint32_t ats_cost_lan;
156 uint32_t ats_cost_wlan;
161 * Information we track for a peer in the testbed.
166 * Handle with testbed.
168 struct GNUNET_TESTBED_Peer *peer;
176 * Is this peer a measter: GNUNET_YES/GNUNET_NO
183 struct GNUNET_PeerIdentity id;
186 * Testbed operation to get peer information
188 struct GNUNET_TESTBED_Operation *peer_id_op;
191 * Testbed operation to connect to ATS performance service
193 struct GNUNET_TESTBED_Operation *ats_perf_op;
196 * Testbed operation to connect to core
198 struct GNUNET_TESTBED_Operation *comm_op;
201 * ATS performance handle
203 struct GNUNET_ATS_PerformanceHandle *ats_perf_handle;
207 * Testbed connect operations to connect masters to slaves
209 struct TestbedConnectOperation *core_connect_ops;
214 struct GNUNET_CORE_Handle *ch;
219 struct GNUNET_TRANSPORT_Handle *th;
223 * Peer to set ATS preferences for
225 struct BenchmarkPeer *pref_partner;
231 GNUNET_SCHEDULER_TaskIdentifier ats_task;
240 * Array of partners with num_slaves entries (if master) or
241 * num_master entries (if slave)
243 struct BenchmarkPartner *partners;
251 * Number of core connections
253 int core_connections;
257 * Number of connections to slave peers
259 int core_slave_connections;
262 * Total number of messages this peer has sent
264 unsigned int total_messages_sent;
267 * Total number of bytes this peer has sent
269 unsigned int total_bytes_sent;
272 * Total number of messages this peer has received
274 unsigned int total_messages_received;
277 * Total number of bytes this peer has received
279 unsigned int total_bytes_received;
283 * Connect peers with testbed
285 struct TestbedConnectOperation
288 * The benchmarking master initiating this connection
290 struct BenchmarkPeer *master;
293 * The benchmarking slave to connect to
295 struct BenchmarkPeer *slave;
298 * Testbed operation to connect peers
300 struct GNUNET_TESTBED_Operation *connect_op;
304 struct GNUNET_ATS_TEST_Topology
309 GNUNET_SCHEDULER_TaskIdentifier shutdown_task;
314 GNUNET_SCHEDULER_TaskIdentifier progress_task;
322 * Test result logging
326 /**Test core (GNUNET_YES) or transport (GNUNET_NO)
346 * ATS preference value
351 * Number master peers
353 unsigned int num_masters;
356 * Array of master peers
358 struct BenchmarkPeer *mps;
363 unsigned int num_slaves;
366 * Array of slave peers
368 struct BenchmarkPeer *sps;
373 struct GNUNET_TIME_Relative perf_duration;
378 struct GNUNET_TIME_Relative log_frequency;
383 struct BenchmarkState state;
385 struct GNUNET_CORE_MessageHandler *handlers;
387 GNUNET_TRANSPORT_ReceiveCallback transport_recv_cb;
392 struct GNUNET_ATS_TEST_Topology *
393 GNUNET_ATS_TEST_create_topology (char *name, char *cfg_file,
394 unsigned int num_slaves,
395 unsigned int num_masters,
396 struct GNUNET_CORE_MessageHandler *handlers,
397 GNUNET_TRANSPORT_ReceiveCallback transport_recv_cb);
400 GNUNET_ATS_TEST_destroy_topology (struct GNUNET_ATS_TEST_Topology *top);
402 /* end of file perf_ats.c */