aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSree Harsha Totakura <totakura@in.tum.de>2014-07-24 15:18:37 +0000
committerSree Harsha Totakura <totakura@in.tum.de>2014-07-24 15:18:37 +0000
commite77ffe8825f2f22478ab8e26f2edb6a309c3fb0a (patch)
tree1e8c3879ecc76b11e608f9d9e53b48f6603ca12d /src
parenteaeb4e371a1ad8d3a7b3b85ad54e99afdfc106d9 (diff)
downloadgnunet-e77ffe8825f2f22478ab8e26f2edb6a309c3fb0a.tar.gz
gnunet-e77ffe8825f2f22478ab8e26f2edb6a309c3fb0a.zip
xdht: track topology successor and predecessor neighbours.
Diffstat (limited to 'src')
-rw-r--r--src/dht/gnunet-service-xdht.c14
-rw-r--r--src/dht/gnunet-service-xdht_neighbours.c28
2 files changed, 39 insertions, 3 deletions
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;
77 */ 77 */
78struct GNUNET_TIME_Relative hello_expiration; 78struct GNUNET_TIME_Relative hello_expiration;
79 79
80/**
81 * Should we store our topology predecessor and successor IDs into statistics?
82 */
83extern unsigned int track_topology;
84
80#if ENABLE_MALICIOUS 85#if ENABLE_MALICIOUS
81/** 86/**
82 * Should this peer act malicious? 87 * Should this peer act malicious?
@@ -153,6 +158,7 @@ static void
153run (void *cls, struct GNUNET_SERVER_Handle *server, 158run (void *cls, struct GNUNET_SERVER_Handle *server,
154 const struct GNUNET_CONFIGURATION_Handle *c) 159 const struct GNUNET_CONFIGURATION_Handle *c)
155{ 160{
161 unsigned long long _track_topology;
156 GDS_cfg = c; 162 GDS_cfg = c;
157 if (GNUNET_OK != 163 if (GNUNET_OK !=
158 GNUNET_CONFIGURATION_get_value_time (c, "transport", "HELLO_EXPIRATION", &hello_expiration)) 164 GNUNET_CONFIGURATION_get_value_time (c, "transport", "HELLO_EXPIRATION", &hello_expiration))
@@ -161,13 +167,17 @@ run (void *cls, struct GNUNET_SERVER_Handle *server,
161 } 167 }
162 GDS_block_context = GNUNET_BLOCK_context_create (GDS_cfg); 168 GDS_block_context = GNUNET_BLOCK_context_create (GDS_cfg);
163 GDS_stats = GNUNET_STATISTICS_create ("dht", GDS_cfg); 169 GDS_stats = GNUNET_STATISTICS_create ("dht", GDS_cfg);
164
165 GDS_ROUTING_init (); 170 GDS_ROUTING_init ();
166 GDS_NSE_init (); 171 GDS_NSE_init ();
167 GDS_DATACACHE_init (); 172 GDS_DATACACHE_init ();
168 GDS_HELLO_init (); 173 GDS_HELLO_init ();
169 GDS_CLIENTS_init (server); 174 GDS_CLIENTS_init (server);
170 175 if (GNUNET_OK ==
176 GNUNET_CONFIGURATION_get_value_number (c, "xdht", "track_toplogy",
177 &_track_topology))
178 {
179 track_topology = (unsigned int) _track_topology;
180 }
171 if (GNUNET_OK != GDS_NEIGHBOURS_init ()) 181 if (GNUNET_OK != GDS_NEIGHBOURS_init ())
172 { 182 {
173 shutdown_task (NULL, NULL); 183 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
@@ -860,6 +860,11 @@ static struct FingerInfo finger_table [MAX_FINGERS];
860static struct GNUNET_CORE_Handle *core_api; 860static struct GNUNET_CORE_Handle *core_api;
861 861
862/** 862/**
863 * Handle for the statistics service.
864 */
865extern struct GNUNET_STATISTICS_Handle *GDS_stats;
866
867/**
863 * The current finger index that we have want to find trail to. We start the 868 * The current finger index that we have want to find trail to. We start the
864 * search with value = 0, i.e. successor and then go to PREDCESSOR_FINGER_ID 869 * search with value = 0, i.e. successor and then go to PREDCESSOR_FINGER_ID
865 * and decrement it. For any index 63 <= index < 0, if finger is same as successor, 870 * and decrement it. For any index 63 <= index < 0, if finger is same as successor,
@@ -867,6 +872,11 @@ static struct GNUNET_CORE_Handle *core_api;
867 */ 872 */
868static unsigned int current_search_finger_index; 873static unsigned int current_search_finger_index;
869 874
875/**
876 * Should we store our topology predecessor and successor IDs into statistics?
877 */
878unsigned int track_topology;
879
870 880
871/** 881/**
872 * Called when core is ready to send a message we asked for 882 * Called when core is ready to send a message we asked for
@@ -3386,6 +3396,22 @@ finger_table_add (struct GNUNET_PeerIdentity finger_identity,
3386 GDS_ROUTING_SRC_TO_DEST, 3396 GDS_ROUTING_SRC_TO_DEST,
3387 finger_identity); 3397 finger_identity);
3388 } 3398 }
3399 /* Store the successor for path tracking */
3400 if (track_topology && (NULL != GDS_stats) && (0 == finger_table_index))
3401 {
3402 char *my_id_str;
3403 char *succ_id_str;
3404 char *key;
3405
3406 my_id_str = GNUNET_strdup (GNUNET_i2s (&my_identity));
3407 succ_id_str = GNUNET_strdup (GNUNET_i2s
3408 (&existing_finger->finger_identity));
3409 GNUNET_asprintf (&key, "XDHT:0:%.4s:%.4s", my_id_str, succ_id_str);
3410 GNUNET_free (my_id_str);
3411 GNUNET_free (succ_id_str);
3412 GNUNET_STATISTICS_update (GDS_stats, "key", 1, 0);
3413 GNUNET_free (key);
3414 }
3389 } 3415 }
3390 } 3416 }
3391 else 3417 else
@@ -5653,4 +5679,4 @@ GDS_NEIGHBOURS_get_my_id (void)
5653 return my_identity; 5679 return my_identity;
5654} 5680}
5655 5681
5656/* end of gnunet-service-xdht_neighbours.c */ \ No newline at end of file 5682/* end of gnunet-service-xdht_neighbours.c */