writign plots
[oweals/gnunet.git] / src / ats-tests / perf_ats.h
1 /*
2  This file is part of GNUnet.
3  (C) 2010-2013 Christian Grothoff (and other contributing authors)
4
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.
9
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.
14
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.
19  */
20 /**
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
25  */
26 #include "platform.h"
27 #include "gnunet_util_lib.h"
28 #include "gnunet_testbed_service.h"
29 #include "gnunet_ats_service.h"
30 #include "gnunet_core_service.h"
31
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
38
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
42
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)
47
48 /**
49  * Information about a benchmarking partner
50  */
51 struct BenchmarkPartner
52 {
53   /**
54    * The peer itself this partner belongs to
55    */
56   struct BenchmarkPeer *me;
57
58   /**
59    * The partner peer
60    */
61   struct BenchmarkPeer *dest;
62
63   /**
64    * Core transmit handles
65    */
66   struct GNUNET_CORE_TransmitHandle *cth;
67
68   /**
69    * Transport transmit handles
70    */
71   struct GNUNET_TRANSPORT_TransmitHandle *tth;
72
73   /**
74    * Timestamp to calculate communication layer delay
75    */
76   struct GNUNET_TIME_Absolute last_message_sent;
77
78   /**
79    * Accumulated RTT for all messages
80    */
81   unsigned int total_app_rtt;
82
83   /**
84    * Number of messages sent to this partner
85    */
86   unsigned int messages_sent;
87
88   /**
89    * Number of bytes sent to this partner
90    */
91   unsigned int bytes_sent;
92
93   /**
94    * Number of messages received from this partner
95    */
96   unsigned int messages_received;
97
98   /**
99    * Number of bytes received from this partner
100    */
101   unsigned int bytes_received;
102
103   /* Current ATS properties */
104
105   uint32_t ats_distance;
106
107   uint32_t ats_delay;
108
109   uint32_t bandwidth_in;
110
111   uint32_t bandwidth_out;
112
113   uint32_t ats_utilization_up;
114
115   uint32_t ats_utilization_down;
116
117   uint32_t ats_network_type;
118
119   uint32_t ats_cost_wan;
120
121   uint32_t ats_cost_lan;
122
123   uint32_t ats_cost_wlan;
124 };
125
126
127 /**
128  * Information we track for a peer in the testbed.
129  */
130 struct BenchmarkPeer
131 {
132   /**
133    * Handle with testbed.
134    */
135   struct GNUNET_TESTBED_Peer *peer;
136
137   /**
138    * Unique identifier
139    */
140   int no;
141
142   /**
143    * Is this peer a measter: GNUNET_YES/GNUNET_NO
144    */
145   int master;
146
147   /**
148    *  Peer ID
149    */
150   struct GNUNET_PeerIdentity id;
151
152   /**
153    * Testbed operation to get peer information
154    */
155   struct GNUNET_TESTBED_Operation *peer_id_op;
156
157   /**
158    * Testbed operation to connect to ATS performance service
159    */
160   struct GNUNET_TESTBED_Operation *ats_perf_op;
161
162   /**
163    * Testbed operation to connect to core
164    */
165   struct GNUNET_TESTBED_Operation *comm_op;
166
167   /**
168    * ATS performance handle
169    */
170   struct GNUNET_ATS_PerformanceHandle *ats_perf_handle;
171
172   /**
173    * Masters only:
174    * Testbed connect operations to connect masters to slaves
175    */
176   struct TestbedConnectOperation *core_connect_ops;
177
178   /**
179    *  Core handle
180    */
181   struct GNUNET_CORE_Handle *ch;
182
183   /**
184    *  Core handle
185    */
186   struct GNUNET_TRANSPORT_Handle *th;
187
188   /**
189    * Masters only:
190    * Peer to set ATS preferences for
191    */
192   struct BenchmarkPeer *pref_partner;
193
194   /**
195    * Masters only
196    * Progress task
197    */
198   GNUNET_SCHEDULER_TaskIdentifier ats_task;
199
200   /**
201    * Masters only
202    * Progress task
203    */
204   double pref_value;
205
206   /**
207    * Array of partners with num_slaves entries (if master) or
208    * num_master entries (if slave)
209    */
210   struct BenchmarkPartner *partners;
211
212   /**
213    * Number of partners
214    */
215   int num_partners;
216
217   /**
218    * Number of core connections
219    */
220   int core_connections;
221
222   /**
223    * Masters only:
224    * Number of connections to slave peers
225    */
226   int core_slave_connections;
227
228   /**
229    * Total number of messages this peer has sent
230    */
231   unsigned int total_messages_sent;
232
233   /**
234    * Total number of bytes this peer has sent
235    */
236   unsigned int total_bytes_sent;
237
238   /**
239    * Total number of messages this peer has received
240    */
241   unsigned int total_messages_received;
242
243   /**
244    * Total number of bytes this peer has received
245    */
246   unsigned int total_bytes_received;
247 };
248
249
250 void
251 GNUNET_ATS_TEST_logging_now (void);
252
253 void
254 GNUNET_ATS_TEST_logging_clean_up ();
255
256 void
257 GNUNET_ATS_TEST_logging_start (struct GNUNET_TIME_Relative log_frequency,
258     char * testname, struct BenchmarkPeer *masters, int num_masters);
259
260
261 /* end of file perf_ats.h */