first batch of license fixes (boring)
[oweals/gnunet.git] / src / ats-tests / perf_ats.h
1 /*
2  This file is part of GNUnet.
3  Copyright (C) 2010-2013 GNUnet e.V.
4
5  GNUnet is free software: you can redistribute it and/or modify it
6  under the terms of the GNU General Public License as published
7  by the Free Software Foundation, either version 3 of the License,
8  or (at your 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  Affero General Public License for more details.
14  */
15 /**
16  * @file ats/perf_ats.c
17  * @brief ats benchmark: start peers and modify preferences, monitor change over time
18  * @author Christian Grothoff
19  * @author Matthias Wachs
20  */
21 #include "platform.h"
22 #include "gnunet_util_lib.h"
23 #include "gnunet_testbed_service.h"
24 #include "gnunet_ats_service.h"
25 #include "gnunet_core_service.h"
26 #include "ats-testing.h"
27
28 #define TEST_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 120)
29 #define BENCHMARK_DURATION GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10)
30 #define LOGGING_FREQUENCY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 500)
31 #define TESTNAME_PREFIX "perf_ats_"
32 #define DEFAULT_SLAVES_NUM 2
33 #define DEFAULT_MASTERS_NUM 1
34
35 #define TEST_ATS_PREFRENCE_FREQUENCY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1)
36 #define TEST_ATS_PREFRENCE_START 1.0
37 #define TEST_ATS_PREFRENCE_DELTA 1.0
38
39 #define TEST_MESSAGE_TYPE_PING 12345
40 #define TEST_MESSAGE_TYPE_PONG 12346
41 #define TEST_MESSAGE_SIZE 1000
42 #define TEST_MESSAGE_FREQUENCY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1)
43
44 /**
45  * Information about a benchmarking partner
46  */
47 struct BenchmarkPartner
48 {
49   /**
50    * The peer itself this partner belongs to
51    */
52   struct BenchmarkPeer *me;
53
54   /**
55    * The partner peer
56    */
57   struct BenchmarkPeer *dest;
58
59   /**
60    * Core transmit handles
61    */
62   struct GNUNET_CORE_TransmitHandle *cth;
63
64   /**
65    * Transport transmit handles
66    */
67   struct GNUNET_TRANSPORT_TransmitHandle *tth;
68
69   /**
70    * Timestamp to calculate communication layer delay
71    */
72   struct GNUNET_TIME_Absolute last_message_sent;
73
74   /**
75    * Accumulated RTT for all messages
76    */
77   unsigned int total_app_rtt;
78
79   /**
80    * Number of messages sent to this partner
81    */
82   unsigned int messages_sent;
83
84   /**
85    * Number of bytes sent to this partner
86    */
87   unsigned int bytes_sent;
88
89   /**
90    * Number of messages received from this partner
91    */
92   unsigned int messages_received;
93
94   /**
95    * Number of bytes received from this partner
96    */
97   unsigned int bytes_received;
98
99   /* Current ATS properties */
100
101   uint32_t ats_distance;
102
103   uint32_t ats_delay;
104
105   uint32_t bandwidth_in;
106
107   uint32_t bandwidth_out;
108
109   uint32_t ats_utilization_up;
110
111   uint32_t ats_utilization_down;
112
113   uint32_t ats_network_type;
114
115   uint32_t ats_cost_wan;
116
117   uint32_t ats_cost_lan;
118
119   uint32_t ats_cost_wlan;
120 };
121
122
123 /**
124  * Information we track for a peer in the testbed.
125  */
126 struct BenchmarkPeer
127 {
128   /**
129    * Handle with testbed.
130    */
131   struct GNUNET_TESTBED_Peer *peer;
132
133   /**
134    * Unique identifier
135    */
136   int no;
137
138   /**
139    * Is this peer a measter: GNUNET_YES/GNUNET_NO
140    */
141   int master;
142
143   /**
144    *  Peer ID
145    */
146   struct GNUNET_PeerIdentity id;
147
148   /**
149    * Testbed operation to get peer information
150    */
151   struct GNUNET_TESTBED_Operation *peer_id_op;
152
153   /**
154    * Testbed operation to connect to ATS performance service
155    */
156   struct GNUNET_TESTBED_Operation *ats_perf_op;
157
158   /**
159    * Testbed operation to connect to core
160    */
161   struct GNUNET_TESTBED_Operation *comm_op;
162
163   /**
164    * ATS performance handle
165    */
166   struct GNUNET_ATS_PerformanceHandle *ats_perf_handle;
167
168   /**
169    * Masters only:
170    * Testbed connect operations to connect masters to slaves
171    */
172   struct TestbedConnectOperation *core_connect_ops;
173
174   /**
175    *  Core handle
176    */
177   struct GNUNET_CORE_Handle *ch;
178
179   /**
180    *  Core handle
181    */
182   struct GNUNET_TRANSPORT_Handle *th;
183
184   /**
185    * Masters only:
186    * Peer to set ATS preferences for
187    */
188   struct BenchmarkPeer *pref_partner;
189
190   /**
191    * Masters only
192    * Progress task
193    */
194   struct GNUNET_SCHEDULER_Task * ats_task;
195
196   /**
197    * Masters only
198    * Progress task
199    */
200   double pref_value;
201
202   /**
203    * Array of partners with num_slaves entries (if master) or
204    * num_master entries (if slave)
205    */
206   struct BenchmarkPartner *partners;
207
208   /**
209    * Number of partners
210    */
211   int num_partners;
212
213   /**
214    * Number of core connections
215    */
216   int core_connections;
217
218   /**
219    * Masters only:
220    * Number of connections to slave peers
221    */
222   int core_slave_connections;
223
224   /**
225    * Total number of messages this peer has sent
226    */
227   unsigned int total_messages_sent;
228
229   /**
230    * Total number of bytes this peer has sent
231    */
232   unsigned int total_bytes_sent;
233
234   /**
235    * Total number of messages this peer has received
236    */
237   unsigned int total_messages_received;
238
239   /**
240    * Total number of bytes this peer has received
241    */
242   unsigned int total_bytes_received;
243 };
244
245
246 /* end of file perf_ats.h */