diff options
author | Omar Tarabai <tarabai@devegypt.com> | 2014-09-25 17:36:46 +0000 |
---|---|---|
committer | Omar Tarabai <tarabai@devegypt.com> | 2014-09-25 17:36:46 +0000 |
commit | 962b455c52a21b8762d8fc4981c0e0d6386919bc (patch) | |
tree | fde7fb43183e211322716e0d2179c11cc45522ac /src/sensor | |
parent | 271260ce0b2fd4550b3c5ec957e4f62d95d7b304 (diff) | |
download | gnunet-962b455c52a21b8762d8fc4981c0e0d6386919bc.tar.gz gnunet-962b455c52a21b8762d8fc4981c0e0d6386919bc.zip |
sensor: profiler update
Diffstat (limited to 'src/sensor')
-rw-r--r-- | src/sensor/Makefile.am | 2 | ||||
-rw-r--r-- | src/sensor/gnunet-sensor-profiler.c | 455 | ||||
-rw-r--r-- | src/sensor/gnunet-sensor.c | 2 | ||||
-rw-r--r-- | src/sensor/profiler.py | 1 |
4 files changed, 93 insertions, 367 deletions
diff --git a/src/sensor/Makefile.am b/src/sensor/Makefile.am index adcac0936..4be862337 100644 --- a/src/sensor/Makefile.am +++ b/src/sensor/Makefile.am | |||
@@ -119,7 +119,7 @@ gnunet_sensor_profiler_LDADD = \ | |||
119 | $(top_builddir)/src/util/libgnunetutil.la \ | 119 | $(top_builddir)/src/util/libgnunetutil.la \ |
120 | $(top_builddir)/src/testbed/libgnunettestbed.la \ | 120 | $(top_builddir)/src/testbed/libgnunettestbed.la \ |
121 | $(top_builddir)/src/peerstore/libgnunetpeerstore.la \ | 121 | $(top_builddir)/src/peerstore/libgnunetpeerstore.la \ |
122 | $(top_builddir)/src/transport/libgnunettransport.la | 122 | $(top_builddir)/src/statistics/libgnunetstatistics.la |
123 | 123 | ||
124 | perf_pow_sign_SOURCES = \ | 124 | perf_pow_sign_SOURCES = \ |
125 | perf_pow_sign.c | 125 | perf_pow_sign.c |
diff --git a/src/sensor/gnunet-sensor-profiler.c b/src/sensor/gnunet-sensor-profiler.c index 3e25cb732..cb0b80044 100644 --- a/src/sensor/gnunet-sensor-profiler.c +++ b/src/sensor/gnunet-sensor-profiler.c | |||
@@ -57,48 +57,18 @@ struct PeerInfo | |||
57 | */ | 57 | */ |
58 | int index; | 58 | int index; |
59 | 59 | ||
60 | }; | 60 | /** |
61 | 61 | * TESTBED operation used to connect to statistics service | |
62 | struct DisconnectionContext | 62 | */ |
63 | { | 63 | struct GNUNET_TESTBED_Operation *statistics_op; |
64 | |||
65 | struct DisconnectionContext *prev; | ||
66 | |||
67 | struct DisconnectionContext *next; | ||
68 | |||
69 | struct PeerInfo *p1; | ||
70 | |||
71 | struct PeerInfo *p2; | ||
72 | |||
73 | struct GNUNET_TESTBED_Operation *p1_transport_op; | ||
74 | |||
75 | struct GNUNET_TRANSPORT_Blacklist *blacklist; | ||
76 | |||
77 | }; | ||
78 | |||
79 | struct ConnectionContext | ||
80 | { | ||
81 | |||
82 | struct PeerInfo *p1; | ||
83 | |||
84 | struct PeerInfo *p2; | ||
85 | |||
86 | }; | ||
87 | |||
88 | struct Split | ||
89 | { | ||
90 | |||
91 | struct Split *next; | ||
92 | |||
93 | struct Split *prev; | ||
94 | |||
95 | int p1; | ||
96 | 64 | ||
97 | int p2; | 65 | /** |
66 | * Handle to the peer's statistics service | ||
67 | */ | ||
68 | struct GNUNET_STATISTICS_Handle *statistics; | ||
98 | 69 | ||
99 | }; | 70 | }; |
100 | 71 | ||
101 | |||
102 | /** | 72 | /** |
103 | * Name of the configuration file used | 73 | * Name of the configuration file used |
104 | */ | 74 | */ |
@@ -140,9 +110,9 @@ static unsigned int sensors_interval = 0; | |||
140 | static char *topology_file; | 110 | static char *topology_file; |
141 | 111 | ||
142 | /** | 112 | /** |
143 | * Path to topology file (Option -s) | 113 | * Number of peers to simulate anomalies on (Option -a) |
144 | */ | 114 | */ |
145 | static char *split_file; | 115 | static unsigned int anomalous_peers = 0; |
146 | 116 | ||
147 | /** | 117 | /** |
148 | * Array of peer info for all peers | 118 | * Array of peer info for all peers |
@@ -189,26 +159,6 @@ static unsigned int sensor_names_size = 0; | |||
189 | */ | 159 | */ |
190 | static GNUNET_SCHEDULER_TaskIdentifier delayed_task = GNUNET_SCHEDULER_NO_TASK; | 160 | static GNUNET_SCHEDULER_TaskIdentifier delayed_task = GNUNET_SCHEDULER_NO_TASK; |
191 | 161 | ||
192 | /** | ||
193 | * Head of list of disconnection contexts | ||
194 | */ | ||
195 | static struct DisconnectionContext *dc_head; | ||
196 | |||
197 | /** | ||
198 | * Tail of list of disconnection contexts | ||
199 | */ | ||
200 | static struct DisconnectionContext *dc_tail; | ||
201 | |||
202 | /** | ||
203 | * Head of splits list | ||
204 | */ | ||
205 | static struct Split *split_head; | ||
206 | |||
207 | /** | ||
208 | * Tail of splits list | ||
209 | */ | ||
210 | static struct Split *split_tail; | ||
211 | |||
212 | 162 | ||
213 | /** | 163 | /** |
214 | * Copy directory recursively | 164 | * Copy directory recursively |
@@ -222,40 +172,12 @@ copy_dir (const char *src, const char *dst); | |||
222 | 172 | ||
223 | 173 | ||
224 | /** | 174 | /** |
225 | * Prompt the user to disconnect two peers | ||
226 | */ | ||
227 | static void | ||
228 | prompt_peer_disconnection (); | ||
229 | |||
230 | |||
231 | /** | ||
232 | * Destroy a DisconnectionContext struct | ||
233 | */ | ||
234 | static void | ||
235 | destroy_dc (struct DisconnectionContext *dc) | ||
236 | { | ||
237 | if (NULL != dc->blacklist) | ||
238 | { | ||
239 | GNUNET_TRANSPORT_blacklist_cancel (dc->blacklist); | ||
240 | dc->blacklist = NULL; | ||
241 | } | ||
242 | if (NULL != dc->p1_transport_op) | ||
243 | { | ||
244 | GNUNET_TESTBED_operation_done (dc->p1_transport_op); | ||
245 | dc->p1_transport_op = NULL; | ||
246 | } | ||
247 | GNUNET_free (dc); | ||
248 | } | ||
249 | |||
250 | |||
251 | /** | ||
252 | * Do clean up and shutdown scheduler | 175 | * Do clean up and shutdown scheduler |
253 | */ | 176 | */ |
254 | static void | 177 | static void |
255 | do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 178 | do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
256 | { | 179 | { |
257 | int i; | 180 | int i; |
258 | struct DisconnectionContext *dc; | ||
259 | 181 | ||
260 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Shutting down.\n"); | 182 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Shutting down.\n"); |
261 | if (GNUNET_SCHEDULER_NO_TASK != delayed_task) | 183 | if (GNUNET_SCHEDULER_NO_TASK != delayed_task) |
@@ -263,12 +185,13 @@ do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
263 | GNUNET_SCHEDULER_cancel (delayed_task); | 185 | GNUNET_SCHEDULER_cancel (delayed_task); |
264 | delayed_task = GNUNET_SCHEDULER_NO_TASK; | 186 | delayed_task = GNUNET_SCHEDULER_NO_TASK; |
265 | } | 187 | } |
266 | dc = dc_head; | 188 | for (i = 0; i < num_peers; i++) |
267 | while (NULL != dc) | ||
268 | { | 189 | { |
269 | GNUNET_CONTAINER_DLL_remove (dc_head, dc_tail, dc); | 190 | if (NULL != all_peers_info[i].statistics_op) |
270 | destroy_dc (dc); | 191 | { |
271 | dc = dc_head; | 192 | GNUNET_TESTBED_operation_done (all_peers_info[i].statistics_op); |
193 | all_peers_info[i].statistics_op = NULL; | ||
194 | } | ||
272 | } | 195 | } |
273 | if (NULL != peerstore_op) | 196 | if (NULL != peerstore_op) |
274 | { | 197 | { |
@@ -295,208 +218,6 @@ do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
295 | } | 218 | } |
296 | 219 | ||
297 | 220 | ||
298 | /*****************************************************************************/ | ||
299 | /****************************** DISCONNECT PEERS *****************************/ | ||
300 | /*****************************************************************************/ | ||
301 | |||
302 | |||
303 | /** | ||
304 | * Function to call with result of the TRANSPORT try disconnect request. | ||
305 | * | ||
306 | * @param cls closure | ||
307 | * @param result #GNUNET_OK if message was transmitted to transport service | ||
308 | * #GNUNET_SYSERR if message was not transmitted to transport service | ||
309 | */ | ||
310 | static void | ||
311 | transport_disconnect_cb (void *cls, const int result) | ||
312 | { | ||
313 | struct DisconnectionContext *dc = cls; | ||
314 | |||
315 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
316 | "Peer disconnection request sent: %d,%d\n", dc->p1->index, | ||
317 | dc->p2->index); | ||
318 | } | ||
319 | |||
320 | |||
321 | /** | ||
322 | * Callback to be called when transport service connect operation is completed | ||
323 | * | ||
324 | * @param cls the callback closure from functions generating an operation | ||
325 | * @param op the operation that has been finished | ||
326 | * @param ca_result the service handle returned from GNUNET_TESTBED_ConnectAdapter() | ||
327 | * @param emsg error message in case the operation has failed; will be NULL if | ||
328 | * operation has executed successfully. | ||
329 | */ | ||
330 | static void | ||
331 | transport_connect_cb (void *cls, struct GNUNET_TESTBED_Operation *op, | ||
332 | void *ca_result, const char *emsg) | ||
333 | { | ||
334 | struct DisconnectionContext *dc = cls; | ||
335 | struct GNUNET_TRANSPORT_Handle *transport = ca_result; | ||
336 | |||
337 | if (NULL != emsg) | ||
338 | { | ||
339 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "ERROR: %s.\n", emsg); | ||
340 | GNUNET_assert (0); | ||
341 | } | ||
342 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "transport_connect_cb().\n"); | ||
343 | GNUNET_TRANSPORT_try_disconnect (transport, &dc->p2->peer_id, | ||
344 | &transport_disconnect_cb, dc); | ||
345 | } | ||
346 | |||
347 | |||
348 | /** | ||
349 | * Callback from TRANSPORT service to ask if the given peer ID is blacklisted. | ||
350 | * | ||
351 | * @param cls closure, DisconnectionContext | ||
352 | * @param pid peer to approve or disapproave | ||
353 | * @return #GNUNET_OK if the connection is allowed, #GNUNET_SYSERR if not | ||
354 | */ | ||
355 | static int | ||
356 | blacklist_cb (void *cls, const struct GNUNET_PeerIdentity *pid) | ||
357 | { | ||
358 | struct DisconnectionContext *dc = cls; | ||
359 | |||
360 | if (0 == GNUNET_CRYPTO_cmp_peer_identity (&dc->p2->peer_id, pid)) | ||
361 | return GNUNET_SYSERR; | ||
362 | return GNUNET_OK; | ||
363 | } | ||
364 | |||
365 | |||
366 | /** | ||
367 | * Adapter function called to establish a connection to transport service. | ||
368 | * | ||
369 | * @param cls closure | ||
370 | * @param cfg configuration of the peer to connect to; will be available until | ||
371 | * GNUNET_TESTBED_operation_done() is called on the operation returned | ||
372 | * from GNUNET_TESTBED_service_connect() | ||
373 | * @return service handle to return in 'op_result', NULL on error | ||
374 | */ | ||
375 | static void * | ||
376 | transport_connect_adapter (void *cls, | ||
377 | const struct GNUNET_CONFIGURATION_Handle *cfg) | ||
378 | { | ||
379 | struct DisconnectionContext *dc = cls; | ||
380 | struct GNUNET_TRANSPORT_Handle *transport; | ||
381 | |||
382 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "transport_connect_adapter().\n"); | ||
383 | dc->blacklist = GNUNET_TRANSPORT_blacklist (cfg, &blacklist_cb, dc); | ||
384 | GNUNET_assert (NULL != dc->blacklist); | ||
385 | transport = GNUNET_TRANSPORT_connect (cfg, NULL, NULL, NULL, NULL, NULL); | ||
386 | GNUNET_assert (NULL != transport); | ||
387 | return transport; | ||
388 | } | ||
389 | |||
390 | |||
391 | /** | ||
392 | * Adapter function called to destroy a connection to transport service. | ||
393 | * | ||
394 | * @param cls closure | ||
395 | * @param op_result service handle returned from the connect adapter | ||
396 | */ | ||
397 | static void | ||
398 | transport_disconnect_adapter (void *cls, void *op_result) | ||
399 | { | ||
400 | struct GNUNET_TRANSPORT_Handle *transport = op_result; | ||
401 | |||
402 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "transport_disconnect_adapter().\n"); | ||
403 | GNUNET_TRANSPORT_disconnect (transport); | ||
404 | } | ||
405 | |||
406 | |||
407 | /** | ||
408 | * Kill any connection between two peers. Has no effect if the peers are not | ||
409 | * connected. | ||
410 | */ | ||
411 | static void | ||
412 | disconnect_peers (struct PeerInfo *p1, struct PeerInfo *p2) | ||
413 | { | ||
414 | struct DisconnectionContext *dc; | ||
415 | |||
416 | GNUNET_assert (p1 != p2); | ||
417 | dc = GNUNET_new (struct DisconnectionContext); | ||
418 | |||
419 | dc->p1 = p1; | ||
420 | dc->p2 = p2; | ||
421 | GNUNET_CONTAINER_DLL_insert (dc_head, dc_tail, dc); | ||
422 | dc->p1_transport_op = | ||
423 | GNUNET_TESTBED_service_connect (NULL, p1->testbed_peer, "transport", | ||
424 | &transport_connect_cb, dc, | ||
425 | &transport_connect_adapter, | ||
426 | &transport_disconnect_adapter, dc); | ||
427 | } | ||
428 | |||
429 | |||
430 | /*****************************************************************************/ | ||
431 | /**************************** END DISCONNECT PEERS ***************************/ | ||
432 | /*****************************************************************************/ | ||
433 | |||
434 | /*****************************************************************************/ | ||
435 | /******************************* CONNECT PEERS *******************************/ | ||
436 | /*****************************************************************************/ | ||
437 | |||
438 | /** | ||
439 | * Callback to be called when overlay connection operation is completed | ||
440 | * | ||
441 | * @param cls the callback closure from functions generating an operation | ||
442 | * @param op the operation that has been finished | ||
443 | * @param emsg error message in case the operation has failed; will be NULL if | ||
444 | * operation has executed successfully. | ||
445 | */ | ||
446 | static void | ||
447 | overlay_connect_cb (void *cls, struct GNUNET_TESTBED_Operation *op, | ||
448 | const char *emsg) | ||
449 | { | ||
450 | struct ConnectionContext *cc = cls; | ||
451 | |||
452 | if (NULL != emsg) | ||
453 | { | ||
454 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "ERROR: %s.\n", emsg); | ||
455 | GNUNET_assert (0); | ||
456 | } | ||
457 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer connection request sent: %d,%d\n", | ||
458 | cc->p1->index, cc->p2->index); | ||
459 | GNUNET_free (cc); | ||
460 | GNUNET_TESTBED_operation_done (op); | ||
461 | } | ||
462 | |||
463 | |||
464 | /** | ||
465 | * Connect two peers together | ||
466 | */ | ||
467 | static void | ||
468 | connect_peers (struct PeerInfo *p1, struct PeerInfo *p2) | ||
469 | { | ||
470 | struct DisconnectionContext *dc; | ||
471 | struct ConnectionContext *cc; | ||
472 | |||
473 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "connect_peers()\n"); | ||
474 | /* Check if we have a disconnection request before */ | ||
475 | dc = dc_head; | ||
476 | while (NULL != dc) | ||
477 | { | ||
478 | if ((dc->p1 == p1 && dc->p2 == p2) || (dc->p1 == p2 && dc->p2 == p1)) | ||
479 | break; | ||
480 | dc = dc->next; | ||
481 | } | ||
482 | if (NULL != dc) | ||
483 | { | ||
484 | GNUNET_CONTAINER_DLL_remove (dc_head, dc_tail, dc); | ||
485 | destroy_dc (dc); | ||
486 | } | ||
487 | /* Connect peers using testbed */ | ||
488 | cc = GNUNET_new (struct ConnectionContext); | ||
489 | |||
490 | cc->p1 = p1; | ||
491 | cc->p2 = p2; | ||
492 | GNUNET_TESTBED_overlay_connect (cc, &overlay_connect_cb, cc, p1->testbed_peer, | ||
493 | p2->testbed_peer); | ||
494 | } | ||
495 | |||
496 | /*****************************************************************************/ | ||
497 | /****************************** END CONNECT PEERS ****************************/ | ||
498 | /*****************************************************************************/ | ||
499 | |||
500 | /** | 221 | /** |
501 | * Function called with each file/folder inside a directory that is being copied. | 222 | * Function called with each file/folder inside a directory that is being copied. |
502 | * | 223 | * |
@@ -742,43 +463,65 @@ peerstore_disconnect_adapter (void *cls, void *op_result) | |||
742 | 463 | ||
743 | 464 | ||
744 | /** | 465 | /** |
745 | * Prompty the user to reconnect two peers | 466 | * Callback to be called when statistics service connect operation is completed |
467 | * | ||
468 | * @param cls the callback closure from functions generating an operation | ||
469 | * @param op the operation that has been finished | ||
470 | * @param ca_result the service handle returned from GNUNET_TESTBED_ConnectAdapter() | ||
471 | * @param emsg error message in case the operation has failed; will be NULL if | ||
472 | * operation has executed successfully. | ||
746 | */ | 473 | */ |
747 | static void | 474 | static void |
748 | prompt_peer_reconnection (void *cls, | 475 | statistics_connect_cb (void *cls, struct GNUNET_TESTBED_Operation *op, |
749 | const struct GNUNET_SCHEDULER_TaskContext *tc) | 476 | void *ca_result, const char *emsg) |
750 | { | 477 | { |
751 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Reconnecting one link.\n"); | 478 | struct PeerInfo *peer = cls; |
752 | connect_peers (&all_peers_info[split_head->p1], | 479 | |
753 | &all_peers_info[split_head->p2]); | 480 | if (NULL != emsg) |
754 | GNUNET_SCHEDULER_cancel (shutdown_task); | 481 | { |
755 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Shutting down in 5 mins.\n"); | 482 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "ERROR: %s.\n", emsg); |
756 | shutdown_task = | 483 | GNUNET_assert (0); |
757 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply | 484 | } |
758 | (GNUNET_TIME_UNIT_MINUTES, 5), do_shutdown, | 485 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
759 | NULL); | 486 | "Connected to statistics service on peer `%s'.\n", GNUNET_i2s (&peer->peer_id)); |
487 | GNUNET_STATISTICS_set (peer->statistics, "# peers connected", 0, GNUNET_NO); | ||
488 | } | ||
489 | |||
490 | |||
491 | /** | ||
492 | * Adapter function called to establish a connection to statistics service. | ||
493 | * | ||
494 | * @param cls closure | ||
495 | * @param cfg configuration of the peer to connect to; will be available until | ||
496 | * GNUNET_TESTBED_operation_done() is called on the operation returned | ||
497 | * from GNUNET_TESTBED_service_connect() | ||
498 | * @return service handle to return in 'op_result', NULL on error | ||
499 | */ | ||
500 | static void * | ||
501 | statistics_connect_adapter (void *cls, | ||
502 | const struct GNUNET_CONFIGURATION_Handle *cfg) | ||
503 | { | ||
504 | struct PeerInfo *peer = cls; | ||
505 | |||
506 | peer->statistics = GNUNET_STATISTICS_create ("core", cfg); | ||
507 | GNUNET_assert (NULL != peer->statistics); | ||
508 | return peer->statistics; | ||
760 | } | 509 | } |
761 | 510 | ||
762 | 511 | ||
763 | /** | 512 | /** |
764 | * Prompt the user to disconnect two peers | 513 | * Adapter function called to destroy a connection to statistics service. |
514 | * | ||
515 | * @param cls closure | ||
516 | * @param op_result service handle returned from the connect adapter | ||
765 | */ | 517 | */ |
766 | static void | 518 | static void |
767 | prompt_peer_disconnection () | 519 | statistics_disconnect_adapter (void *cls, void *op_result) |
768 | { | 520 | { |
769 | struct Split *s; | 521 | struct PeerInfo *peer = cls; |
770 | 522 | ||
771 | s = split_head; | 523 | GNUNET_STATISTICS_destroy (peer->statistics, GNUNET_NO); |
772 | while (NULL != s) | 524 | peer->statistics = NULL; |
773 | { | ||
774 | disconnect_peers (&all_peers_info[s->p1], &all_peers_info[s->p2]); | ||
775 | s = s->next; | ||
776 | } | ||
777 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
778 | "Will prompt for reconnection in 1 min.\n"); | ||
779 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply | ||
780 | (GNUNET_TIME_UNIT_MINUTES, 5), | ||
781 | &prompt_peer_reconnection, NULL); | ||
782 | } | 525 | } |
783 | 526 | ||
784 | 527 | ||
@@ -788,10 +531,33 @@ prompt_peer_disconnection () | |||
788 | static void | 531 | static void |
789 | simulate_anomalies (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 532 | simulate_anomalies (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
790 | { | 533 | { |
534 | int i; | ||
535 | uint32_t an_peer; | ||
536 | struct GNUNET_TIME_Relative shutdown_delay; | ||
537 | |||
791 | delayed_task = GNUNET_SCHEDULER_NO_TASK; | 538 | delayed_task = GNUNET_SCHEDULER_NO_TASK; |
792 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 539 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
793 | "Training period over, simulating anomalies now.\n"); | 540 | "Training period over, simulating anomalies now.\n"); |
794 | prompt_peer_disconnection (); | 541 | GNUNET_assert (anomalous_peers <= num_peers); |
542 | for (i = 0; i < anomalous_peers; i++) | ||
543 | { | ||
544 | an_peer = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, num_peers); | ||
545 | if (NULL != all_peers_info[an_peer].statistics_op) | ||
546 | { | ||
547 | i--; | ||
548 | continue; | ||
549 | } | ||
550 | all_peers_info[an_peer].statistics_op = | ||
551 | GNUNET_TESTBED_service_connect (NULL, all_peers_info[an_peer].testbed_peer, | ||
552 | "statistics", &statistics_connect_cb, | ||
553 | &all_peers_info[an_peer], &statistics_connect_adapter, | ||
554 | &statistics_disconnect_adapter, &all_peers_info[an_peer]); | ||
555 | } | ||
556 | shutdown_delay = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, num_peers * 6); | ||
557 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Shutting down in %s\n", | ||
558 | GNUNET_STRINGS_relative_time_to_string (shutdown_delay, GNUNET_NO)); | ||
559 | GNUNET_SCHEDULER_cancel (shutdown_task); | ||
560 | shutdown_task = GNUNET_SCHEDULER_add_delayed (shutdown_delay, &do_shutdown, NULL); | ||
795 | } | 561 | } |
796 | 562 | ||
797 | 563 | ||
@@ -935,7 +701,6 @@ test_master (void *cls, struct GNUNET_TESTBED_RunHandle *h, unsigned int num, | |||
935 | "%d peers started. %d links succeeded. %d links failed.\n", | 701 | "%d peers started. %d links succeeded. %d links failed.\n", |
936 | num_peers, links_succeeded, links_failed); | 702 | num_peers, links_succeeded, links_failed); |
937 | GNUNET_assert (num == num_peers); | 703 | GNUNET_assert (num == num_peers); |
938 | GNUNET_assert (0 == links_failed); | ||
939 | /* Collect peer information */ | 704 | /* Collect peer information */ |
940 | all_peers_info = GNUNET_new_array (num_peers, struct PeerInfo); | 705 | all_peers_info = GNUNET_new_array (num_peers, struct PeerInfo); |
941 | 706 | ||
@@ -975,44 +740,6 @@ verify_args () | |||
975 | 740 | ||
976 | 741 | ||
977 | /** | 742 | /** |
978 | * Parse split file (name passed as parameter). | ||
979 | * Split file contains sequence of peer pairs to disconenct. | ||
980 | */ | ||
981 | static void | ||
982 | parse_split_file () | ||
983 | { | ||
984 | uint64_t f_size; | ||
985 | char *splits; | ||
986 | char *ptr; | ||
987 | int p1; | ||
988 | int p2; | ||
989 | struct Split *s; | ||
990 | |||
991 | GNUNET_assert (NULL != split_file); | ||
992 | GNUNET_assert (GNUNET_OK == | ||
993 | GNUNET_DISK_file_size (split_file, &f_size, GNUNET_NO, | ||
994 | GNUNET_YES)); | ||
995 | splits = malloc (f_size); | ||
996 | GNUNET_assert (f_size == GNUNET_DISK_fn_read (split_file, splits, f_size)); | ||
997 | ptr = splits; | ||
998 | while (ptr < (splits + f_size)) | ||
999 | { | ||
1000 | GNUNET_assert (2 == sscanf (ptr, "%d,%d", &p1, &p2)); | ||
1001 | s = GNUNET_new (struct Split); | ||
1002 | |||
1003 | s->p1 = p1; | ||
1004 | s->p2 = p2; | ||
1005 | GNUNET_CONTAINER_DLL_insert_tail (split_head, split_tail, s); | ||
1006 | while (ptr < (splits + f_size) && *ptr != '\n') | ||
1007 | ptr++; | ||
1008 | if (*ptr == '\n') | ||
1009 | ptr++; | ||
1010 | } | ||
1011 | GNUNET_free (splits); | ||
1012 | } | ||
1013 | |||
1014 | |||
1015 | /** | ||
1016 | * Actual main function. | 743 | * Actual main function. |
1017 | * | 744 | * |
1018 | * @param cls unused | 745 | * @param cls unused |
@@ -1035,7 +762,6 @@ run (void *cls, char *const *args, const char *cf, | |||
1035 | cfg, "TESTBED", | 762 | cfg, "TESTBED", |
1036 | "OVERLAY_TOPOLOGY_FILE", | 763 | "OVERLAY_TOPOLOGY_FILE", |
1037 | topology_file); | 764 | topology_file); |
1038 | parse_split_file (); | ||
1039 | shutdown_task = | 765 | shutdown_task = |
1040 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &do_shutdown, | 766 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &do_shutdown, |
1041 | NULL); | 767 | NULL); |
@@ -1059,8 +785,9 @@ main (int argc, char *const *argv) | |||
1059 | {'i', "sensors-interval", "INTERVAL", | 785 | {'i', "sensors-interval", "INTERVAL", |
1060 | gettext_noop ("Change the interval of running sensors to given value"), | 786 | gettext_noop ("Change the interval of running sensors to given value"), |
1061 | GNUNET_YES, &GNUNET_GETOPT_set_uint, &sensors_interval}, | 787 | GNUNET_YES, &GNUNET_GETOPT_set_uint, &sensors_interval}, |
1062 | {'s', "split-file", "FILEPATH", gettext_noop ("Path to split file"), | 788 | {'a', "anomalous-peers", "COUNT", |
1063 | GNUNET_YES, &GNUNET_GETOPT_set_filename, &split_file}, | 789 | gettext_noop ("Number of peers to simulate anomalies on"), GNUNET_YES, |
790 | &GNUNET_GETOPT_set_uint, &anomalous_peers}, | ||
1064 | GNUNET_GETOPT_OPTION_END | 791 | GNUNET_GETOPT_OPTION_END |
1065 | }; | 792 | }; |
1066 | 793 | ||
diff --git a/src/sensor/gnunet-sensor.c b/src/sensor/gnunet-sensor.c index 7b7be61ef..4ba70a167 100644 --- a/src/sensor/gnunet-sensor.c +++ b/src/sensor/gnunet-sensor.c | |||
@@ -164,7 +164,7 @@ main (int argc, char *const *argv) | |||
164 | {'g', "get-sensor", NULL, | 164 | {'g', "get-sensor", NULL, |
165 | gettext_noop ("Retrieve information about a single sensor"), | 165 | gettext_noop ("Retrieve information about a single sensor"), |
166 | 1, &GNUNET_GETOPT_set_string, &get_sensor}, | 166 | 1, &GNUNET_GETOPT_set_string, &get_sensor}, |
167 | {'f', "force anomaly", NULL, | 167 | {'f', "force-anomaly", NULL, |
168 | gettext_noop ("Force an anomaly on a sensor, use only for testing"), | 168 | gettext_noop ("Force an anomaly on a sensor, use only for testing"), |
169 | 1, &GNUNET_GETOPT_set_string, &force_anomaly}, | 169 | 1, &GNUNET_GETOPT_set_string, &force_anomaly}, |
170 | GNUNET_GETOPT_OPTION_END | 170 | GNUNET_GETOPT_OPTION_END |
diff --git a/src/sensor/profiler.py b/src/sensor/profiler.py index 8e48ab838..834020250 100644 --- a/src/sensor/profiler.py +++ b/src/sensor/profiler.py | |||
@@ -140,7 +140,6 @@ def run_profiler(peers, topology_file, sensors_interval, split_file): | |||
140 | line = '' | 140 | line = '' |
141 | else: | 141 | else: |
142 | line += c | 142 | line += c |
143 | os.remove('log') | ||
144 | 143 | ||
145 | def create_split(): | 144 | def create_split(): |
146 | global graph | 145 | global graph |