aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/sensor/gnunet-sensor-profiler.c56
-rw-r--r--src/sensor/gnunet-sensor-profiler.conf3
2 files changed, 33 insertions, 26 deletions
diff --git a/src/sensor/gnunet-sensor-profiler.c b/src/sensor/gnunet-sensor-profiler.c
index d236d1780..814413ba1 100644
--- a/src/sensor/gnunet-sensor-profiler.c
+++ b/src/sensor/gnunet-sensor-profiler.c
@@ -90,6 +90,11 @@ static unsigned int num_peers = 0;
90static unsigned int sensors_interval = 0; 90static unsigned int sensors_interval = 0;
91 91
92/** 92/**
93 * Path to topology file (Option -t)
94 */
95static char *topology_file;
96
97/**
93 * Array of peer info for all peers 98 * Array of peer info for all peers
94 */ 99 */
95static struct PeerInfo *all_peers_info; 100static struct PeerInfo *all_peers_info;
@@ -187,8 +192,6 @@ copy_dir_scanner (void *cls, const char *filename)
187 192
188 GNUNET_asprintf (&dst, "%s%s%s", dst_dir, DIR_SEPARATOR_STR, 193 GNUNET_asprintf (&dst, "%s%s%s", dst_dir, DIR_SEPARATOR_STR,
189 GNUNET_STRINGS_get_short_name (filename)); 194 GNUNET_STRINGS_get_short_name (filename));
190 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Copying `%s' to `%s'.\n", filename,
191 dst);
192 if (GNUNET_YES == GNUNET_DISK_directory_test (filename, GNUNET_YES)) 195 if (GNUNET_YES == GNUNET_DISK_directory_test (filename, GNUNET_YES))
193 copy_result = copy_dir (filename, dst); 196 copy_result = copy_dir (filename, dst);
194 else 197 else
@@ -212,8 +215,6 @@ copy_dir_scanner (void *cls, const char *filename)
212static int 215static int
213copy_dir (const char *src, const char *dst) 216copy_dir (const char *src, const char *dst)
214{ 217{
215 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Copying directory `%s' to `%s'.\n", src,
216 dst);
217 if (GNUNET_YES != GNUNET_DISK_directory_test (src, GNUNET_YES)) 218 if (GNUNET_YES != GNUNET_DISK_directory_test (src, GNUNET_YES))
218 return GNUNET_SYSERR; 219 return GNUNET_SYSERR;
219 if (GNUNET_OK != GNUNET_DISK_directory_create (dst)) 220 if (GNUNET_OK != GNUNET_DISK_directory_create (dst))
@@ -249,9 +250,8 @@ sensor_dir_scanner (void *cls, const char *filename)
249 } 250 }
250 else 251 else
251 { 252 {
252 sensor_name = GNUNET_strdup(file_basename); 253 sensor_name = GNUNET_strdup (file_basename);
253 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Saving sensor name `%s'.\n", sensor_name); 254 GNUNET_array_append (sensor_names, sensor_names_size, sensor_name);
254 GNUNET_array_append(sensor_names, sensor_names_size, sensor_name);
255 sensor_cfg = GNUNET_CONFIGURATION_create (); 255 sensor_cfg = GNUNET_CONFIGURATION_create ();
256 GNUNET_assert (GNUNET_OK == 256 GNUNET_assert (GNUNET_OK ==
257 GNUNET_CONFIGURATION_parse (sensor_cfg, filename)); 257 GNUNET_CONFIGURATION_parse (sensor_cfg, filename));
@@ -322,7 +322,7 @@ dashboard_started (void *cls, struct GNUNET_TESTBED_Operation *op,
322 */ 322 */
323static int 323static int
324peerstore_watch_cb (void *cls, struct GNUNET_PEERSTORE_Record *record, 324peerstore_watch_cb (void *cls, struct GNUNET_PEERSTORE_Record *record,
325 char *emsg) 325 char *emsg)
326{ 326{
327 struct PeerInfo *peer = cls; 327 struct PeerInfo *peer = cls;
328 struct GNUNET_SENSOR_DashboardAnomalyEntry *anomaly; 328 struct GNUNET_SENSOR_DashboardAnomalyEntry *anomaly;
@@ -337,14 +337,11 @@ peerstore_watch_cb (void *cls, struct GNUNET_PEERSTORE_Record *record,
337 anomaly = record->value; 337 anomaly = record->value;
338 GNUNET_assert (0 == 338 GNUNET_assert (0 ==
339 GNUNET_CRYPTO_cmp_peer_identity (&peer->peer_id, 339 GNUNET_CRYPTO_cmp_peer_identity (&peer->peer_id,
340 record->peer)); 340 record->peer));
341 printf ("Anomaly report:\n" 341 printf ("Anomaly report:\n" " Peer: `%s'\n" " Sensor: `%s'\n"
342 " Peer: `%s'\n" 342 " Anomalous: `%d'\n" " Anomalous neighbors: %f.\n\n",
343 " Sensor: `%s'\n" 343 GNUNET_i2s (&peer->peer_id), record->key, anomaly->anomalous,
344 " Anomalous: `%d'\n" 344 anomaly->anomalous_neighbors);
345 " Anomalous neighbors: %f.\n\n",
346 GNUNET_i2s (&peer->peer_id),
347 record->key, anomaly->anomalous, anomaly->anomalous_neighbors);
348 return GNUNET_YES; 345 return GNUNET_YES;
349} 346}
350 347
@@ -378,8 +375,9 @@ peerstore_connect_cb (void *cls, struct GNUNET_TESTBED_Operation *op,
378 peer = &all_peers_info[i]; 375 peer = &all_peers_info[i];
379 for (j = 0; j < sensor_names_size; j++) 376 for (j = 0; j < sensor_names_size; j++)
380 { 377 {
381 GNUNET_PEERSTORE_watch (peerstore, "sensordashboard-anomalies", &peer->peer_id, 378 GNUNET_PEERSTORE_watch (peerstore, "sensordashboard-anomalies",
382 sensor_names[j], &peerstore_watch_cb, peer); 379 &peer->peer_id, sensor_names[j],
380 &peerstore_watch_cb, peer);
383 } 381 }
384 } 382 }
385} 383}
@@ -441,7 +439,9 @@ sensor_service_started (void *cls, struct GNUNET_TESTBED_Operation *op,
441 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sensor service started on peer `%s'.\n", 439 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sensor service started on peer `%s'.\n",
442 GNUNET_i2s (&peer->peer_id)); 440 GNUNET_i2s (&peer->peer_id));
443 GNUNET_TESTBED_operation_done (op); 441 GNUNET_TESTBED_operation_done (op);
444 sensor_services_started ++; 442 sensor_services_started++;
443 if (sensor_services_started == num_peers) //TODO: remove
444 do_shutdown ();
445 //TODO 445 //TODO
446} 446}
447 447
@@ -548,6 +548,13 @@ verify_args ()
548 ("Invalid or missing number of peers. Set at least 3 peers.\n")); 548 ("Invalid or missing number of peers. Set at least 3 peers.\n"));
549 return GNUNET_SYSERR; 549 return GNUNET_SYSERR;
550 } 550 }
551 if (NULL == topology_file ||
552 GNUNET_YES != GNUNET_DISK_file_test (topology_file))
553 {
554 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
555 _("Missing or invalid topology file.\n"));
556 return GNUNET_SYSERR;
557 }
551 return GNUNET_OK; 558 return GNUNET_OK;
552} 559}
553 560
@@ -565,7 +572,6 @@ run (void *cls, char *const *args, const char *cf,
565 const struct GNUNET_CONFIGURATION_Handle *c) 572 const struct GNUNET_CONFIGURATION_Handle *c)
566{ 573{
567 struct GNUNET_CONFIGURATION_Handle *cfg; 574 struct GNUNET_CONFIGURATION_Handle *cfg;
568 double links;
569 575
570 if (GNUNET_OK != verify_args ()) 576 if (GNUNET_OK != verify_args ())
571 { 577 {
@@ -574,10 +580,10 @@ run (void *cls, char *const *args, const char *cf,
574 } 580 }
575 cfg = GNUNET_CONFIGURATION_create (); 581 cfg = GNUNET_CONFIGURATION_create ();
576 GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (cfg, cfg_filename)); 582 GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (cfg, cfg_filename));
577 links = log (num_peers) * log (num_peers) * num_peers / 2; 583 GNUNET_CONFIGURATION_set_value_string ((struct GNUNET_CONFIGURATION_Handle *)
578 GNUNET_CONFIGURATION_set_value_number ((struct GNUNET_CONFIGURATION_Handle *) 584 cfg, "TESTBED",
579 cfg, "TESTBED", "OVERLAY_RANDOM_LINKS", 585 "OVERLAY_TOPOLOGY_FILE",
580 (unsigned long long int) links); 586 topology_file);
581 GNUNET_TESTBED_run (NULL, cfg, num_peers, 0, NULL, NULL, &test_master, NULL); 587 GNUNET_TESTBED_run (NULL, cfg, num_peers, 0, NULL, NULL, &test_master, NULL);
582 GNUNET_CONFIGURATION_destroy (cfg); 588 GNUNET_CONFIGURATION_destroy (cfg);
583} 589}
@@ -594,6 +600,8 @@ main (int argc, char *const *argv)
594 static struct GNUNET_GETOPT_CommandLineOption options[] = { 600 static struct GNUNET_GETOPT_CommandLineOption options[] = {
595 {'p', "peers", "COUNT", gettext_noop ("Number of peers to run"), GNUNET_YES, 601 {'p', "peers", "COUNT", gettext_noop ("Number of peers to run"), GNUNET_YES,
596 &GNUNET_GETOPT_set_uint, &num_peers}, 602 &GNUNET_GETOPT_set_uint, &num_peers},
603 {'t', "topology-file", "FILEPATH", gettext_noop ("Path to topology file"),
604 GNUNET_YES, &GNUNET_GETOPT_set_filename, &topology_file},
597 {'i', "sensors-interval", "INTERVAL", 605 {'i', "sensors-interval", "INTERVAL",
598 gettext_noop ("Change the interval or running sensors to given value"), 606 gettext_noop ("Change the interval or running sensors to given value"),
599 GNUNET_YES, &GNUNET_GETOPT_set_uint, &sensors_interval}, 607 GNUNET_YES, &GNUNET_GETOPT_set_uint, &sensors_interval},
diff --git a/src/sensor/gnunet-sensor-profiler.conf b/src/sensor/gnunet-sensor-profiler.conf
index 977d8dcbf..34a0f41b2 100644
--- a/src/sensor/gnunet-sensor-profiler.conf
+++ b/src/sensor/gnunet-sensor-profiler.conf
@@ -1,6 +1,5 @@
1[testbed] 1[testbed]
2OVERLAY_TOPOLOGY = RANDOM 2OVERLAY_TOPOLOGY = FROM_FILE
3#OVERLAY_RANDOM_LINKS = 1000
4 3
5[arm] 4[arm]
6DEFAULTSERVICES = topology dht cadet 5DEFAULTSERVICES = topology dht cadet