measuring application layer delay
[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, 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
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 delay for all messages
80    */
81   unsigned int total_app_delay;
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
104
105
106 };
107
108
109 /**
110  * Information we track for a peer in the testbed.
111  */
112 struct BenchmarkPeer
113 {
114   /**
115    * Handle with testbed.
116    */
117   struct GNUNET_TESTBED_Peer *peer;
118
119   /**
120    * Unique identifier
121    */
122   int no;
123
124   /**
125    * Is this peer a measter: GNUNET_YES/GNUNET_NO
126    */
127   int master;
128
129   /**
130    *  Peer ID
131    */
132   struct GNUNET_PeerIdentity id;
133
134   /**
135    * Testbed operation to get peer information
136    */
137   struct GNUNET_TESTBED_Operation *peer_id_op;
138
139   /**
140    * Testbed operation to connect to ATS performance service
141    */
142   struct GNUNET_TESTBED_Operation *ats_perf_op;
143
144   /**
145    * Testbed operation to connect to core
146    */
147   struct GNUNET_TESTBED_Operation *comm_op;
148
149   /**
150    * ATS performance handle
151    */
152   struct GNUNET_ATS_PerformanceHandle *ats_perf_handle;
153
154   /**
155    * Masters only:
156    * Testbed connect operations to connect masters to slaves
157    */
158   struct TestbedConnectOperation *core_connect_ops;
159
160   /**
161    *  Core handle
162    */
163   struct GNUNET_CORE_Handle *ch;
164
165   /**
166    *  Core handle
167    */
168   struct GNUNET_TRANSPORT_Handle *th;
169
170   /**
171    * Masters only:
172    * Peer to set ATS preferences for
173    */
174   struct BenchmarkPeer *pref_partner;
175
176   /**
177    * Masters only
178    * Progress task
179    */
180   GNUNET_SCHEDULER_TaskIdentifier ats_task;
181
182   /**
183    * Masters only
184    * Progress task
185    */
186   double pref_value;
187
188   /**
189    * Array of partners with num_slaves entries (if master) or
190    * num_master entries (if slave)
191    */
192   struct BenchmarkPartner *partners;
193
194   /**
195    * Number of partners
196    */
197   int num_partners;
198
199   /**
200    * Number of core connections
201    */
202   int core_connections;
203
204   /**
205    * Masters only:
206    * Number of connections to slave peers
207    */
208   int core_slave_connections;
209
210   /**
211    * Total number of messages this peer has sent
212    */
213   unsigned int total_messages_sent;
214
215   /**
216    * Total number of bytes this peer has sent
217    */
218   unsigned int total_bytes_sent;
219
220   /**
221    * Total number of messages this peer has received
222    */
223   unsigned int total_messages_received;
224
225   /**
226    * Total number of bytes this peer has received
227    */
228   unsigned int total_bytes_received;
229 };
230
231
232 void
233 perf_logging_stop ();
234
235 void
236 perf_logging_start (struct GNUNET_TIME_Relative log_frequency,
237     char * testname, struct BenchmarkPeer *masters, int num_masters);
238
239
240 /* end of file perf_ats.h */