diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2014-01-21 15:22:09 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2014-01-21 15:22:09 +0000 |
commit | 1f3f45c08b82899a5350633dc6f1030216a1e150 (patch) | |
tree | 1536f4ed581eed1139eb8a81663038c548dea038 /src/ats-tests/ats-testing.h | |
parent | 42d205bed7f300dbc9fa4e97bb88b35321552a89 (diff) | |
download | gnunet-1f3f45c08b82899a5350633dc6f1030216a1e150.tar.gz gnunet-1f3f45c08b82899a5350633dc6f1030216a1e150.zip |
initial preliminary commit for ats testing lib and simulator tool
Diffstat (limited to 'src/ats-tests/ats-testing.h')
-rw-r--r-- | src/ats-tests/ats-testing.h | 402 |
1 files changed, 402 insertions, 0 deletions
diff --git a/src/ats-tests/ats-testing.h b/src/ats-tests/ats-testing.h new file mode 100644 index 000000000..37fc94da7 --- /dev/null +++ b/src/ats-tests/ats-testing.h | |||
@@ -0,0 +1,402 @@ | |||
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 | /** | ||
50 | * Overall state of the performance benchmark | ||
51 | */ | ||
52 | struct BenchmarkState | ||
53 | { | ||
54 | /** | ||
55 | * Are we connected to ATS service of all peers: GNUNET_YES/NO | ||
56 | */ | ||
57 | int connected_ATS_service; | ||
58 | |||
59 | /** | ||
60 | * Are we connected to CORE service of all peers: GNUNET_YES/NO | ||
61 | */ | ||
62 | int connected_COMM_service; | ||
63 | |||
64 | /** | ||
65 | * Are we connected to all peers: GNUNET_YES/NO | ||
66 | */ | ||
67 | int connected_PEERS; | ||
68 | |||
69 | /** | ||
70 | * Are we connected to all slave peers on CORE level: GNUNET_YES/NO | ||
71 | */ | ||
72 | int connected_CORE; | ||
73 | |||
74 | /** | ||
75 | * Are we connected to CORE service of all peers: GNUNET_YES/NO | ||
76 | */ | ||
77 | int benchmarking; | ||
78 | }; | ||
79 | |||
80 | |||
81 | /** | ||
82 | * Information about a benchmarking partner | ||
83 | */ | ||
84 | struct BenchmarkPartner | ||
85 | { | ||
86 | /** | ||
87 | * The peer itself this partner belongs to | ||
88 | */ | ||
89 | struct BenchmarkPeer *me; | ||
90 | |||
91 | /** | ||
92 | * The partner peer | ||
93 | */ | ||
94 | struct BenchmarkPeer *dest; | ||
95 | |||
96 | /** | ||
97 | * Core transmit handles | ||
98 | */ | ||
99 | struct GNUNET_CORE_TransmitHandle *cth; | ||
100 | |||
101 | /** | ||
102 | * Transport transmit handles | ||
103 | */ | ||
104 | struct GNUNET_TRANSPORT_TransmitHandle *tth; | ||
105 | |||
106 | /** | ||
107 | * Timestamp to calculate communication layer delay | ||
108 | */ | ||
109 | struct GNUNET_TIME_Absolute last_message_sent; | ||
110 | |||
111 | /** | ||
112 | * Accumulated RTT for all messages | ||
113 | */ | ||
114 | unsigned int total_app_rtt; | ||
115 | |||
116 | /** | ||
117 | * Number of messages sent to this partner | ||
118 | */ | ||
119 | unsigned int messages_sent; | ||
120 | |||
121 | /** | ||
122 | * Number of bytes sent to this partner | ||
123 | */ | ||
124 | unsigned int bytes_sent; | ||
125 | |||
126 | /** | ||
127 | * Number of messages received from this partner | ||
128 | */ | ||
129 | unsigned int messages_received; | ||
130 | |||
131 | /** | ||
132 | * Number of bytes received from this partner | ||
133 | */ | ||
134 | unsigned int bytes_received; | ||
135 | |||
136 | /* Current ATS properties */ | ||
137 | |||
138 | uint32_t ats_distance; | ||
139 | |||
140 | uint32_t ats_delay; | ||
141 | |||
142 | uint32_t bandwidth_in; | ||
143 | |||
144 | uint32_t bandwidth_out; | ||
145 | |||
146 | uint32_t ats_utilization_up; | ||
147 | |||
148 | uint32_t ats_utilization_down; | ||
149 | |||
150 | uint32_t ats_network_type; | ||
151 | |||
152 | uint32_t ats_cost_wan; | ||
153 | |||
154 | uint32_t ats_cost_lan; | ||
155 | |||
156 | uint32_t ats_cost_wlan; | ||
157 | }; | ||
158 | |||
159 | |||
160 | /** | ||
161 | * Information we track for a peer in the testbed. | ||
162 | */ | ||
163 | struct BenchmarkPeer | ||
164 | { | ||
165 | /** | ||
166 | * Handle with testbed. | ||
167 | */ | ||
168 | struct GNUNET_TESTBED_Peer *peer; | ||
169 | |||
170 | /** | ||
171 | * Unique identifier | ||
172 | */ | ||
173 | int no; | ||
174 | |||
175 | /** | ||
176 | * Is this peer a measter: GNUNET_YES/GNUNET_NO | ||
177 | */ | ||
178 | int master; | ||
179 | |||
180 | /** | ||
181 | * Peer ID | ||
182 | */ | ||
183 | struct GNUNET_PeerIdentity id; | ||
184 | |||
185 | /** | ||
186 | * Testbed operation to get peer information | ||
187 | */ | ||
188 | struct GNUNET_TESTBED_Operation *peer_id_op; | ||
189 | |||
190 | /** | ||
191 | * Testbed operation to connect to ATS performance service | ||
192 | */ | ||
193 | struct GNUNET_TESTBED_Operation *ats_perf_op; | ||
194 | |||
195 | /** | ||
196 | * Testbed operation to connect to core | ||
197 | */ | ||
198 | struct GNUNET_TESTBED_Operation *comm_op; | ||
199 | |||
200 | /** | ||
201 | * ATS performance handle | ||
202 | */ | ||
203 | struct GNUNET_ATS_PerformanceHandle *ats_perf_handle; | ||
204 | |||
205 | /** | ||
206 | * Masters only: | ||
207 | * Testbed connect operations to connect masters to slaves | ||
208 | */ | ||
209 | struct TestbedConnectOperation *core_connect_ops; | ||
210 | |||
211 | /** | ||
212 | * Core handle | ||
213 | */ | ||
214 | struct GNUNET_CORE_Handle *ch; | ||
215 | |||
216 | /** | ||
217 | * Core handle | ||
218 | */ | ||
219 | struct GNUNET_TRANSPORT_Handle *th; | ||
220 | |||
221 | /** | ||
222 | * Masters only: | ||
223 | * Peer to set ATS preferences for | ||
224 | */ | ||
225 | struct BenchmarkPeer *pref_partner; | ||
226 | |||
227 | /** | ||
228 | * Masters only | ||
229 | * Progress task | ||
230 | */ | ||
231 | GNUNET_SCHEDULER_TaskIdentifier ats_task; | ||
232 | |||
233 | /** | ||
234 | * Masters only | ||
235 | * Progress task | ||
236 | */ | ||
237 | double pref_value; | ||
238 | |||
239 | /** | ||
240 | * Array of partners with num_slaves entries (if master) or | ||
241 | * num_master entries (if slave) | ||
242 | */ | ||
243 | struct BenchmarkPartner *partners; | ||
244 | |||
245 | /** | ||
246 | * Number of partners | ||
247 | */ | ||
248 | int num_partners; | ||
249 | |||
250 | /** | ||
251 | * Number of core connections | ||
252 | */ | ||
253 | int core_connections; | ||
254 | |||
255 | /** | ||
256 | * Masters only: | ||
257 | * Number of connections to slave peers | ||
258 | */ | ||
259 | int core_slave_connections; | ||
260 | |||
261 | /** | ||
262 | * Total number of messages this peer has sent | ||
263 | */ | ||
264 | unsigned int total_messages_sent; | ||
265 | |||
266 | /** | ||
267 | * Total number of bytes this peer has sent | ||
268 | */ | ||
269 | unsigned int total_bytes_sent; | ||
270 | |||
271 | /** | ||
272 | * Total number of messages this peer has received | ||
273 | */ | ||
274 | unsigned int total_messages_received; | ||
275 | |||
276 | /** | ||
277 | * Total number of bytes this peer has received | ||
278 | */ | ||
279 | unsigned int total_bytes_received; | ||
280 | }; | ||
281 | |||
282 | /** | ||
283 | * Connect peers with testbed | ||
284 | */ | ||
285 | struct TestbedConnectOperation | ||
286 | { | ||
287 | /** | ||
288 | * The benchmarking master initiating this connection | ||
289 | */ | ||
290 | struct BenchmarkPeer *master; | ||
291 | |||
292 | /** | ||
293 | * The benchmarking slave to connect to | ||
294 | */ | ||
295 | struct BenchmarkPeer *slave; | ||
296 | |||
297 | /** | ||
298 | * Testbed operation to connect peers | ||
299 | */ | ||
300 | struct GNUNET_TESTBED_Operation *connect_op; | ||
301 | }; | ||
302 | |||
303 | |||
304 | struct GNUNET_ATS_TEST_Topology | ||
305 | { | ||
306 | /** | ||
307 | * Shutdown task | ||
308 | */ | ||
309 | GNUNET_SCHEDULER_TaskIdentifier shutdown_task; | ||
310 | |||
311 | /** | ||
312 | * Progress task | ||
313 | */ | ||
314 | GNUNET_SCHEDULER_TaskIdentifier progress_task; | ||
315 | |||
316 | /** | ||
317 | * Test result | ||
318 | */ | ||
319 | int result; | ||
320 | |||
321 | /** | ||
322 | * Test result logging | ||
323 | */ | ||
324 | int logging; | ||
325 | |||
326 | /**Test core (GNUNET_YES) or transport (GNUNET_NO) | ||
327 | */ | ||
328 | int test_core; | ||
329 | |||
330 | /** | ||
331 | * Solver string | ||
332 | */ | ||
333 | char *solver; | ||
334 | |||
335 | /** | ||
336 | * Preference string | ||
337 | */ | ||
338 | char *testname; | ||
339 | |||
340 | /** | ||
341 | * Preference string | ||
342 | */ | ||
343 | char *pref_str; | ||
344 | |||
345 | /** | ||
346 | * ATS preference value | ||
347 | */ | ||
348 | int pref_val; | ||
349 | |||
350 | /** | ||
351 | * Number master peers | ||
352 | */ | ||
353 | unsigned int num_masters; | ||
354 | |||
355 | /** | ||
356 | * Array of master peers | ||
357 | */ | ||
358 | struct BenchmarkPeer *mps; | ||
359 | |||
360 | /** | ||
361 | * Number slave peers | ||
362 | */ | ||
363 | unsigned int num_slaves; | ||
364 | |||
365 | /** | ||
366 | * Array of slave peers | ||
367 | */ | ||
368 | struct BenchmarkPeer *sps; | ||
369 | |||
370 | /** | ||
371 | * Benchmark duration | ||
372 | */ | ||
373 | struct GNUNET_TIME_Relative perf_duration; | ||
374 | |||
375 | /** | ||
376 | * Logging frequency | ||
377 | */ | ||
378 | struct GNUNET_TIME_Relative log_frequency; | ||
379 | |||
380 | /** | ||
381 | * Benchmark state | ||
382 | */ | ||
383 | struct BenchmarkState state; | ||
384 | |||
385 | struct GNUNET_CORE_MessageHandler *handlers; | ||
386 | |||
387 | GNUNET_TRANSPORT_ReceiveCallback transport_recv_cb; | ||
388 | |||
389 | }; | ||
390 | |||
391 | |||
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); | ||
398 | |||
399 | void | ||
400 | GNUNET_ATS_TEST_destroy_topology (struct GNUNET_ATS_TEST_Topology *top); | ||
401 | |||
402 | /* end of file perf_ats.c */ | ||