diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2013-03-11 13:23:56 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2013-03-11 13:23:56 +0000 |
commit | 0d683490bcc0bda3bd7fff3ef2aae4c8f9eb71a5 (patch) | |
tree | ade41e9db5433012e9dc3d8478f7930501cfb467 /src/ats | |
parent | 6da582ab73a51dceb234e14cf365ff72eb82ced8 (diff) | |
download | gnunet-0d683490bcc0bda3bd7fff3ef2aae4c8f9eb71a5.tar.gz gnunet-0d683490bcc0bda3bd7fff3ef2aae4c8f9eb71a5.zip |
updating addresses
Diffstat (limited to 'src/ats')
-rw-r--r-- | src/ats/perf_ats_mlp.c | 85 |
1 files changed, 72 insertions, 13 deletions
diff --git a/src/ats/perf_ats_mlp.c b/src/ats/perf_ats_mlp.c index f0832c685..cf61a1829 100644 --- a/src/ats/perf_ats_mlp.c +++ b/src/ats/perf_ats_mlp.c | |||
@@ -78,6 +78,8 @@ struct PerfPeer | |||
78 | static int ret; | 78 | static int ret; |
79 | static int opt_numeric; | 79 | static int opt_numeric; |
80 | static int opt_dump; | 80 | static int opt_dump; |
81 | static int opt_update_percent; | ||
82 | static int opt_update_quantity; | ||
81 | 83 | ||
82 | static int N_peers_start; | 84 | static int N_peers_start; |
83 | static int N_peers_end; | 85 | static int N_peers_end; |
@@ -98,6 +100,8 @@ struct GAS_MLP_Handle *mlp; | |||
98 | */ | 100 | */ |
99 | struct GNUNET_CONTAINER_MultiHashMap * addresses; | 101 | struct GNUNET_CONTAINER_MultiHashMap * addresses; |
100 | 102 | ||
103 | struct GNUNET_ATS_Information ats[3]; | ||
104 | |||
101 | struct PerfPeer *peers; | 105 | struct PerfPeer *peers; |
102 | 106 | ||
103 | static void | 107 | static void |
@@ -153,7 +157,23 @@ perf_create_address (int cp, int ca) | |||
153 | } | 157 | } |
154 | 158 | ||
155 | 159 | ||
160 | static int | ||
161 | update_address_it (void *cls, const struct GNUNET_HashCode *key, void * value) | ||
162 | { | ||
163 | |||
164 | return GNUNET_OK; | ||
165 | } | ||
156 | 166 | ||
167 | static void | ||
168 | update_addresses (void) | ||
169 | { | ||
170 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Updating addresses %u addresses per peer \n", opt_update_quantity); | ||
171 | |||
172 | |||
173 | GNUNET_CONTAINER_multihashmap_iterate (addresses, &update_address_it, NULL); | ||
174 | |||
175 | |||
176 | } | ||
157 | 177 | ||
158 | 178 | ||
159 | static void | 179 | static void |
@@ -187,14 +207,6 @@ check (void *cls, char *const *args, const char *cfgfile, | |||
187 | GNUNET_assert (N_peers_end >= N_peers_start); | 207 | GNUNET_assert (N_peers_end >= N_peers_start); |
188 | GNUNET_assert (N_address >= 0); | 208 | GNUNET_assert (N_address >= 0); |
189 | 209 | ||
190 | if ((0 == N_peers_start) && (0 == N_peers_end)) | ||
191 | { | ||
192 | N_peers_start = PEERS_START; | ||
193 | N_peers_end = PEERS_END; | ||
194 | } | ||
195 | if (0 == N_address) | ||
196 | N_address = ADDRESSES; | ||
197 | |||
198 | fprintf (stderr, "Solving problem for %u..%u peers with %u addresses\n", | 210 | fprintf (stderr, "Solving problem for %u..%u peers with %u addresses\n", |
199 | N_peers_start, N_peers_end, N_address); | 211 | N_peers_start, N_peers_end, N_address); |
200 | 212 | ||
@@ -260,8 +272,13 @@ check (void *cls, char *const *args, const char *cfgfile, | |||
260 | (unsigned long long) mlp->ps.lp_dur.rel_value, | 272 | (unsigned long long) mlp->ps.lp_dur.rel_value, |
261 | (unsigned long long) mlp->ps.mip_dur.rel_value, | 273 | (unsigned long long) mlp->ps.mip_dur.rel_value, |
262 | mlp->ps.p_cols, mlp->ps.p_rows, mlp->ps.p_elements); | 274 | mlp->ps.p_cols, mlp->ps.p_rows, mlp->ps.p_elements); |
275 | if ((0 < opt_update_quantity) || (0 < opt_update_percent)) | ||
276 | { | ||
277 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Updating problem with %u peers and %u addresses\n", cp + 1, ca); | ||
278 | update_addresses (); | ||
279 | GAS_mlp_solve_problem (mlp, addresses); | ||
280 | } | ||
263 | } | 281 | } |
264 | |||
265 | } | 282 | } |
266 | 283 | ||
267 | 284 | ||
@@ -295,6 +312,8 @@ main (int argc, char *argv[]) | |||
295 | }; | 312 | }; |
296 | 313 | ||
297 | opt_dump = GNUNET_NO; | 314 | opt_dump = GNUNET_NO; |
315 | opt_update_quantity = 0; | ||
316 | opt_update_percent = 0; | ||
298 | 317 | ||
299 | N_peers_start = 0; | 318 | N_peers_start = 0; |
300 | N_peers_end = 0; | 319 | N_peers_end = 0; |
@@ -302,28 +321,28 @@ main (int argc, char *argv[]) | |||
302 | int c; | 321 | int c; |
303 | for (c = 0; c < argc; c++) | 322 | for (c = 0; c < argc; c++) |
304 | { | 323 | { |
305 | if ((0 == strcmp (argv[c], "-q")) && (c < argc)) | 324 | if ((0 == strcmp (argv[c], "-z")) && (c < (argc - 1))) |
306 | { | 325 | { |
307 | if (0 != atoi(argv[c+1])) | 326 | if (0 != atoi(argv[c+1])) |
308 | { | 327 | { |
309 | N_peers_start = atoi(argv[c+1]); | 328 | N_peers_start = atoi(argv[c+1]); |
310 | } | 329 | } |
311 | } | 330 | } |
312 | if ((0 == strcmp (argv[c], "-w")) && (c < argc)) | 331 | if ((0 == strcmp (argv[c], "-x")) && (c < (argc - 1))) |
313 | { | 332 | { |
314 | if (0 != atoi(argv[c+1])) | 333 | if (0 != atoi(argv[c+1])) |
315 | { | 334 | { |
316 | N_peers_end = atoi(argv[c+1]); | 335 | N_peers_end = atoi(argv[c+1]); |
317 | } | 336 | } |
318 | } | 337 | } |
319 | if ((0 == strcmp (argv[c], "-a")) && (c < argc)) | 338 | if ((0 == strcmp (argv[c], "-c")) && (c < (argc - 1))) |
320 | { | 339 | { |
321 | if (0 != atoi(argv[c+1])) | 340 | if (0 != atoi(argv[c+1])) |
322 | { | 341 | { |
323 | N_address = atoi(argv[c+1]); | 342 | N_address = atoi(argv[c+1]); |
324 | } | 343 | } |
325 | } | 344 | } |
326 | if ((0 == strcmp (argv[c], "-n"))) | 345 | if ((0 == strcmp (argv[c], "-v"))) |
327 | { | 346 | { |
328 | opt_numeric = GNUNET_YES; | 347 | opt_numeric = GNUNET_YES; |
329 | } | 348 | } |
@@ -331,6 +350,46 @@ main (int argc, char *argv[]) | |||
331 | { | 350 | { |
332 | opt_dump = GNUNET_YES; | 351 | opt_dump = GNUNET_YES; |
333 | } | 352 | } |
353 | if ((0 == strcmp (argv[c], "-p")) && (c < (argc - 1))) | ||
354 | { | ||
355 | if (0 != atoi(argv[c+1])) | ||
356 | { | ||
357 | /* Update a fix "p"ercentage of addresses */ | ||
358 | opt_update_percent = atoi(argv[c+1]); | ||
359 | if ((0 <= opt_update_percent) && (100 <= opt_update_percent)) | ||
360 | { | ||
361 | fprintf (stderr, _("Percentage has to be: 0 <= p <= 100 ")); | ||
362 | exit (1); | ||
363 | } | ||
364 | } | ||
365 | } | ||
366 | if ((0 == strcmp (argv[c], "-q")) && (c < (argc - 1))) | ||
367 | { | ||
368 | if (0 != atoi(argv[c+1])) | ||
369 | { | ||
370 | /* Update a fix "q"uantity of addresses */ | ||
371 | opt_update_quantity = atoi(argv[c+1]); | ||
372 | if (0 >= opt_update_quantity) | ||
373 | { | ||
374 | fprintf (stderr, _("Quantity has to be: p => 0 ")); | ||
375 | exit (1); | ||
376 | } | ||
377 | } | ||
378 | } | ||
379 | } | ||
380 | |||
381 | if ((0 == N_peers_start) && (0 == N_peers_end)) | ||
382 | { | ||
383 | N_peers_start = PEERS_START; | ||
384 | N_peers_end = PEERS_END; | ||
385 | } | ||
386 | if (0 == N_address) | ||
387 | N_address = ADDRESSES; | ||
388 | |||
389 | if (opt_update_quantity >= N_address) | ||
390 | { | ||
391 | fprintf (stderr, _("Trying to Update more addresses than we have per peer!")); | ||
392 | exit (1); | ||
334 | } | 393 | } |
335 | 394 | ||
336 | static const struct GNUNET_GETOPT_CommandLineOption options[] = { | 395 | static const struct GNUNET_GETOPT_CommandLineOption options[] = { |