diff options
Diffstat (limited to 'src/ats-tests/gnunet-ats-sim.c')
-rw-r--r-- | src/ats-tests/gnunet-ats-sim.c | 427 |
1 files changed, 214 insertions, 213 deletions
diff --git a/src/ats-tests/gnunet-ats-sim.c b/src/ats-tests/gnunet-ats-sim.c index af0eff534..d6168d388 100644 --- a/src/ats-tests/gnunet-ats-sim.c +++ b/src/ats-tests/gnunet-ats-sim.c | |||
@@ -1,19 +1,19 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2010-2013 GNUnet e.V. | 3 | Copyright (C) 2010-2013 GNUnet e.V. |
4 | 4 | ||
5 | GNUnet is free software: you can redistribute it and/or modify it | 5 | GNUnet is free software: you can redistribute it and/or modify it |
6 | under the terms of the GNU Affero General Public License as published | 6 | under the terms of the GNU Affero General Public License as published |
7 | by the Free Software Foundation, either version 3 of the License, | 7 | by the Free Software Foundation, either version 3 of the License, |
8 | or (at your option) any later version. | 8 | or (at your option) any later version. |
9 | 9 | ||
10 | GNUnet is distributed in the hope that it will be useful, but | 10 | GNUnet is distributed in the hope that it will be useful, but |
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Affero General Public License for more details. | 13 | Affero General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Affero General Public License | 15 | You should have received a copy of the GNU Affero General Public License |
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | 17 | ||
18 | SPDX-License-Identifier: AGPL3.0-or-later | 18 | SPDX-License-Identifier: AGPL3.0-or-later |
19 | */ | 19 | */ |
@@ -32,7 +32,7 @@ | |||
32 | #include "gnunet_core_service.h" | 32 | #include "gnunet_core_service.h" |
33 | #include "ats-testing.h" | 33 | #include "ats-testing.h" |
34 | 34 | ||
35 | #define TEST_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10) | 35 | #define TEST_TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 10) |
36 | 36 | ||
37 | static struct BenchmarkPeer *masters_p; | 37 | static struct BenchmarkPeer *masters_p; |
38 | static struct BenchmarkPeer *slaves_p; | 38 | static struct BenchmarkPeer *slaves_p; |
@@ -65,7 +65,7 @@ static struct LoggingHandle *l; | |||
65 | 65 | ||
66 | 66 | ||
67 | static void | 67 | static void |
68 | evaluate (struct GNUNET_TIME_Relative duration_total) | 68 | evaluate(struct GNUNET_TIME_Relative duration_total) |
69 | { | 69 | { |
70 | int c_m; | 70 | int c_m; |
71 | int c_s; | 71 | int c_s; |
@@ -84,312 +84,313 @@ evaluate (struct GNUNET_TIME_Relative duration_total) | |||
84 | if (0 == duration) | 84 | if (0 == duration) |
85 | duration = 1; | 85 | duration = 1; |
86 | for (c_m = 0; c_m < e->num_masters; c_m++) | 86 | for (c_m = 0; c_m < e->num_masters; c_m++) |
87 | { | ||
88 | mp = &masters_p[c_m]; | ||
89 | fprintf (stderr, | ||
90 | _("Master [%u]: sent: %u KiB in %u sec. = %u KiB/s, received: %u KiB in %u sec. = %u KiB/s\n"), | ||
91 | mp->no, mp->total_bytes_sent / 1024, | ||
92 | duration, | ||
93 | (mp->total_bytes_sent / 1024) / duration, | ||
94 | mp->total_bytes_received / 1024, | ||
95 | duration, | ||
96 | (mp->total_bytes_received / 1024) / duration); | ||
97 | |||
98 | for (c_s = 0; c_s < e->num_slaves; c_s++) | ||
99 | { | 87 | { |
100 | p = &mp->partners[c_s]; | 88 | mp = &masters_p[c_m]; |
101 | 89 | fprintf(stderr, | |
102 | b_sent_sec = 0; | 90 | _("Master [%u]: sent: %u KiB in %u sec. = %u KiB/s, received: %u KiB in %u sec. = %u KiB/s\n"), |
103 | b_recv_sec = 0; | 91 | mp->no, mp->total_bytes_sent / 1024, |
104 | kb_sent_percent = 0.0; | 92 | duration, |
105 | kb_recv_percent = 0.0; | 93 | (mp->total_bytes_sent / 1024) / duration, |
106 | rtt = 0; | 94 | mp->total_bytes_received / 1024, |
107 | 95 | duration, | |
108 | if (duration > 0) | 96 | (mp->total_bytes_received / 1024) / duration); |
109 | { | 97 | |
110 | b_sent_sec = p->bytes_sent / duration; | 98 | for (c_s = 0; c_s < e->num_slaves; c_s++) |
111 | b_recv_sec = p->bytes_received / duration; | 99 | { |
112 | } | 100 | p = &mp->partners[c_s]; |
113 | 101 | ||
114 | if (mp->total_bytes_sent > 0) | 102 | b_sent_sec = 0; |
115 | kb_sent_percent = ((double) p->bytes_sent * 100) / mp->total_bytes_sent; | 103 | b_recv_sec = 0; |
116 | if (mp->total_bytes_received > 0) | 104 | kb_sent_percent = 0.0; |
117 | kb_recv_percent = ((double) p->bytes_received * 100) / mp->total_bytes_received; | 105 | kb_recv_percent = 0.0; |
118 | if (1000 * p->messages_sent > 0) | 106 | rtt = 0; |
119 | rtt = p->total_app_rtt / (1000 * p->messages_sent); | 107 | |
120 | fprintf (stderr, | 108 | if (duration > 0) |
121 | "%c Master [%u] -> Slave [%u]: sent %u Bips (%.2f %%), received %u Bips (%.2f %%)\n", | 109 | { |
122 | (mp->pref_partner == p->dest) ? '*' : ' ', | 110 | b_sent_sec = p->bytes_sent / duration; |
123 | mp->no, p->dest->no, | 111 | b_recv_sec = p->bytes_received / duration; |
124 | b_sent_sec, kb_sent_percent, | 112 | } |
113 | |||
114 | if (mp->total_bytes_sent > 0) | ||
115 | kb_sent_percent = ((double)p->bytes_sent * 100) / mp->total_bytes_sent; | ||
116 | if (mp->total_bytes_received > 0) | ||
117 | kb_recv_percent = ((double)p->bytes_received * 100) / mp->total_bytes_received; | ||
118 | if (1000 * p->messages_sent > 0) | ||
119 | rtt = p->total_app_rtt / (1000 * p->messages_sent); | ||
120 | fprintf(stderr, | ||
121 | "%c Master [%u] -> Slave [%u]: sent %u Bips (%.2f %%), received %u Bips (%.2f %%)\n", | ||
122 | (mp->pref_partner == p->dest) ? '*' : ' ', | ||
123 | mp->no, p->dest->no, | ||
124 | b_sent_sec, kb_sent_percent, | ||
125 | b_recv_sec, kb_recv_percent); | 125 | b_recv_sec, kb_recv_percent); |
126 | fprintf (stderr, | 126 | fprintf(stderr, |
127 | "%c Master [%u] -> Slave [%u]: Average application layer RTT: %u ms\n", | 127 | "%c Master [%u] -> Slave [%u]: Average application layer RTT: %u ms\n", |
128 | (mp->pref_partner == p->dest) ? '*' : ' ', | 128 | (mp->pref_partner == p->dest) ? '*' : ' ', |
129 | mp->no, p->dest->no, rtt); | 129 | mp->no, p->dest->no, rtt); |
130 | } | ||
130 | } | 131 | } |
131 | } | ||
132 | } | 132 | } |
133 | 133 | ||
134 | 134 | ||
135 | static void | 135 | static void |
136 | do_shutdown (void *cls) | 136 | do_shutdown(void *cls) |
137 | { | 137 | { |
138 | fprintf (stderr, "Shutdown\n"); | 138 | fprintf(stderr, "Shutdown\n"); |
139 | if (NULL != timeout_task) | 139 | if (NULL != timeout_task) |
140 | { | 140 | { |
141 | GNUNET_SCHEDULER_cancel (timeout_task); | 141 | GNUNET_SCHEDULER_cancel(timeout_task); |
142 | timeout_task = NULL; | 142 | timeout_task = NULL; |
143 | } | 143 | } |
144 | if (NULL != l) | 144 | if (NULL != l) |
145 | { | 145 | { |
146 | GNUNET_ATS_TEST_logging_stop (l); | 146 | GNUNET_ATS_TEST_logging_stop(l); |
147 | GNUNET_ATS_TEST_logging_clean_up (l); | 147 | GNUNET_ATS_TEST_logging_clean_up(l); |
148 | l = NULL; | 148 | l = NULL; |
149 | } | 149 | } |
150 | 150 | ||
151 | /* Stop traffic generation */ | 151 | /* Stop traffic generation */ |
152 | GNUNET_ATS_TEST_generate_traffic_stop_all(); | 152 | GNUNET_ATS_TEST_generate_traffic_stop_all(); |
153 | 153 | ||
154 | /* Stop all preference generations */ | 154 | /* Stop all preference generations */ |
155 | GNUNET_ATS_TEST_generate_preferences_stop_all (); | 155 | GNUNET_ATS_TEST_generate_preferences_stop_all(); |
156 | 156 | ||
157 | if (NULL != e) | 157 | if (NULL != e) |
158 | { | 158 | { |
159 | GNUNET_ATS_TEST_experimentation_stop (e); | 159 | GNUNET_ATS_TEST_experimentation_stop(e); |
160 | e = NULL; | 160 | e = NULL; |
161 | } | 161 | } |
162 | GNUNET_ATS_TEST_shutdown_topology (); | 162 | GNUNET_ATS_TEST_shutdown_topology(); |
163 | } | 163 | } |
164 | 164 | ||
165 | 165 | ||
166 | static void | 166 | static void |
167 | do_timeout (void *cls) | 167 | do_timeout(void *cls) |
168 | { | 168 | { |
169 | timeout_task = NULL; | 169 | timeout_task = NULL; |
170 | GNUNET_SCHEDULER_shutdown (); | 170 | GNUNET_SCHEDULER_shutdown(); |
171 | } | 171 | } |
172 | 172 | ||
173 | 173 | ||
174 | static void | 174 | static void |
175 | log_request__cb (void *cls, | 175 | log_request__cb(void *cls, |
176 | const struct GNUNET_HELLO_Address *address, | 176 | const struct GNUNET_HELLO_Address *address, |
177 | int address_active, | 177 | int address_active, |
178 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, | 178 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, |
179 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, | 179 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, |
180 | const struct GNUNET_ATS_Properties *ats) | 180 | const struct GNUNET_ATS_Properties *ats) |
181 | { | 181 | { |
182 | if (NULL != l) | 182 | if (NULL != l) |
183 | { | 183 | { |
184 | //GNUNET_break (0); | 184 | //GNUNET_break (0); |
185 | //GNUNET_ATS_TEST_logging_now (l); | 185 | //GNUNET_ATS_TEST_logging_now (l); |
186 | } | 186 | } |
187 | } | 187 | } |
188 | 188 | ||
189 | 189 | ||
190 | static void | 190 | static void |
191 | experiment_done_cb (struct Experiment *e, | 191 | experiment_done_cb(struct Experiment *e, |
192 | struct GNUNET_TIME_Relative duration, | 192 | struct GNUNET_TIME_Relative duration, |
193 | int success) | 193 | int success) |
194 | { | 194 | { |
195 | if (GNUNET_OK == success) | 195 | if (GNUNET_OK == success) |
196 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 196 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, |
197 | "Experiment done successful in %s\n", | 197 | "Experiment done successful in %s\n", |
198 | GNUNET_STRINGS_relative_time_to_string (duration, | 198 | GNUNET_STRINGS_relative_time_to_string(duration, |
199 | GNUNET_YES)); | 199 | GNUNET_YES)); |
200 | else | 200 | else |
201 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Experiment failed \n"); | 201 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Experiment failed \n"); |
202 | 202 | ||
203 | /* Stop logging */ | 203 | /* Stop logging */ |
204 | GNUNET_ATS_TEST_logging_stop (l); | 204 | GNUNET_ATS_TEST_logging_stop(l); |
205 | 205 | ||
206 | /* Stop traffic generation */ | 206 | /* Stop traffic generation */ |
207 | GNUNET_ATS_TEST_generate_traffic_stop_all(); | 207 | GNUNET_ATS_TEST_generate_traffic_stop_all(); |
208 | 208 | ||
209 | /* Stop all preference generations */ | 209 | /* Stop all preference generations */ |
210 | GNUNET_ATS_TEST_generate_preferences_stop_all (); | 210 | GNUNET_ATS_TEST_generate_preferences_stop_all(); |
211 | 211 | ||
212 | evaluate (duration); | 212 | evaluate(duration); |
213 | if (opt_log) | 213 | if (opt_log) |
214 | GNUNET_ATS_TEST_logging_write_to_file(l, opt_exp_file, opt_plot); | 214 | GNUNET_ATS_TEST_logging_write_to_file(l, opt_exp_file, opt_plot); |
215 | GNUNET_SCHEDULER_shutdown (); | 215 | GNUNET_SCHEDULER_shutdown(); |
216 | } | 216 | } |
217 | 217 | ||
218 | 218 | ||
219 | static void | 219 | static void |
220 | episode_done_cb (struct Episode *ep) | 220 | episode_done_cb(struct Episode *ep) |
221 | { | 221 | { |
222 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 222 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, |
223 | "Episode %u done\n", | 223 | "Episode %u done\n", |
224 | ep->id); | 224 | ep->id); |
225 | } | 225 | } |
226 | 226 | ||
227 | 227 | ||
228 | static void | 228 | static void |
229 | topology_setup_done (void *cls, | 229 | topology_setup_done(void *cls, |
230 | struct BenchmarkPeer *masters, | 230 | struct BenchmarkPeer *masters, |
231 | struct BenchmarkPeer *slaves) | 231 | struct BenchmarkPeer *slaves) |
232 | { | 232 | { |
233 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 233 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, |
234 | "Topology setup complete!\n"); | 234 | "Topology setup complete!\n"); |
235 | 235 | ||
236 | masters_p = masters; | 236 | masters_p = masters; |
237 | slaves_p = slaves; | 237 | slaves_p = slaves; |
238 | 238 | ||
239 | l = GNUNET_ATS_TEST_logging_start (e->log_freq, | 239 | l = GNUNET_ATS_TEST_logging_start(e->log_freq, |
240 | e->name, | 240 | e->name, |
241 | masters_p, | 241 | masters_p, |
242 | e->num_masters, e->num_slaves, | 242 | e->num_masters, e->num_slaves, |
243 | opt_verbose); | 243 | opt_verbose); |
244 | GNUNET_ATS_TEST_experimentation_run (e, | 244 | GNUNET_ATS_TEST_experimentation_run(e, |
245 | &episode_done_cb, | 245 | &episode_done_cb, |
246 | &experiment_done_cb); | 246 | &experiment_done_cb); |
247 | /* | 247 | /* |
248 | GNUNET_ATS_TEST_generate_preferences_start(&masters[0],&masters[0].partners[0], | 248 | GNUNET_ATS_TEST_generate_preferences_start(&masters[0],&masters[0].partners[0], |
249 | GNUNET_ATS_TEST_TG_CONSTANT, 1, 1, GNUNET_TIME_UNIT_SECONDS, | 249 | GNUNET_ATS_TEST_TG_CONSTANT, 1, 1, GNUNET_TIME_UNIT_SECONDS, |
250 | GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 250), | 250 | GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 250), |
251 | GNUNET_ATS_PREFERENCE_BANDWIDTH); | 251 | GNUNET_ATS_PREFERENCE_BANDWIDTH); |
252 | */ | 252 | */ |
253 | /* | 253 | /* |
254 | GNUNET_ATS_TEST_generate_preferences_start(&masters[0],&masters[0].partners[0], | 254 | GNUNET_ATS_TEST_generate_preferences_start(&masters[0],&masters[0].partners[0], |
255 | GNUNET_ATS_TEST_TG_LINEAR, 1, 50, | 255 | GNUNET_ATS_TEST_TG_LINEAR, 1, 50, |
256 | GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 2), | 256 | GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 2), |
257 | GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 250), | 257 | GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 250), |
258 | GNUNET_ATS_PREFERENCE_BANDWIDTH); | 258 | GNUNET_ATS_PREFERENCE_BANDWIDTH); |
259 | */ | 259 | */ |
260 | /* | 260 | /* |
261 | GNUNET_ATS_TEST_generate_preferences_start(&masters[0],&masters[0].partners[0], | 261 | GNUNET_ATS_TEST_generate_preferences_start(&masters[0],&masters[0].partners[0], |
262 | GNUNET_ATS_TEST_TG_RANDOM, 1, 50, | 262 | GNUNET_ATS_TEST_TG_RANDOM, 1, 50, |
263 | GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 2), | 263 | GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 2), |
264 | GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 250), | 264 | GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 250), |
265 | GNUNET_ATS_PREFERENCE_BANDWIDTH); | 265 | GNUNET_ATS_PREFERENCE_BANDWIDTH); |
266 | */ | 266 | */ |
267 | /* | 267 | /* |
268 | GNUNET_ATS_TEST_generate_preferences_start(&masters[0],&masters[0].partners[0], | 268 | GNUNET_ATS_TEST_generate_preferences_start(&masters[0],&masters[0].partners[0], |
269 | GNUNET_ATS_TEST_TG_SINUS, 10, 5, | 269 | GNUNET_ATS_TEST_TG_SINUS, 10, 5, |
270 | GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 5), | 270 | GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 5), |
271 | GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 250), | 271 | GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 250), |
272 | GNUNET_ATS_PREFERENCE_BANDWIDTH); | 272 | GNUNET_ATS_PREFERENCE_BANDWIDTH); |
273 | */ | 273 | */ |
274 | #if 0 | 274 | #if 0 |
275 | int c_m; | 275 | int c_m; |
276 | int c_s; | 276 | int c_s; |
277 | for (c_m = 0; c_m < e->num_masters; c_m++) | 277 | for (c_m = 0; c_m < e->num_masters; c_m++) |
278 | { | 278 | { |
279 | for (c_s = 0; c_s < e->num_slaves; c_s++) | 279 | for (c_s = 0; c_s < e->num_slaves; c_s++) |
280 | { | 280 | { |
281 | /* Generate maximum traffic to all peers */ | 281 | /* Generate maximum traffic to all peers */ |
282 | /* Example: Generate traffic with constant 10,000 Bytes/s */ | 282 | /* Example: Generate traffic with constant 10,000 Bytes/s */ |
283 | GNUNET_ATS_TEST_generate_traffic_start (&masters[c_m], | 283 | GNUNET_ATS_TEST_generate_traffic_start(&masters[c_m], |
284 | &masters[c_m].partners[c_s], | 284 | &masters[c_m].partners[c_s], |
285 | GNUNET_ATS_TEST_TG_CONSTANT, | 285 | GNUNET_ATS_TEST_TG_CONSTANT, |
286 | 10000, | 286 | 10000, |
287 | GNUNET_TIME_UNIT_FOREVER_REL); | 287 | GNUNET_TIME_UNIT_FOREVER_REL); |
288 | /* Example: Generate traffic with an increasing rate from 1000 to 2000 | 288 | /* Example: Generate traffic with an increasing rate from 1000 to 2000 |
289 | * Bytes/s with in a minute */ | 289 | * Bytes/s with in a minute */ |
290 | GNUNET_ATS_TEST_generate_traffic_start (&masters[c_m], | 290 | GNUNET_ATS_TEST_generate_traffic_start(&masters[c_m], |
291 | &masters[c_m].partners[c_s], | 291 | &masters[c_m].partners[c_s], |
292 | GNUNET_ATS_TEST_TG_LINEAR, | 292 | GNUNET_ATS_TEST_TG_LINEAR, |
293 | 1000, | 293 | 1000, |
294 | 2000, | 294 | 2000, |
295 | GNUNET_TIME_UNIT_MINUTES, | 295 | GNUNET_TIME_UNIT_MINUTES, |
296 | GNUNET_TIME_UNIT_FOREVER_REL); | 296 | GNUNET_TIME_UNIT_FOREVER_REL); |
297 | /* Example: Generate traffic with a random rate between 1000 to 2000 | 297 | /* Example: Generate traffic with a random rate between 1000 to 2000 |
298 | * Bytes/s */ | 298 | * Bytes/s */ |
299 | GNUNET_ATS_TEST_generate_traffic_start (&masters[c_m], | 299 | GNUNET_ATS_TEST_generate_traffic_start(&masters[c_m], |
300 | &masters[c_m].partners[c_s], | 300 | &masters[c_m].partners[c_s], |
301 | GNUNET_ATS_TEST_TG_RANDOM, | 301 | GNUNET_ATS_TEST_TG_RANDOM, |
302 | 1000, | 302 | 1000, |
303 | 2000, | 303 | 2000, |
304 | GNUNET_TIME_UNIT_FOREVER_REL, | 304 | GNUNET_TIME_UNIT_FOREVER_REL, |
305 | GNUNET_TIME_UNIT_FOREVER_REL); | 305 | GNUNET_TIME_UNIT_FOREVER_REL); |
306 | /* Example: Generate traffic with a sinus form, a base rate of | 306 | /* Example: Generate traffic with a sinus form, a base rate of |
307 | * 1000 Bytes/s, an amplitude of (max-base), and a period of 1 minute */ | 307 | * 1000 Bytes/s, an amplitude of (max-base), and a period of 1 minute */ |
308 | GNUNET_ATS_TEST_generate_traffic_start (&masters[c_m], | 308 | GNUNET_ATS_TEST_generate_traffic_start(&masters[c_m], |
309 | &masters[c_m].partners[c_s], | 309 | &masters[c_m].partners[c_s], |
310 | GNUNET_ATS_TEST_TG_SINUS, | 310 | GNUNET_ATS_TEST_TG_SINUS, |
311 | 1000, | 311 | 1000, |
312 | 2000, | 312 | 2000, |
313 | GNUNET_TIME_UNIT_MINUTES, | 313 | GNUNET_TIME_UNIT_MINUTES, |
314 | GNUNET_TIME_UNIT_FOREVER_REL); | 314 | GNUNET_TIME_UNIT_FOREVER_REL); |
315 | } | 315 | } |
316 | } | 316 | } |
317 | #endif | 317 | #endif |
318 | 318 | ||
319 | timeout_task | 319 | timeout_task |
320 | = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_add (GNUNET_TIME_UNIT_MINUTES, | 320 | = GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_add(GNUNET_TIME_UNIT_MINUTES, |
321 | e->max_duration), | 321 | e->max_duration), |
322 | &do_timeout, | 322 | &do_timeout, |
323 | NULL); | 323 | NULL); |
324 | GNUNET_SCHEDULER_add_shutdown (&do_shutdown, NULL); | 324 | GNUNET_SCHEDULER_add_shutdown(&do_shutdown, NULL); |
325 | } | 325 | } |
326 | 326 | ||
327 | 327 | ||
328 | static void | 328 | static void |
329 | parse_args (int argc, char *argv[]) | 329 | parse_args(int argc, char *argv[]) |
330 | { | 330 | { |
331 | int c; | 331 | int c; |
332 | |||
332 | opt_exp_file = NULL; | 333 | opt_exp_file = NULL; |
333 | opt_log = GNUNET_NO; | 334 | opt_log = GNUNET_NO; |
334 | opt_plot = GNUNET_NO; | 335 | opt_plot = GNUNET_NO; |
335 | 336 | ||
336 | for (c = 0; c < argc; c++) | 337 | for (c = 0; c < argc; c++) |
337 | { | ||
338 | if ((c < (argc - 1)) && (0 == strcmp (argv[c], "-e"))) | ||
339 | { | ||
340 | GNUNET_free_non_null (opt_exp_file); | ||
341 | opt_exp_file = GNUNET_strdup ( argv[c + 1]); | ||
342 | } | ||
343 | if (0 == strcmp (argv[c], "-l")) | ||
344 | { | ||
345 | opt_log = GNUNET_YES; | ||
346 | } | ||
347 | if (0 == strcmp (argv[c], "-p")) | ||
348 | { | 338 | { |
349 | opt_plot = GNUNET_YES; | 339 | if ((c < (argc - 1)) && (0 == strcmp(argv[c], "-e"))) |
340 | { | ||
341 | GNUNET_free_non_null(opt_exp_file); | ||
342 | opt_exp_file = GNUNET_strdup(argv[c + 1]); | ||
343 | } | ||
344 | if (0 == strcmp(argv[c], "-l")) | ||
345 | { | ||
346 | opt_log = GNUNET_YES; | ||
347 | } | ||
348 | if (0 == strcmp(argv[c], "-p")) | ||
349 | { | ||
350 | opt_plot = GNUNET_YES; | ||
351 | } | ||
352 | if (0 == strcmp(argv[c], "-v")) | ||
353 | { | ||
354 | opt_verbose = GNUNET_YES; | ||
355 | } | ||
350 | } | 356 | } |
351 | if (0 == strcmp (argv[c], "-v")) | ||
352 | { | ||
353 | opt_verbose = GNUNET_YES; | ||
354 | } | ||
355 | } | ||
356 | } | 357 | } |
357 | 358 | ||
358 | 359 | ||
359 | int | 360 | int |
360 | main (int argc, char *argv[]) | 361 | main(int argc, char *argv[]) |
361 | { | 362 | { |
362 | GNUNET_log_setup("gnunet-ats-sim", "INFO", NULL); | 363 | GNUNET_log_setup("gnunet-ats-sim", "INFO", NULL); |
363 | 364 | ||
364 | parse_args (argc, argv); | 365 | parse_args(argc, argv); |
365 | if (NULL == opt_exp_file ) | 366 | if (NULL == opt_exp_file) |
366 | { | 367 | { |
367 | fprintf (stderr, "No experiment given...\n"); | 368 | fprintf(stderr, "No experiment given...\n"); |
368 | return 1; | 369 | return 1; |
369 | } | 370 | } |
370 | 371 | ||
371 | fprintf (stderr, "Loading experiment `%s' \n", opt_exp_file ); | 372 | fprintf(stderr, "Loading experiment `%s' \n", opt_exp_file); |
372 | e = GNUNET_ATS_TEST_experimentation_load (opt_exp_file); | 373 | e = GNUNET_ATS_TEST_experimentation_load(opt_exp_file); |
373 | if (NULL == e) | 374 | if (NULL == e) |
374 | { | 375 | { |
375 | fprintf (stderr, "Invalid experiment\n"); | 376 | fprintf(stderr, "Invalid experiment\n"); |
376 | return 1; | 377 | return 1; |
377 | } | 378 | } |
378 | if (0 == e->num_episodes) | 379 | if (0 == e->num_episodes) |
379 | { | 380 | { |
380 | fprintf (stderr, "No episodes included\n"); | 381 | fprintf(stderr, "No episodes included\n"); |
381 | return 1; | 382 | return 1; |
382 | } | 383 | } |
383 | 384 | ||
384 | /* Setup a topology with */ | 385 | /* Setup a topology with */ |
385 | GNUNET_ATS_TEST_create_topology ("gnunet-ats-sim", e->cfg_file, | 386 | GNUNET_ATS_TEST_create_topology("gnunet-ats-sim", e->cfg_file, |
386 | e->num_slaves, | 387 | e->num_slaves, |
387 | e->num_masters, | 388 | e->num_masters, |
388 | GNUNET_NO, | 389 | GNUNET_NO, |
389 | &topology_setup_done, | 390 | &topology_setup_done, |
390 | NULL, | 391 | NULL, |
391 | &log_request__cb); | 392 | &log_request__cb); |
392 | GNUNET_free (opt_exp_file); | 393 | GNUNET_free(opt_exp_file); |
393 | return 0; | 394 | return 0; |
394 | } | 395 | } |
395 | /* end of file gnunet-ats-sim.c */ | 396 | /* end of file gnunet-ats-sim.c */ |