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, 30)
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 3
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)
49 * Information about a benchmarking partner
51 struct BenchmarkPartner
54 * The peer itself this partner belongs to
56 struct BenchmarkPeer *me;
61 struct BenchmarkPeer *dest;
64 * Core transmit handles
66 struct GNUNET_CORE_TransmitHandle *cth;
69 * Transport transmit handles
71 struct GNUNET_TRANSPORT_TransmitHandle *tth;
74 * Timestamp to calculate communication layer delay
76 struct GNUNET_TIME_Absolute last_message_sent;
79 * Accumulated delay for all messages
81 unsigned int total_app_delay;
84 * Number of messages sent to this partner
86 unsigned int messages_sent;
89 * Number of bytes sent to this partner
91 unsigned int bytes_sent;
94 * Number of messages received from this partner
96 unsigned int messages_received;
99 * Number of bytes received from this partner
101 unsigned int bytes_received;
103 /* Current ATS properties */
105 uint32_t ats_distance;
109 uint32_t bandwidth_in;
111 uint32_t bandwidth_out;
116 * Information we track for a peer in the testbed.
121 * Handle with testbed.
123 struct GNUNET_TESTBED_Peer *peer;
131 * Is this peer a measter: GNUNET_YES/GNUNET_NO
138 struct GNUNET_PeerIdentity id;
141 * Testbed operation to get peer information
143 struct GNUNET_TESTBED_Operation *peer_id_op;
146 * Testbed operation to connect to ATS performance service
148 struct GNUNET_TESTBED_Operation *ats_perf_op;
151 * Testbed operation to connect to core
153 struct GNUNET_TESTBED_Operation *comm_op;
156 * ATS performance handle
158 struct GNUNET_ATS_PerformanceHandle *ats_perf_handle;
162 * Testbed connect operations to connect masters to slaves
164 struct TestbedConnectOperation *core_connect_ops;
169 struct GNUNET_CORE_Handle *ch;
174 struct GNUNET_TRANSPORT_Handle *th;
178 * Peer to set ATS preferences for
180 struct BenchmarkPeer *pref_partner;
186 GNUNET_SCHEDULER_TaskIdentifier ats_task;
195 * Array of partners with num_slaves entries (if master) or
196 * num_master entries (if slave)
198 struct BenchmarkPartner *partners;
206 * Number of core connections
208 int core_connections;
212 * Number of connections to slave peers
214 int core_slave_connections;
217 * Total number of messages this peer has sent
219 unsigned int total_messages_sent;
222 * Total number of bytes this peer has sent
224 unsigned int total_bytes_sent;
227 * Total number of messages this peer has received
229 unsigned int total_messages_received;
232 * Total number of bytes this peer has received
234 unsigned int total_bytes_received;
239 perf_logging_stop ();
242 perf_logging_start (struct GNUNET_TIME_Relative log_frequency,
243 char * testname, struct BenchmarkPeer *masters, int num_masters);
246 /* end of file perf_ats.h */