aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSupriti Singh <supritisingh08@gmail.com>2014-08-07 14:17:48 +0000
committerSupriti Singh <supritisingh08@gmail.com>2014-08-07 14:17:48 +0000
commitd6e728b2b869ee521216deae75a767165d3e1001 (patch)
tree3c33a5a2068782e32a188ad5471ddb74b338ac3f /src
parent9ea2094c766b8a62bcfb8eebbda7746009750387 (diff)
downloadgnunet-d6e728b2b869ee521216deae75a767165d3e1001.tar.gz
gnunet-d6e728b2b869ee521216deae75a767165d3e1001.zip
- Collect bandwidth statistics in profiler
- Get average put/get length in profiler - Check for GNUNET_CONSTANTS_MAX_ENCRYPTED_MESSAGE_SIZE,instead of GNUNET_SERVER_MAX_MESSAGE_SIZE
Diffstat (limited to 'src')
-rw-r--r--src/dht/gnunet-service-xdht.c2
-rw-r--r--src/dht/gnunet-service-xdht_neighbours.c111
-rw-r--r--src/dht/gnunet_dht_profiler.c190
3 files changed, 165 insertions, 138 deletions
diff --git a/src/dht/gnunet-service-xdht.c b/src/dht/gnunet-service-xdht.c
index 3f44c2a69..61f534988 100644
--- a/src/dht/gnunet-service-xdht.c
+++ b/src/dht/gnunet-service-xdht.c
@@ -168,7 +168,7 @@ run (void *cls, struct GNUNET_SERVER_Handle *server,
168 GDS_block_context = GNUNET_BLOCK_context_create (GDS_cfg); 168 GDS_block_context = GNUNET_BLOCK_context_create (GDS_cfg);
169 GDS_stats = GNUNET_STATISTICS_create ("dht", GDS_cfg); 169 GDS_stats = GNUNET_STATISTICS_create ("dht", GDS_cfg);
170 GDS_ROUTING_init (); 170 GDS_ROUTING_init ();
171 GDS_NSE_init (); //FIXME:not used in x0vine, remove 171 GDS_NSE_init ();
172 GDS_DATACACHE_init (); 172 GDS_DATACACHE_init ();
173 GDS_HELLO_init (); 173 GDS_HELLO_init ();
174 GDS_CLIENTS_init (server); 174 GDS_CLIENTS_init (server);
diff --git a/src/dht/gnunet-service-xdht_neighbours.c b/src/dht/gnunet-service-xdht_neighbours.c
index 3f280134e..139d1971b 100644
--- a/src/dht/gnunet-service-xdht_neighbours.c
+++ b/src/dht/gnunet-service-xdht_neighbours.c
@@ -936,10 +936,10 @@ core_transmit_notify (void *cls, size_t size, void *buf)
936 while ((NULL != (pending = peer->head)) && 936 while ((NULL != (pending = peer->head)) &&
937 (size - off >= (msize = ntohs (pending->msg->size)))) 937 (size - off >= (msize = ntohs (pending->msg->size))))
938 { 938 {
939 /*GNUNET_STATISTICS_update (GDS_stats, 939 GNUNET_STATISTICS_update (GDS_stats,
940 gettext_noop 940 gettext_noop
941 ("# Bytes transmitted to other peers"), msize, 941 ("# Bytes transmitted to other peers"), msize,
942 GNUNET_NO);*/ 942 GNUNET_NO);
943 memcpy (&cbuf[off], pending->msg, msize); 943 memcpy (&cbuf[off], pending->msg, msize);
944 off += msize; 944 off += msize;
945 peer->pending_count--; 945 peer->pending_count--;
@@ -978,11 +978,7 @@ process_friend_queue (struct FriendInfo *peer)
978 { 978 {
979 return; 979 return;
980 } 980 }
981 GNUNET_STATISTICS_update (GDS_stats, 981
982 gettext_noop
983 ("# Bytes of bandwidth requested from core"),
984 ntohs (pending->msg->size), GNUNET_NO);
985
986 peer->th = 982 peer->th =
987 GNUNET_CORE_notify_transmit_ready (core_api, GNUNET_NO, 983 GNUNET_CORE_notify_transmit_ready (core_api, GNUNET_NO,
988 pending->importance, 984 pending->importance,
@@ -1030,7 +1026,7 @@ GDS_NEIGHBOURS_send_trail_setup (struct GNUNET_PeerIdentity source_peer,
1030 msize = sizeof (struct PeerTrailSetupMessage) + 1026 msize = sizeof (struct PeerTrailSetupMessage) +
1031 (trail_length * sizeof (struct GNUNET_PeerIdentity)); 1027 (trail_length * sizeof (struct GNUNET_PeerIdentity));
1032 1028
1033 if (msize >= GNUNET_SERVER_MAX_MESSAGE_SIZE) 1029 if (msize >= GNUNET_CONSTANTS_MAX_ENCRYPTED_MESSAGE_SIZE)
1034 { 1030 {
1035 GNUNET_break (0); 1031 GNUNET_break (0);
1036 return; 1032 return;
@@ -1099,7 +1095,7 @@ GDS_NEIGHBOURS_send_trail_setup_result (struct GNUNET_PeerIdentity querying_peer
1099 msize = sizeof (struct PeerTrailSetupResultMessage) + 1095 msize = sizeof (struct PeerTrailSetupResultMessage) +
1100 (trail_length * sizeof (struct GNUNET_PeerIdentity)); 1096 (trail_length * sizeof (struct GNUNET_PeerIdentity));
1101 1097
1102 if (msize >= GNUNET_SERVER_MAX_MESSAGE_SIZE) 1098 if (msize >= GNUNET_CONSTANTS_MAX_ENCRYPTED_MESSAGE_SIZE)
1103 { 1099 {
1104 GNUNET_break (0); 1100 GNUNET_break (0);
1105 return; 1101 return;
@@ -1171,7 +1167,7 @@ GDS_NEIGHBOURS_send_trail_rejection (struct GNUNET_PeerIdentity source_peer,
1171 msize = sizeof (struct PeerTrailRejectionMessage) + 1167 msize = sizeof (struct PeerTrailRejectionMessage) +
1172 (trail_length * sizeof (struct GNUNET_PeerIdentity)); 1168 (trail_length * sizeof (struct GNUNET_PeerIdentity));
1173 1169
1174 if (msize >= GNUNET_SERVER_MAX_MESSAGE_SIZE) 1170 if (msize >= GNUNET_CONSTANTS_MAX_ENCRYPTED_MESSAGE_SIZE)
1175 { 1171 {
1176 GNUNET_break (0); 1172 GNUNET_break (0);
1177 return; 1173 return;
@@ -1237,7 +1233,7 @@ GDS_NEIGHBOURS_send_verify_successor_message (struct GNUNET_PeerIdentity source_
1237 1233
1238 msize = sizeof (struct PeerVerifySuccessorMessage) + 1234 msize = sizeof (struct PeerVerifySuccessorMessage) +
1239 (trail_length * sizeof (struct GNUNET_PeerIdentity));; 1235 (trail_length * sizeof (struct GNUNET_PeerIdentity));;
1240 if (msize >= GNUNET_SERVER_MAX_MESSAGE_SIZE) 1236 if (msize >= GNUNET_CONSTANTS_MAX_ENCRYPTED_MESSAGE_SIZE)
1241 { 1237 {
1242 GNUNET_break (0); 1238 GNUNET_break (0);
1243 return; 1239 return;
@@ -1291,7 +1287,7 @@ GDS_NEIGHBOURS_send_trail_teardown (struct GNUNET_HashCode trail_id,
1291 1287
1292 msize = sizeof (struct PeerTrailTearDownMessage); 1288 msize = sizeof (struct PeerTrailTearDownMessage);
1293 1289
1294 if (msize >= GNUNET_SERVER_MAX_MESSAGE_SIZE) 1290 if (msize >= GNUNET_CONSTANTS_MAX_ENCRYPTED_MESSAGE_SIZE)
1295 { 1291 {
1296 GNUNET_break (0); 1292 GNUNET_break (0);
1297 return; 1293 return;
@@ -1358,7 +1354,7 @@ GDS_NEIGHBOURS_send_verify_successor_result (struct GNUNET_PeerIdentity querying
1358 msize = sizeof (struct PeerVerifySuccessorResultMessage) + 1354 msize = sizeof (struct PeerVerifySuccessorResultMessage) +
1359 (trail_length * sizeof(struct GNUNET_PeerIdentity)); 1355 (trail_length * sizeof(struct GNUNET_PeerIdentity));
1360 1356
1361 if (msize >= GNUNET_SERVER_MAX_MESSAGE_SIZE) 1357 if (msize >= GNUNET_CONSTANTS_MAX_ENCRYPTED_MESSAGE_SIZE)
1362 { 1358 {
1363 GNUNET_break (0); 1359 GNUNET_break (0);
1364 return; 1360 return;
@@ -1420,7 +1416,7 @@ GDS_NEIGHBOURS_send_notify_new_successor (struct GNUNET_PeerIdentity source_peer
1420 msize = sizeof (struct PeerNotifyNewSuccessorMessage) + 1416 msize = sizeof (struct PeerNotifyNewSuccessorMessage) +
1421 (successor_trail_length * sizeof(struct GNUNET_PeerIdentity)); 1417 (successor_trail_length * sizeof(struct GNUNET_PeerIdentity));
1422 1418
1423 if (msize >= GNUNET_SERVER_MAX_MESSAGE_SIZE) 1419 if (msize >= GNUNET_CONSTANTS_MAX_ENCRYPTED_MESSAGE_SIZE)
1424 { 1420 {
1425 GNUNET_break (0); 1421 GNUNET_break (0);
1426 return; 1422 return;
@@ -1481,7 +1477,7 @@ GDS_NEIGHBOURS_send_add_trail (struct GNUNET_PeerIdentity source_peer,
1481 msize = sizeof (struct PeerAddTrailMessage) + 1477 msize = sizeof (struct PeerAddTrailMessage) +
1482 (trail_length * sizeof(struct GNUNET_PeerIdentity)); 1478 (trail_length * sizeof(struct GNUNET_PeerIdentity));
1483 1479
1484 if (msize >= GNUNET_SERVER_MAX_MESSAGE_SIZE) 1480 if (msize >= GNUNET_CONSTANTS_MAX_ENCRYPTED_MESSAGE_SIZE)
1485 { 1481 {
1486 GNUNET_break (0); 1482 GNUNET_break (0);
1487 return; 1483 return;
@@ -1533,7 +1529,7 @@ GDS_NEIGHBOURS_send_trail_compression (struct GNUNET_PeerIdentity source_peer,
1533 1529
1534 msize = sizeof (struct PeerTrailCompressionMessage); 1530 msize = sizeof (struct PeerTrailCompressionMessage);
1535 1531
1536 if (msize >= GNUNET_SERVER_MAX_MESSAGE_SIZE) 1532 if (msize >= GNUNET_CONSTANTS_MAX_ENCRYPTED_MESSAGE_SIZE)
1537 { 1533 {
1538 GNUNET_break (0); 1534 GNUNET_break (0);
1539 return; 1535 return;
@@ -2113,13 +2109,13 @@ GDS_NEIGHBOURS_send_put (const struct GNUNET_HashCode *key,
2113 msize = put_path_length * sizeof (struct GNUNET_PeerIdentity) + data_size + 2109 msize = put_path_length * sizeof (struct GNUNET_PeerIdentity) + data_size +
2114 sizeof (struct PeerPutMessage); 2110 sizeof (struct PeerPutMessage);
2115 2111
2116 if (msize >= GNUNET_SERVER_MAX_MESSAGE_SIZE) 2112 if (msize >= GNUNET_CONSTANTS_MAX_ENCRYPTED_MESSAGE_SIZE)
2117 { 2113 {
2118 put_path_length = 0; 2114 put_path_length = 0;
2119 msize = data_size + sizeof (struct PeerPutMessage); 2115 msize = data_size + sizeof (struct PeerPutMessage);
2120 } 2116 }
2121 2117
2122 if (msize >= GNUNET_SERVER_MAX_MESSAGE_SIZE) 2118 if (msize >= GNUNET_CONSTANTS_MAX_ENCRYPTED_MESSAGE_SIZE)
2123 { 2119 {
2124 GNUNET_break (0); 2120 GNUNET_break (0);
2125 return; 2121 return;
@@ -2227,7 +2223,7 @@ GDS_NEIGHBOURS_send_get (const struct GNUNET_HashCode *key,
2227 2223
2228 /* In this case we don't make get_path_length = 0, as we need get path to 2224 /* In this case we don't make get_path_length = 0, as we need get path to
2229 * return the message back to querying client. */ 2225 * return the message back to querying client. */
2230 if (msize >= GNUNET_SERVER_MAX_MESSAGE_SIZE) 2226 if (msize >= GNUNET_CONSTANTS_MAX_ENCRYPTED_MESSAGE_SIZE)
2231 { 2227 {
2232 GNUNET_break (0); 2228 GNUNET_break (0);
2233 return; 2229 return;
@@ -2333,12 +2329,19 @@ GDS_NEIGHBOURS_send_get_result (const struct GNUNET_HashCode *key,
2333 data_size + 2329 data_size +
2334 sizeof (struct PeerGetResultMessage); 2330 sizeof (struct PeerGetResultMessage);
2335 2331
2336 if (msize >= GNUNET_SERVER_MAX_MESSAGE_SIZE) 2332 if (msize >= GNUNET_CONSTANTS_MAX_ENCRYPTED_MESSAGE_SIZE)
2337 { 2333 {
2338 GNUNET_break (0); 2334 put_path_length = 0;
2335 msize = msize - put_path_length;
2339 return; 2336 return;
2340 } 2337 }
2341 2338
2339 if (msize >= GNUNET_CONSTANTS_MAX_ENCRYPTED_MESSAGE_SIZE)
2340 {
2341 GNUNET_break(0);
2342 return;
2343 }
2344
2342 current_path_index = 0; 2345 current_path_index = 0;
2343 if(get_path_length > 0) 2346 if(get_path_length > 0)
2344 { 2347 {
@@ -3518,6 +3521,11 @@ handle_dht_p2p_put (void *cls, const struct GNUNET_PeerIdentity *peer,
3518 return GNUNET_OK; 3521 return GNUNET_OK;
3519 } 3522 }
3520 3523
3524 GNUNET_STATISTICS_update (GDS_stats,
3525 gettext_noop
3526 ("# Bytes received from other peers"), (int64_t) msize,
3527 GNUNET_NO);
3528
3521 best_known_dest = put->best_known_destination; 3529 best_known_dest = put->best_known_destination;
3522 put_path = (struct GNUNET_PeerIdentity *) &put[1]; 3530 put_path = (struct GNUNET_PeerIdentity *) &put[1];
3523 payload = &put_path[putlen]; 3531 payload = &put_path[putlen];
@@ -3687,6 +3695,11 @@ handle_dht_p2p_get (void *cls, const struct GNUNET_PeerIdentity *peer,
3687 return GNUNET_YES; 3695 return GNUNET_YES;
3688 } 3696 }
3689 3697
3698 GNUNET_STATISTICS_update (GDS_stats,
3699 gettext_noop
3700 ("# Bytes received from other peers"), msize,
3701 GNUNET_NO);
3702
3690 /* Add sender to get path */ 3703 /* Add sender to get path */
3691 struct GNUNET_PeerIdentity gp[get_length + 1]; 3704 struct GNUNET_PeerIdentity gp[get_length + 1];
3692 if (get_length > 0) 3705 if (get_length > 0)
@@ -3795,6 +3808,11 @@ handle_dht_p2p_get_result (void *cls, const struct GNUNET_PeerIdentity *peer,
3795 return GNUNET_YES; 3808 return GNUNET_YES;
3796 } 3809 }
3797 3810
3811 GNUNET_STATISTICS_update (GDS_stats,
3812 gettext_noop
3813 ("# Bytes received from other peers"), msize,
3814 GNUNET_NO);
3815
3798 put_path = (const struct GNUNET_PeerIdentity *) &get_result[1]; 3816 put_path = (const struct GNUNET_PeerIdentity *) &get_result[1];
3799 get_path = &put_path[putlen]; 3817 get_path = &put_path[putlen];
3800 payload = (const void *) &get_path[getlen]; 3818 payload = (const void *) &get_path[getlen];
@@ -3930,6 +3948,11 @@ handle_dht_p2p_trail_setup (void *cls, const struct GNUNET_PeerIdentity *peer,
3930 return GNUNET_OK; 3948 return GNUNET_OK;
3931 } 3949 }
3932 3950
3951 GNUNET_STATISTICS_update (GDS_stats,
3952 gettext_noop
3953 ("# Bytes received from other peers"), msize,
3954 GNUNET_NO);
3955
3933 trail_peer_list = (const struct GNUNET_PeerIdentity *)&trail_setup[1]; 3956 trail_peer_list = (const struct GNUNET_PeerIdentity *)&trail_setup[1];
3934 current_dest = trail_setup->best_known_destination; 3957 current_dest = trail_setup->best_known_destination;
3935 trail_id = trail_setup->trail_id; 3958 trail_id = trail_setup->trail_id;
@@ -4187,6 +4210,11 @@ handle_dht_p2p_trail_setup_result(void *cls, const struct GNUNET_PeerIdentity *p
4187 return GNUNET_OK; 4210 return GNUNET_OK;
4188 } 4211 }
4189 4212
4213 GNUNET_STATISTICS_update (GDS_stats,
4214 gettext_noop
4215 ("# Bytes received from other peers"), msize,
4216 GNUNET_NO);
4217
4190 is_predecessor = ntohl (trail_result->is_predecessor); 4218 is_predecessor = ntohl (trail_result->is_predecessor);
4191 querying_peer = trail_result->querying_peer; 4219 querying_peer = trail_result->querying_peer;
4192 finger_identity = trail_result->finger_identity; 4220 finger_identity = trail_result->finger_identity;
@@ -4693,12 +4721,17 @@ handle_dht_p2p_verify_successor(void *cls,
4693 GNUNET_break_op (0); 4721 GNUNET_break_op (0);
4694 return GNUNET_OK; 4722 return GNUNET_OK;
4695 } 4723 }
4696 4724
4725 GNUNET_STATISTICS_update (GDS_stats,
4726 gettext_noop
4727 ("# Bytes received from other peers"), msize,
4728 GNUNET_NO);
4729
4697 trail_id = vsm->trail_id; 4730 trail_id = vsm->trail_id;
4698 source_peer = vsm->source_peer; 4731 source_peer = vsm->source_peer;
4699 successor = vsm->successor; 4732 successor = vsm->successor;
4700 trail = (struct GNUNET_PeerIdentity *)&vsm[1]; 4733 trail = (struct GNUNET_PeerIdentity *)&vsm[1];
4701 4734
4702 4735
4703 /* I am NOT the successor of source_peer. Pass the message to next_hop on 4736 /* I am NOT the successor of source_peer. Pass the message to next_hop on
4704 * the trail. */ 4737 * the trail. */
@@ -5024,6 +5057,11 @@ handle_dht_p2p_verify_successor_result(void *cls,
5024 return GNUNET_OK; 5057 return GNUNET_OK;
5025 } 5058 }
5026 5059
5060 GNUNET_STATISTICS_update (GDS_stats,
5061 gettext_noop
5062 ("# Bytes received from other peers"), msize,
5063 GNUNET_NO);
5064
5027 trail = (const struct GNUNET_PeerIdentity *) &vsrm[1]; 5065 trail = (const struct GNUNET_PeerIdentity *) &vsrm[1];
5028 querying_peer = vsrm->querying_peer; 5066 querying_peer = vsrm->querying_peer;
5029 trail_direction = ntohl (vsrm->trail_direction); 5067 trail_direction = ntohl (vsrm->trail_direction);
@@ -5098,6 +5136,11 @@ handle_dht_p2p_notify_new_successor(void *cls,
5098 return GNUNET_OK; 5136 return GNUNET_OK;
5099 } 5137 }
5100 5138
5139 GNUNET_STATISTICS_update (GDS_stats,
5140 gettext_noop
5141 ("# Bytes received from other peers"), msize,
5142 GNUNET_NO);
5143
5101 trail = (struct GNUNET_PeerIdentity *) &nsm[1]; 5144 trail = (struct GNUNET_PeerIdentity *) &nsm[1];
5102 source = nsm->source_peer; 5145 source = nsm->source_peer;
5103 new_successor = nsm->new_successor; 5146 new_successor = nsm->new_successor;
@@ -5189,7 +5232,12 @@ handle_dht_p2p_trail_setup_rejection (void *cls,
5189 GNUNET_break_op (0); 5232 GNUNET_break_op (0);
5190 return GNUNET_OK; 5233 return GNUNET_OK;
5191 } 5234 }
5192 5235
5236 GNUNET_STATISTICS_update (GDS_stats,
5237 gettext_noop
5238 ("# Bytes received from other peers"), msize,
5239 GNUNET_NO);
5240
5193 trail_peer_list = (const struct GNUNET_PeerIdentity *)&trail_rejection[1]; 5241 trail_peer_list = (const struct GNUNET_PeerIdentity *)&trail_rejection[1];
5194 is_predecessor = ntohl (trail_rejection->is_predecessor); 5242 is_predecessor = ntohl (trail_rejection->is_predecessor);
5195 congestion_timeout = trail_rejection->congestion_time; 5243 congestion_timeout = trail_rejection->congestion_time;
@@ -5318,6 +5366,11 @@ handle_dht_p2p_trail_compression (void *cls, const struct GNUNET_PeerIdentity *p
5318 return GNUNET_OK; 5366 return GNUNET_OK;
5319 } 5367 }
5320 5368
5369 GNUNET_STATISTICS_update (GDS_stats,
5370 gettext_noop
5371 ("# Bytes received from other peers"), msize,
5372 GNUNET_NO);
5373
5321 trail_compression = (const struct PeerTrailCompressionMessage *) message; 5374 trail_compression = (const struct PeerTrailCompressionMessage *) message;
5322 trail_id = trail_compression->trail_id; 5375 trail_id = trail_compression->trail_id;
5323 5376
@@ -5385,6 +5438,11 @@ handle_dht_p2p_trail_teardown (void *cls, const struct GNUNET_PeerIdentity *peer
5385 return GNUNET_OK; 5438 return GNUNET_OK;
5386 } 5439 }
5387 5440
5441 GNUNET_STATISTICS_update (GDS_stats,
5442 gettext_noop
5443 ("# Bytes received from other peers"), msize,
5444 GNUNET_NO);
5445
5388 trail_teardown = (const struct PeerTrailTearDownMessage *) message; 5446 trail_teardown = (const struct PeerTrailTearDownMessage *) message;
5389 trail_direction = ntohl (trail_teardown->trail_direction); 5447 trail_direction = ntohl (trail_teardown->trail_direction);
5390 trail_id = trail_teardown->trail_id; 5448 trail_id = trail_teardown->trail_id;
@@ -5468,6 +5526,11 @@ handle_dht_p2p_add_trail (void *cls, const struct GNUNET_PeerIdentity *peer,
5468 return GNUNET_OK; 5526 return GNUNET_OK;
5469 } 5527 }
5470 5528
5529 GNUNET_STATISTICS_update (GDS_stats,
5530 gettext_noop
5531 ("# Bytes received from other peers"), msize,
5532 GNUNET_NO);
5533
5471 trail = (const struct GNUNET_PeerIdentity *)&add_trail[1]; 5534 trail = (const struct GNUNET_PeerIdentity *)&add_trail[1];
5472 destination_peer = add_trail->destination_peer; 5535 destination_peer = add_trail->destination_peer;
5473 source_peer = add_trail->source_peer; 5536 source_peer = add_trail->source_peer;
diff --git a/src/dht/gnunet_dht_profiler.c b/src/dht/gnunet_dht_profiler.c
index f88749524..95528b3f9 100644
--- a/src/dht/gnunet_dht_profiler.c
+++ b/src/dht/gnunet_dht_profiler.c
@@ -205,7 +205,6 @@ static unsigned int n_gets_fail;
205 */ 205 */
206static unsigned int replication; 206static unsigned int replication;
207 207
208#if 0
209/** 208/**
210 * Testbed Operation (to get stats). 209 * Testbed Operation (to get stats).
211 */ 210 */
@@ -215,7 +214,30 @@ static struct GNUNET_TESTBED_Operation *stats_op;
215 * Testbed peer handles. 214 * Testbed peer handles.
216 */ 215 */
217static struct GNUNET_TESTBED_Peer **testbed_handles; 216static struct GNUNET_TESTBED_Peer **testbed_handles;
218#endif 217
218/**
219 * Total number of messages sent by peer.
220 */
221static uint64_t outgoing_bandwidth;
222
223/**
224 * Total number of messages received by peer.
225 */
226static uint64_t incoming_bandwidth;
227
228/**
229 * Average number of hops taken to do put.
230 */
231static unsigned int average_put_path_length;
232
233/**
234 * Average number of hops taken to do get.
235 */
236static unsigned int average_get_path_length;
237
238static unsigned int total_put_path_length;
239
240static unsigned int total_get_path_length;
219/** 241/**
220 * Shutdown task. Cleanup all resources and operations. 242 * Shutdown task. Cleanup all resources and operations.
221 * 243 *
@@ -251,10 +273,13 @@ do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
251 GNUNET_free (a_ctx); 273 GNUNET_free (a_ctx);
252 a_ctx = NULL; 274 a_ctx = NULL;
253 } 275 }
276 if(NULL != stats_op)
277 GNUNET_TESTBED_operation_done (stats_op);
278 stats_op = NULL;
254 GNUNET_free_non_null (a_ac); 279 GNUNET_free_non_null (a_ac);
255} 280}
256 281
257#if 0 282
258/** 283/**
259 * Stats callback. Finish the stats testbed operation and when all stats have 284 * Stats callback. Finish the stats testbed operation and when all stats have
260 * been iterated, shutdown the test. 285 * been iterated, shutdown the test.
@@ -266,9 +291,12 @@ do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
266 */ 291 */
267static void 292static void
268bandwidth_stats_cont (void *cls, 293bandwidth_stats_cont (void *cls,
269 struct GNUNET_TESTBED_Operation *op, const char *emsg) 294 struct GNUNET_TESTBED_Operation *op,
295 const char *emsg)
270{ 296{
271 297 INFO ("# Outgoing bandwidth: %u\n", outgoing_bandwidth);
298 INFO ("# Incoming bandwidth: %u\n", incoming_bandwidth);
299 GNUNET_SCHEDULER_shutdown ();
272} 300}
273 301
274 302
@@ -284,35 +312,29 @@ bandwidth_stats_cont (void *cls,
284 * @return GNUNET_OK to continue, GNUNET_SYSERR to abort iteration 312 * @return GNUNET_OK to continue, GNUNET_SYSERR to abort iteration
285 */ 313 */
286static int 314static int
287bandwidth_stats_iterator (void *cls, const struct GNUNET_TESTBED_Peer *peer, 315bandwidth_stats_iterator (void *cls,
288 const char *subsystem, const char *name, 316 const struct GNUNET_TESTBED_Peer *peer,
289 uint64_t value, int is_persistent) 317 const char *subsystem,
318 const char *name,
319 uint64_t value,
320 int is_persistent)
290{ 321{
291 return GNUNET_OK; 322 static const char *s_sent = "# Bytes transmitted to other peers";
323 static const char *s_recv = "# Bytes received from other peers";
324
325 if (0 == strncmp (s_sent, name, strlen (s_sent)))
326 outgoing_bandwidth = outgoing_bandwidth + value;
327 else if (0 == strncmp(s_recv, name, strlen (s_recv)))
328 incoming_bandwidth = incoming_bandwidth + value;
329 else
330 return GNUNET_OK;
331 DEBUG ("Bandwith - Out: %lu; In: %lu\n",
332 (unsigned long) outgoing_bandwidth,
333 (unsigned long) incoming_bandwidth);
334 return GNUNET_OK;
292} 335}
293 336
294 337
295/**
296 * Task that collects bandwidth used by all the peers.
297 *
298 * @param cls Closure (NULL).
299 * @param tc Task Context.
300 */
301static void
302collect_bandwidth_stats (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
303{
304 if ((GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason) != 0)
305 return;
306
307 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Start collecting bandwidth statistics...\n");
308 //FIXME: what is the name of transport subsystem?
309 stats_op = GNUNET_TESTBED_get_statistics (n_active, testbed_handles,
310 NULL, NULL,
311 bandwidth_stats_iterator,
312 bandwidth_stats_cont, NULL);
313}
314#endif
315
316static void 338static void
317summarize () 339summarize ()
318{ 340{
@@ -322,9 +344,19 @@ summarize ()
322 INFO ("# GETS made: %u\n", n_gets); 344 INFO ("# GETS made: %u\n", n_gets);
323 INFO ("# GETS succeeded: %u\n", n_gets_ok); 345 INFO ("# GETS succeeded: %u\n", n_gets_ok);
324 INFO ("# GETS failed: %u\n", n_gets_fail); 346 INFO ("# GETS failed: %u\n", n_gets_fail);
325 //FIXME: is this the right place to call b/w stats? 347 INFO ("# average_put_path_length: %u\n", average_put_path_length);
326 //GNUNET_SCHEDULER_add_now (&collect_bandwidth_stats, NULL); 348 INFO ("# average_get_path_length: %u\n", average_get_path_length);
327 GNUNET_SCHEDULER_shutdown (); 349
350 if (NULL == testbed_handles)
351 {
352 INFO ("No peers found\n");
353 return;
354 }
355 /* Collect Stats*/
356 stats_op = GNUNET_TESTBED_get_statistics (n_active, testbed_handles,
357 "dht", NULL,
358 bandwidth_stats_iterator,
359 bandwidth_stats_cont, NULL);
328} 360}
329 361
330 362
@@ -338,19 +370,17 @@ static void
338cancel_get (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 370cancel_get (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
339{ 371{
340 struct ActiveContext *ac = cls; 372 struct ActiveContext *ac = cls;
341 struct Context *ctx = ac->ctx;
342 373
343 ac->delay_task = GNUNET_SCHEDULER_NO_TASK; 374 ac->delay_task = GNUNET_SCHEDULER_NO_TASK;
344 GNUNET_assert (NULL != ac->dht_get); 375 GNUNET_assert (NULL != ac->dht_get);
345 GNUNET_DHT_get_stop (ac->dht_get); 376 GNUNET_DHT_get_stop (ac->dht_get);
346 ac->dht_get = NULL; 377 ac->dht_get = NULL;
347 GNUNET_TESTBED_operation_done (ctx->op);
348 ctx->op = NULL;
349 n_gets_fail++; 378 n_gets_fail++;
350 379
351 /* If profiling is complete, summarize */ 380 /* If profiling is complete, summarize */
352 if (n_active == n_gets_fail + n_gets_ok) 381 if (n_active == n_gets_fail + n_gets_ok)
353 summarize (); 382 summarize ();
383
354} 384}
355 385
356 386
@@ -384,7 +414,6 @@ get_iter (void *cls,
384{ 414{
385 struct ActiveContext *ac = cls; 415 struct ActiveContext *ac = cls;
386 struct ActiveContext *get_ac = ac->get_ac; 416 struct ActiveContext *get_ac = ac->get_ac;
387 struct Context *ctx = ac->ctx;
388 417
389 /* Check the keys of put and get match or not. */ 418 /* Check the keys of put and get match or not. */
390 GNUNET_assert (0 == memcmp (key, &get_ac->hash, sizeof (struct GNUNET_HashCode))); 419 GNUNET_assert (0 == memcmp (key, &get_ac->hash, sizeof (struct GNUNET_HashCode)));
@@ -396,12 +425,17 @@ get_iter (void *cls,
396 ac->dht_get = NULL; 425 ac->dht_get = NULL;
397 GNUNET_SCHEDULER_cancel (ac->delay_task); 426 GNUNET_SCHEDULER_cancel (ac->delay_task);
398 ac->delay_task = GNUNET_SCHEDULER_NO_TASK; 427 ac->delay_task = GNUNET_SCHEDULER_NO_TASK;
399 GNUNET_TESTBED_operation_done (ctx->op); 428
400 ctx->op = NULL; 429 total_put_path_length = total_put_path_length + put_path_length;
430 total_get_path_length = total_get_path_length + get_path_length;
401 431
402 /* Summarize if profiling is complete */ 432 /* Summarize if profiling is complete */
403 if (n_active == n_gets_fail + n_gets_ok) 433 if (n_active == n_gets_fail + n_gets_ok)
434 {
435 average_put_path_length = total_put_path_length/n_active;
436 average_get_path_length = total_get_path_length/n_active;
404 summarize (); 437 summarize ();
438 }
405} 439}
406 440
407 441
@@ -468,71 +502,6 @@ put_cont (void *cls, int success)
468 ac->delay_task = GNUNET_SCHEDULER_add_delayed (delay, &delayed_get, ac); 502 ac->delay_task = GNUNET_SCHEDULER_add_delayed (delay, &delayed_get, ac);
469} 503}
470 504
471#if 0
472/**
473 * Stats callback. Finish the stats testbed operation and when all stats have
474 * been iterated, shutdown the test.
475 *
476 * @param cls closure
477 * @param op the operation that has been finished
478 * @param emsg error message in case the operation has failed; will be NULL if
479 * operation has executed successfully.
480 */
481static void
482finger_stats_cont (void *cls,
483 struct GNUNET_TESTBED_Operation *op,
484 const char *emsg)
485{
486
487}
488
489
490/**
491 * Process statistic values.
492 *
493 * @param cls closure
494 * @param peer the peer the statistic belong to
495 * @param subsystem name of subsystem that created the statistic
496 * @param name the name of the datum
497 * @param value the current value
498 * @param is_persistent GNUNET_YES if the value is persistent, GNUNET_NO if not
499 * @return GNUNET_OK to continue, GNUNET_SYSERR to abort iteration
500 */
501static int
502finger_stats_iterator (void *cls, const struct GNUNET_TESTBED_Peer *peer,
503 const char *subsystem, const char *name,
504 uint64_t value, int is_persistent)
505{
506 uint32_t i;
507
508 i = GNUNET_TESTBED_get_index (peer);
509 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " STATS %u - %s [%s]: %llu\n",
510 i, subsystem, name, value);
511
512 return GNUNET_OK;
513}
514
515
516/**
517 * Task check that keepalives were sent and received.
518 *
519 * @param cls Closure (NULL).
520 * @param tc Task Context.
521 */
522static void
523collect_finger_stats (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
524{
525 if ((GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason) != 0)
526 return;
527
528 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Start collecting statistics...\n");
529 /* FIXME: Write subsystem name. */
530 stats_op = GNUNET_TESTBED_get_statistics (n_active, testbed_handles,
531 "dht", NULL,
532 finger_stats_iterator,
533 finger_stats_cont, NULL);
534}
535#endif
536 505
537/** 506/**
538 * Task to do DHT PUTS 507 * Task to do DHT PUTS
@@ -545,12 +514,6 @@ delayed_put (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
545{ 514{
546 struct ActiveContext *ac = cls; 515 struct ActiveContext *ac = cls;
547 516
548 /*FIXME: Before doing anything else, first collect statistics from each peer
549 DHT and check if circle is formed. If yes then go ahead with more puts,
550 else wait for 'delay' time. This function does not return anything, so we
551 should have some way to notify that circle is done or we need to wait.*/
552 //GNUNET_SCHEDULER_add_now(collect_finger_stats,NULL);
553
554 ac->delay_task = GNUNET_SCHEDULER_NO_TASK; 517 ac->delay_task = GNUNET_SCHEDULER_NO_TASK;
555 /* Generate and DHT PUT some random data */ 518 /* Generate and DHT PUT some random data */
556 ac->put_data_size = 16; /* minimum */ 519 ac->put_data_size = 16; /* minimum */
@@ -696,7 +659,8 @@ test_run (void *cls,
696{ 659{
697 unsigned int cnt; 660 unsigned int cnt;
698 unsigned int ac_cnt; 661 unsigned int ac_cnt;
699 662
663 testbed_handles = peers;
700 if (NULL == peers) 664 if (NULL == peers)
701 { 665 {
702 /* exit */ 666 /* exit */
@@ -802,8 +766,8 @@ main (int argc, char *const *argv)
802 766
803 if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv)) 767 if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
804 return 2; 768 return 2;
805 delay = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 5); /* default delay */ 769 delay = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30); /* default delay */
806 timeout = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30); /* default timeout */ 770 timeout = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1); /* default timeout */
807 replication = 1; /* default replication */ 771 replication = 1; /* default replication */
808 rc = 0; 772 rc = 0;
809 if (GNUNET_OK != 773 if (GNUNET_OK !=