From: Sree Harsha Totakura Date: Thu, 24 Jul 2014 15:18:37 +0000 (+0000) Subject: xdht: track topology successor and predecessor neighbours. X-Git-Tag: initial-import-from-subversion-38251~3396 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=e77ffe8825f2f22478ab8e26f2edb6a309c3fb0a;p=oweals%2Fgnunet.git xdht: track topology successor and predecessor neighbours. --- diff --git a/src/dht/gnunet-service-xdht.c b/src/dht/gnunet-service-xdht.c index 40aa71a0f..c8bc11686 100644 --- a/src/dht/gnunet-service-xdht.c +++ b/src/dht/gnunet-service-xdht.c @@ -77,6 +77,11 @@ static struct GNUNET_TRANSPORT_GetHelloHandle *ghh; */ struct GNUNET_TIME_Relative hello_expiration; +/** + * Should we store our topology predecessor and successor IDs into statistics? + */ +extern unsigned int track_topology; + #if ENABLE_MALICIOUS /** * Should this peer act malicious? @@ -153,6 +158,7 @@ static void run (void *cls, struct GNUNET_SERVER_Handle *server, const struct GNUNET_CONFIGURATION_Handle *c) { + unsigned long long _track_topology; GDS_cfg = c; if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_time (c, "transport", "HELLO_EXPIRATION", &hello_expiration)) @@ -161,13 +167,17 @@ run (void *cls, struct GNUNET_SERVER_Handle *server, } GDS_block_context = GNUNET_BLOCK_context_create (GDS_cfg); GDS_stats = GNUNET_STATISTICS_create ("dht", GDS_cfg); - GDS_ROUTING_init (); GDS_NSE_init (); GDS_DATACACHE_init (); GDS_HELLO_init (); GDS_CLIENTS_init (server); - + if (GNUNET_OK == + GNUNET_CONFIGURATION_get_value_number (c, "xdht", "track_toplogy", + &_track_topology)) + { + track_topology = (unsigned int) _track_topology; + } if (GNUNET_OK != GDS_NEIGHBOURS_init ()) { shutdown_task (NULL, NULL); diff --git a/src/dht/gnunet-service-xdht_neighbours.c b/src/dht/gnunet-service-xdht_neighbours.c index 97e983b56..d8b52b0e8 100644 --- a/src/dht/gnunet-service-xdht_neighbours.c +++ b/src/dht/gnunet-service-xdht_neighbours.c @@ -859,6 +859,11 @@ static struct FingerInfo finger_table [MAX_FINGERS]; */ static struct GNUNET_CORE_Handle *core_api; +/** + * Handle for the statistics service. + */ +extern struct GNUNET_STATISTICS_Handle *GDS_stats; + /** * The current finger index that we have want to find trail to. We start the * search with value = 0, i.e. successor and then go to PREDCESSOR_FINGER_ID @@ -867,6 +872,11 @@ static struct GNUNET_CORE_Handle *core_api; */ static unsigned int current_search_finger_index; +/** + * Should we store our topology predecessor and successor IDs into statistics? + */ +unsigned int track_topology; + /** * Called when core is ready to send a message we asked for @@ -3386,6 +3396,22 @@ finger_table_add (struct GNUNET_PeerIdentity finger_identity, GDS_ROUTING_SRC_TO_DEST, finger_identity); } + /* Store the successor for path tracking */ + if (track_topology && (NULL != GDS_stats) && (0 == finger_table_index)) + { + char *my_id_str; + char *succ_id_str; + char *key; + + my_id_str = GNUNET_strdup (GNUNET_i2s (&my_identity)); + succ_id_str = GNUNET_strdup (GNUNET_i2s + (&existing_finger->finger_identity)); + GNUNET_asprintf (&key, "XDHT:0:%.4s:%.4s", my_id_str, succ_id_str); + GNUNET_free (my_id_str); + GNUNET_free (succ_id_str); + GNUNET_STATISTICS_update (GDS_stats, "key", 1, 0); + GNUNET_free (key); + } } } else @@ -5653,4 +5679,4 @@ GDS_NEIGHBOURS_get_my_id (void) return my_identity; } -/* end of gnunet-service-xdht_neighbours.c */ \ No newline at end of file +/* end of gnunet-service-xdht_neighbours.c */