aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSupriti Singh <supritisingh08@gmail.com>2014-08-06 11:07:42 +0000
committerSupriti Singh <supritisingh08@gmail.com>2014-08-06 11:07:42 +0000
commit6c6e08344363cf61ce0baef3cc5afba38a247d7a (patch)
treec7ad79c255864d9325c3dd7135089eeccf7658b5 /src
parentd5d82faf0c8ef87b9bd4171f3e880ff006ec693c (diff)
downloadgnunet-6c6e08344363cf61ce0baef3cc5afba38a247d7a.tar.gz
gnunet-6c6e08344363cf61ce0baef3cc5afba38a247d7a.zip
- added basic layout for b/w and successor stats collection in profiler
- fixes in neighbours
Diffstat (limited to 'src')
-rw-r--r--src/dht/gnunet-service-xdht_neighbours.c103
-rw-r--r--src/dht/gnunet-service-xdht_routing.c10
-rw-r--r--src/dht/gnunet_dht_profiler.c141
3 files changed, 190 insertions, 64 deletions
diff --git a/src/dht/gnunet-service-xdht_neighbours.c b/src/dht/gnunet-service-xdht_neighbours.c
index 6b7f2d5de..c12ce9fa7 100644
--- a/src/dht/gnunet-service-xdht_neighbours.c
+++ b/src/dht/gnunet-service-xdht_neighbours.c
@@ -1259,12 +1259,8 @@ GDS_NEIGHBOURS_send_verify_successor_message (struct GNUNET_PeerIdentity source_
1259 vsm->source_peer = source_peer; 1259 vsm->source_peer = source_peer;
1260 vsm->successor = successor; 1260 vsm->successor = successor;
1261 vsm->trail_id = trail_id; 1261 vsm->trail_id = trail_id;
1262 1262 peer_list = (struct GNUNET_PeerIdentity *) &vsm[1];
1263 if (trail_length != 0) 1263 memcpy (peer_list, trail, trail_length * sizeof (struct GNUNET_PeerIdentity));
1264 {
1265 peer_list = (struct GNUNET_PeerIdentity *) &vsm[1];
1266 memcpy (peer_list, trail, trail_length * sizeof (struct GNUNET_PeerIdentity));
1267 }
1268 1264
1269 /* Send the message to chosen friend. */ 1265 /* Send the message to chosen friend. */
1270 GNUNET_CONTAINER_DLL_insert_tail (target_friend->head, target_friend->tail, pending); 1266 GNUNET_CONTAINER_DLL_insert_tail (target_friend->head, target_friend->tail, pending);
@@ -1385,14 +1381,10 @@ GDS_NEIGHBOURS_send_verify_successor_result (struct GNUNET_PeerIdentity querying
1385 vsmr->current_successor = current_successor; 1381 vsmr->current_successor = current_successor;
1386 vsmr->probable_successor = probable_successor; 1382 vsmr->probable_successor = probable_successor;
1387 vsmr->trail_direction = htonl (trail_direction); 1383 vsmr->trail_direction = htonl (trail_direction);
1388 vsmr->trail_id = trail_id; 1384 vsmr->trail_id = trail_id;
1389 1385 peer_list = (struct GNUNET_PeerIdentity *) &vsmr[1];
1390 if (trail_length > 0) 1386 memcpy (peer_list, trail, trail_length * sizeof (struct GNUNET_PeerIdentity));
1391 { 1387
1392 peer_list = (struct GNUNET_PeerIdentity *) &vsmr[1];
1393 memcpy (peer_list, trail, trail_length * sizeof (struct GNUNET_PeerIdentity));
1394 }
1395
1396 /* Send the message to chosen friend. */ 1388 /* Send the message to chosen friend. */
1397 GNUNET_CONTAINER_DLL_insert_tail (target_friend->head, target_friend->tail, pending); 1389 GNUNET_CONTAINER_DLL_insert_tail (target_friend->head, target_friend->tail, pending);
1398 target_friend->pending_count++; 1390 target_friend->pending_count++;
@@ -1451,13 +1443,10 @@ GDS_NEIGHBOURS_send_notify_new_successor (struct GNUNET_PeerIdentity source_peer
1451 nsm->source_peer = source_peer; 1443 nsm->source_peer = source_peer;
1452 nsm->trail_id = succesor_trail_id; 1444 nsm->trail_id = succesor_trail_id;
1453 1445
1454 if (successor_trail_length > 0) 1446 peer_list = (struct GNUNET_PeerIdentity *) &nsm[1];
1455 { 1447 memcpy (peer_list, successor_trail,
1456 peer_list = (struct GNUNET_PeerIdentity *) &nsm[1]; 1448 successor_trail_length * sizeof (struct GNUNET_PeerIdentity));
1457 memcpy (peer_list, successor_trail, 1449
1458 successor_trail_length * sizeof (struct GNUNET_PeerIdentity));
1459 }
1460
1461 /* Send the message to chosen friend. */ 1450 /* Send the message to chosen friend. */
1462 GNUNET_CONTAINER_DLL_insert_tail (target_friend->head, target_friend->tail, pending); 1451 GNUNET_CONTAINER_DLL_insert_tail (target_friend->head, target_friend->tail, pending);
1463 target_friend->pending_count++; 1452 target_friend->pending_count++;
@@ -1962,7 +1951,7 @@ compare_finger_and_current_successor (struct Closest_Peer *current_closest_peer)
1962 current_closest_peer->best_known_destination = finger->finger_identity; 1951 current_closest_peer->best_known_destination = finger->finger_identity;
1963 current_closest_peer->next_hop = finger_trail->friend.id; 1952 current_closest_peer->next_hop = finger_trail->friend.id;
1964 current_closest_peer->trail_id = finger_trail->trail_id; 1953 current_closest_peer->trail_id = finger_trail->trail_id;
1965 //GNUNET_free(finger_trail);//FIXME: where should we free the finger trail. 1954 GNUNET_free(finger_trail);
1966 } 1955 }
1967 continue; 1956 continue;
1968 } 1957 }
@@ -2870,13 +2859,9 @@ free_finger (struct FingerInfo *finger, unsigned int finger_table_index)
2870 2859
2871 2860
2872/** 2861/**
2873 * FIXME: ensure that you are not adding any trail to reach to a friend which
2874 * is a finger. Also decide on should you increment trails count of a friend
2875 * which is also a finger.
2876 * Add a new entry in finger table at finger_table_index. 2862 * Add a new entry in finger table at finger_table_index.
2877 * In case finger identity is me or a friend, then don't add a trail. NOTE 2863 * In case I am my own finger, then we don't have a trail. In case of a friend,
2878 * trail length to reach to a finger can be 0 only if the finger is a friend 2864 * we have a trail with unique id and '0' trail length.
2879 * or my identity.
2880 * In case a finger is a friend, then increment the trails count of the friend. 2865 * In case a finger is a friend, then increment the trails count of the friend.
2881 * @param finger_identity Peer Identity of new finger 2866 * @param finger_identity Peer Identity of new finger
2882 * @param finger_trail Trail to reach from me to finger (excluding both end points). 2867 * @param finger_trail Trail to reach from me to finger (excluding both end points).
@@ -2902,7 +2887,8 @@ add_new_finger (struct GNUNET_PeerIdentity finger_identity,
2902 new_entry->is_present = GNUNET_YES; 2887 new_entry->is_present = GNUNET_YES;
2903 2888
2904 /* If the new entry is my own identity. */ 2889 /* If the new entry is my own identity. */
2905 if (0 == GNUNET_CRYPTO_cmp_peer_identity (&my_identity, &finger_identity)) 2890 if (0 == GNUNET_CRYPTO_cmp_peer_identity (&my_identity,
2891 &finger_identity))
2906 { 2892 {
2907 new_entry->trails_count = 0; 2893 new_entry->trails_count = 0;
2908 finger_table[finger_table_index] = *new_entry; 2894 finger_table[finger_table_index] = *new_entry;
@@ -2923,7 +2909,7 @@ add_new_finger (struct GNUNET_PeerIdentity finger_identity,
2923 new_entry->trail_list[0].trail_tail = NULL; 2909 new_entry->trail_list[0].trail_tail = NULL;
2924 finger_table[finger_table_index] = *new_entry; 2910 finger_table[finger_table_index] = *new_entry;
2925 GNUNET_assert (NULL != 2911 GNUNET_assert (NULL !=
2926 (first_trail_hop = 2912 (first_trail_hop =
2927 GNUNET_CONTAINER_multipeermap_get (friend_peermap, 2913 GNUNET_CONTAINER_multipeermap_get (friend_peermap,
2928 &finger_identity))); 2914 &finger_identity)));
2929 2915
@@ -2932,10 +2918,6 @@ add_new_finger (struct GNUNET_PeerIdentity finger_identity,
2932 return; 2918 return;
2933 } 2919 }
2934 2920
2935 /* finger trail length can be 0 only in case if finger is my identity or
2936 finger is friend. We should never reach here. */
2937 GNUNET_assert (finger_trail_length > 0);
2938
2939 GNUNET_assert (NULL != 2921 GNUNET_assert (NULL !=
2940 (first_trail_hop = 2922 (first_trail_hop =
2941 GNUNET_CONTAINER_multipeermap_get (friend_peermap, 2923 GNUNET_CONTAINER_multipeermap_get (friend_peermap,
@@ -2965,8 +2947,7 @@ add_new_finger (struct GNUNET_PeerIdentity finger_identity,
2965 new_entry->trail_list[0].trail_id = trail_id; 2947 new_entry->trail_list[0].trail_id = trail_id;
2966 new_entry->trail_list[0].is_present = GNUNET_YES; 2948 new_entry->trail_list[0].is_present = GNUNET_YES;
2967 finger_table[finger_table_index] = *new_entry; 2949 finger_table[finger_table_index] = *new_entry;
2968 //GNUNET_free (new_entry); 2950 GNUNET_free (new_entry);
2969 //GNUNET_free (trail);
2970 return; 2951 return;
2971} 2952}
2972 2953
@@ -3064,8 +3045,8 @@ scan_and_compress_trail (struct GNUNET_PeerIdentity finger_identity,
3064 } 3045 }
3065 3046
3066 /* If we did not compress the trail, return the original trail back.*/ 3047 /* If we did not compress the trail, return the original trail back.*/
3067 new_trail = GNUNET_malloc (sizeof (struct GNUNET_PeerIdentity) * trail_length);
3068 *new_trail_length = trail_length; 3048 *new_trail_length = trail_length;
3049 new_trail = GNUNET_malloc (sizeof (struct GNUNET_PeerIdentity) * trail_length);
3069 memcpy (new_trail, trail, trail_length * sizeof (struct GNUNET_PeerIdentity)); 3050 memcpy (new_trail, trail, trail_length * sizeof (struct GNUNET_PeerIdentity));
3070 return new_trail; 3051 return new_trail;
3071} 3052}
@@ -3400,6 +3381,7 @@ finger_table_add (struct GNUNET_PeerIdentity finger_identity,
3400 add_new_finger (finger_identity, updated_trail, 3381 add_new_finger (finger_identity, updated_trail,
3401 updated_finger_trail_length, 3382 updated_finger_trail_length,
3402 finger_trail_id, finger_table_index); 3383 finger_trail_id, finger_table_index);
3384 GNUNET_free_non_null(updated_trail);
3403 update_current_search_finger_index (finger_identity, 3385 update_current_search_finger_index (finger_identity,
3404 finger_table_index); 3386 finger_table_index);
3405 return; 3387 return;
@@ -3428,7 +3410,7 @@ finger_table_add (struct GNUNET_PeerIdentity finger_identity,
3428 remove_existing_finger (existing_finger, finger_table_index); 3410 remove_existing_finger (existing_finger, finger_table_index);
3429 add_new_finger (finger_identity, updated_trail, updated_finger_trail_length, 3411 add_new_finger (finger_identity, updated_trail, updated_finger_trail_length,
3430 finger_trail_id, finger_table_index); 3412 finger_trail_id, finger_table_index);
3431 3413 GNUNET_free_non_null((struct GNUNET_PeerIdentity *)updated_trail);
3432 } 3414 }
3433 else 3415 else
3434 { 3416 {
@@ -3615,7 +3597,6 @@ handle_dht_p2p_put (void *cls, const struct GNUNET_PeerIdentity *peer,
3615 struct Closest_Peer successor; 3597 struct Closest_Peer successor;
3616 key_value = GNUNET_ntohll (key_value); 3598 key_value = GNUNET_ntohll (key_value);
3617 successor = find_successor (key_value, GDS_FINGER_TYPE_NON_PREDECESSOR); 3599 successor = find_successor (key_value, GDS_FINGER_TYPE_NON_PREDECESSOR);
3618
3619 next_hop = GNUNET_new (struct GNUNET_PeerIdentity); 3600 next_hop = GNUNET_new (struct GNUNET_PeerIdentity);
3620 *next_hop = successor.next_hop; 3601 *next_hop = successor.next_hop;
3621 intermediate_trail_id = successor.trail_id; 3602 intermediate_trail_id = successor.trail_id;
@@ -4366,6 +4347,7 @@ get_shortest_trail (struct FingerInfo *finger,
4366 return trail_list; 4347 return trail_list;
4367} 4348}
4368 4349
4350
4369/** 4351/**
4370 * Check if trail_1 and trail_2 have any common element. If yes then join 4352 * Check if trail_1 and trail_2 have any common element. If yes then join
4371 * them at common element. trail_1 always preceeds trail_2 in joined trail. 4353 * them at common element. trail_1 always preceeds trail_2 in joined trail.
@@ -4401,7 +4383,7 @@ check_for_duplicate_entries (const struct GNUNET_PeerIdentity *trail_1,
4401 4383
4402 4384
4403 /* Copy all the elements from 0 to i into joined_trail. */ 4385 /* Copy all the elements from 0 to i into joined_trail. */
4404 for(k = 0; k < trail_1_len; k++) 4386 for(k = 0; k < (i+1); k++)
4405 { 4387 {
4406 joined_trail[k] = trail_1[k]; 4388 joined_trail[k] = trail_1[k];
4407 } 4389 }
@@ -4410,9 +4392,10 @@ check_for_duplicate_entries (const struct GNUNET_PeerIdentity *trail_1,
4410 j = j+1; 4392 j = j+1;
4411 4393
4412 /* Copy all the elements from j+1 to trail_2_len-1 to joined trail.*/ 4394 /* Copy all the elements from j+1 to trail_2_len-1 to joined trail.*/
4413 while(k < *joined_trail_len) 4395 while((k < *joined_trail_len) && (j < trail_2_len));
4414 { 4396 {
4415 joined_trail[k] = trail_2[j]; 4397 joined_trail[k] = trail_2[j];
4398 j++;
4416 k++; 4399 k++;
4417 } 4400 }
4418 4401
@@ -4473,6 +4456,7 @@ get_trail_src_to_curr_pred (struct GNUNET_PeerIdentity source_peer,
4473 &trail_me_to_curr_pred[0]))) 4456 &trail_me_to_curr_pred[0])))
4474 { 4457 {
4475 *trail_src_to_curr_pred_length = 0; 4458 *trail_src_to_curr_pred_length = 0;
4459 GNUNET_free_non_null(trail_me_to_curr_pred);
4476 return NULL; 4460 return NULL;
4477 } 4461 }
4478 4462
@@ -4503,6 +4487,7 @@ get_trail_src_to_curr_pred (struct GNUNET_PeerIdentity source_peer,
4503 { 4487 {
4504 trail_src_to_curr_pred[j] = trail_me_to_curr_pred[i]; 4488 trail_src_to_curr_pred[j] = trail_me_to_curr_pred[i];
4505 } 4489 }
4490 GNUNET_free_non_null(trail_me_to_curr_pred);
4506 return trail_src_to_curr_pred; 4491 return trail_src_to_curr_pred;
4507 } 4492 }
4508 } 4493 }
@@ -4514,6 +4499,7 @@ get_trail_src_to_curr_pred (struct GNUNET_PeerIdentity source_peer,
4514 trail_me_to_curr_pred_length, 4499 trail_me_to_curr_pred_length,
4515 &len); 4500 &len);
4516 *trail_src_to_curr_pred_length = len; 4501 *trail_src_to_curr_pred_length = len;
4502 GNUNET_free_non_null(trail_me_to_curr_pred);
4517 return trail_src_to_curr_pred; 4503 return trail_src_to_curr_pred;
4518} 4504}
4519 4505
@@ -4580,7 +4566,7 @@ update_predecessor (struct GNUNET_PeerIdentity finger,
4580 4566
4581 add_new_finger (finger, trail_to_new_predecessor, trail_length, 4567 add_new_finger (finger, trail_to_new_predecessor, trail_length,
4582 trail_to_new_predecessor_id, PREDECESSOR_FINGER_ID); 4568 trail_to_new_predecessor_id, PREDECESSOR_FINGER_ID);
4583 GNUNET_free_non_null (trail_to_new_predecessor); 4569 GNUNET_free_non_null(trail_to_new_predecessor);
4584} 4570}
4585 4571
4586 4572
@@ -4658,13 +4644,13 @@ handle_dht_p2p_verify_successor(void *cls,
4658 struct GNUNET_PeerIdentity source_peer; 4644 struct GNUNET_PeerIdentity source_peer;
4659 struct GNUNET_PeerIdentity *trail; 4645 struct GNUNET_PeerIdentity *trail;
4660 struct GNUNET_PeerIdentity *next_hop; 4646 struct GNUNET_PeerIdentity *next_hop;
4661 struct FingerInfo *current_predecessor; 4647 struct FingerInfo current_predecessor;
4662 struct FriendInfo *target_friend; 4648 struct FriendInfo *target_friend;
4663 unsigned int trail_src_to_curr_pred_len = 0; 4649 unsigned int trail_src_to_curr_pred_len = 0;
4664 struct GNUNET_PeerIdentity *trail_src_to_curr_pred; 4650 struct GNUNET_PeerIdentity *trail_src_to_curr_pred;
4665 size_t msize;
4666 unsigned int trail_length; 4651 unsigned int trail_length;
4667 4652 size_t msize;
4653
4668 msize = ntohs (message->size); 4654 msize = ntohs (message->size);
4669 4655
4670 if (msize < sizeof (struct PeerVerifySuccessorMessage)) 4656 if (msize < sizeof (struct PeerVerifySuccessorMessage))
@@ -4702,7 +4688,7 @@ handle_dht_p2p_verify_successor(void *cls,
4702 } 4688 }
4703 4689
4704 target_friend = GNUNET_CONTAINER_multipeermap_get (friend_peermap, next_hop); 4690 target_friend = GNUNET_CONTAINER_multipeermap_get (friend_peermap, next_hop);
4705 4691
4706 if(NULL == target_friend) 4692 if(NULL == target_friend)
4707 { 4693 {
4708 GNUNET_break_op(0); 4694 GNUNET_break_op(0);
@@ -4719,10 +4705,10 @@ handle_dht_p2p_verify_successor(void *cls,
4719 /* Check if the source_peer could be our predecessor and if yes then update 4705 /* Check if the source_peer could be our predecessor and if yes then update
4720 * it. */ 4706 * it. */
4721 compare_and_update_predecessor (source_peer, trail, trail_length); 4707 compare_and_update_predecessor (source_peer, trail, trail_length);
4722 current_predecessor = &finger_table[PREDECESSOR_FINGER_ID]; 4708 current_predecessor = finger_table[PREDECESSOR_FINGER_ID];
4723 4709
4724 /* Is source of this message NOT my predecessor. */ 4710 /* Is source of this message NOT my predecessor. */
4725 if (0 != (GNUNET_CRYPTO_cmp_peer_identity (&current_predecessor->finger_identity, 4711 if (0 != (GNUNET_CRYPTO_cmp_peer_identity (&current_predecessor.finger_identity,
4726 &source_peer))) 4712 &source_peer)))
4727 { 4713 {
4728 trail_src_to_curr_pred = get_trail_src_to_curr_pred (source_peer, 4714 trail_src_to_curr_pred = get_trail_src_to_curr_pred (source_peer,
@@ -4735,7 +4721,8 @@ handle_dht_p2p_verify_successor(void *cls,
4735 trail_src_to_curr_pred_len = trail_length; 4721 trail_src_to_curr_pred_len = trail_length;
4736 int i; 4722 int i;
4737 4723
4738 trail_src_to_curr_pred = GNUNET_malloc(sizeof(struct GNUNET_PeerIdentity)*trail_length); 4724 trail_src_to_curr_pred = GNUNET_malloc (sizeof(struct GNUNET_PeerIdentity)
4725 *trail_src_to_curr_pred_len);
4739 for(i = 0; i < trail_src_to_curr_pred_len; i++) 4726 for(i = 0; i < trail_src_to_curr_pred_len; i++)
4740 { 4727 {
4741 trail_src_to_curr_pred[i] = trail[i]; 4728 trail_src_to_curr_pred[i] = trail[i];
@@ -4747,12 +4734,12 @@ handle_dht_p2p_verify_successor(void *cls,
4747 (target_friend = 4734 (target_friend =
4748 GNUNET_CONTAINER_multipeermap_get (friend_peermap, peer))); 4735 GNUNET_CONTAINER_multipeermap_get (friend_peermap, peer)));
4749 GDS_NEIGHBOURS_send_verify_successor_result (source_peer, my_identity, 4736 GDS_NEIGHBOURS_send_verify_successor_result (source_peer, my_identity,
4750 current_predecessor->finger_identity, 4737 current_predecessor.finger_identity,
4751 trail_id, trail_src_to_curr_pred, 4738 trail_id, trail_src_to_curr_pred,
4752 trail_src_to_curr_pred_len, 4739 trail_src_to_curr_pred_len,
4753 GDS_ROUTING_DEST_TO_SRC, 4740 GDS_ROUTING_DEST_TO_SRC,
4754 target_friend); 4741 target_friend);
4755 4742 GNUNET_free_non_null(trail_src_to_curr_pred);
4756 return GNUNET_OK; 4743 return GNUNET_OK;
4757} 4744}
4758 4745
@@ -4786,7 +4773,7 @@ check_trail_me_to_probable_succ (struct GNUNET_PeerIdentity probable_successor,
4786 *trail_to_new_successor_length = 0; 4773 *trail_to_new_successor_length = 0;
4787 return trail_to_new_successor; 4774 return trail_to_new_successor;
4788 } 4775 }
4789 4776
4790 /* Is there any friend of yours in this trail. */ 4777 /* Is there any friend of yours in this trail. */
4791 if(trail_me_to_probable_successor_len > 1) 4778 if(trail_me_to_probable_successor_len > 1)
4792 { 4779 {
@@ -4801,15 +4788,19 @@ check_trail_me_to_probable_succ (struct GNUNET_PeerIdentity probable_successor,
4801 trail_to_new_successor = GNUNET_malloc (sizeof(struct GNUNET_PeerIdentity)* 4788 trail_to_new_successor = GNUNET_malloc (sizeof(struct GNUNET_PeerIdentity)*
4802 *trail_to_new_successor_length); 4789 *trail_to_new_successor_length);
4803 4790
4804 for(j = 0;i < trail_me_to_probable_successor_len;i++,j++) 4791
4792 for(j = 0;j < *trail_to_new_successor_length;i++,j++)
4805 { 4793 {
4806 trail_to_new_successor[j] = trail_me_to_probable_successor[i]; 4794 trail_to_new_successor[j] = trail_me_to_probable_successor[i];
4807 } 4795 }
4796
4808 return trail_to_new_successor; 4797 return trail_to_new_successor;
4809 } 4798 }
4810 } 4799 }
4811 4800
4812 *trail_to_new_successor_length = trail_me_to_probable_successor_len; 4801 *trail_to_new_successor_length = trail_me_to_probable_successor_len;
4802 return (struct GNUNET_PeerIdentity*)trail_me_to_probable_successor;
4803#if 0
4813 trail_to_new_successor = GNUNET_malloc (sizeof (struct GNUNET_PeerIdentity)* 4804 trail_to_new_successor = GNUNET_malloc (sizeof (struct GNUNET_PeerIdentity)*
4814 *trail_to_new_successor_length); 4805 *trail_to_new_successor_length);
4815 4806
@@ -4817,6 +4808,7 @@ check_trail_me_to_probable_succ (struct GNUNET_PeerIdentity probable_successor,
4817 trail_to_new_successor[i] = trail_me_to_probable_successor[i]; 4808 trail_to_new_successor[i] = trail_me_to_probable_successor[i];
4818 4809
4819 return trail_to_new_successor; 4810 return trail_to_new_successor;
4811#endif
4820} 4812}
4821 4813
4822 4814
@@ -4925,7 +4917,7 @@ compare_and_update_successor (struct GNUNET_PeerIdentity curr_succ,
4925 4917
4926 add_new_finger (probable_successor, trail_me_to_probable_succ, 4918 add_new_finger (probable_successor, trail_me_to_probable_succ,
4927 trail_me_to_probable_succ_len, trail_id, 0); 4919 trail_me_to_probable_succ_len, trail_id, 0);
4928 4920
4929 GDS_NEIGHBOURS_send_notify_new_successor (my_identity, probable_successor, 4921 GDS_NEIGHBOURS_send_notify_new_successor (my_identity, probable_successor,
4930 trail_me_to_probable_succ, 4922 trail_me_to_probable_succ,
4931 trail_me_to_probable_succ_len, 4923 trail_me_to_probable_succ_len,
@@ -5695,9 +5687,6 @@ handle_core_connect (void *cls, const struct GNUNET_PeerIdentity *peer_identity)
5695 return; 5687 return;
5696 } 5688 }
5697 5689
5698 GNUNET_STATISTICS_update (GDS_stats, gettext_noop ("# peers connected"), 1,
5699 GNUNET_NO);
5700
5701 friend = GNUNET_new (struct FriendInfo); 5690 friend = GNUNET_new (struct FriendInfo);
5702 friend->id = *peer_identity; 5691 friend->id = *peer_identity;
5703 5692
diff --git a/src/dht/gnunet-service-xdht_routing.c b/src/dht/gnunet-service-xdht_routing.c
index 087d4dcff..b096e5ef3 100644
--- a/src/dht/gnunet-service-xdht_routing.c
+++ b/src/dht/gnunet-service-xdht_routing.c
@@ -311,7 +311,6 @@ GDS_ROUTING_add (struct GNUNET_HashCode new_trail_id,
311 struct GNUNET_PeerIdentity next_hop) 311 struct GNUNET_PeerIdentity next_hop)
312{ 312{
313 struct RoutingTrail *new_entry; 313 struct RoutingTrail *new_entry;
314 int ret;
315 314
316 new_entry = GNUNET_new (struct RoutingTrail); 315 new_entry = GNUNET_new (struct RoutingTrail);
317 new_entry->trail_id = new_trail_id; 316 new_entry->trail_id = new_trail_id;
@@ -319,11 +318,10 @@ GDS_ROUTING_add (struct GNUNET_HashCode new_trail_id,
319 new_entry->prev_hop = prev_hop; 318 new_entry->prev_hop = prev_hop;
320 319
321 320
322 ret = GNUNET_CONTAINER_multihashmap_put (routing_table, 321 return GNUNET_CONTAINER_multihashmap_put (routing_table,
323 &new_trail_id, new_entry, 322 &new_trail_id, new_entry,
324 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY); 323 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY);
325 //GNUNET_assert(ret == GNUNET_OK); 324
326 return ret;
327} 325}
328 326
329 327
diff --git a/src/dht/gnunet_dht_profiler.c b/src/dht/gnunet_dht_profiler.c
index 62e8acf02..0bfe609d8 100644
--- a/src/dht/gnunet_dht_profiler.c
+++ b/src/dht/gnunet_dht_profiler.c
@@ -205,6 +205,15 @@ static unsigned int n_gets_fail;
205 */ 205 */
206static unsigned int replication; 206static unsigned int replication;
207 207
208/**
209 * Testbed Operation (to get stats).
210 */
211static struct GNUNET_TESTBED_Operation *stats_op;
212
213/**
214 * Testbed peer handles.
215 */
216static struct GNUNET_TESTBED_Peer **testbed_handles;
208 217
209/** 218/**
210 * Shutdown task. Cleanup all resources and operations. 219 * Shutdown task. Cleanup all resources and operations.
@@ -245,6 +254,64 @@ do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
245} 254}
246 255
247 256
257/**
258 * Stats callback. Finish the stats testbed operation and when all stats have
259 * been iterated, shutdown the test.
260 *
261 * @param cls closure
262 * @param op the operation that has been finished
263 * @param emsg error message in case the operation has failed; will be NULL if
264 * operation has executed successfully.
265 */
266static void
267bandwidth_stats_cont (void *cls,
268 struct GNUNET_TESTBED_Operation *op, const char *emsg)
269{
270
271}
272
273
274/**
275 * Process statistic values.
276 *
277 * @param cls closure
278 * @param peer the peer the statistic belong to
279 * @param subsystem name of subsystem that created the statistic
280 * @param name the name of the datum
281 * @param value the current value
282 * @param is_persistent GNUNET_YES if the value is persistent, GNUNET_NO if not
283 * @return GNUNET_OK to continue, GNUNET_SYSERR to abort iteration
284 */
285static int
286bandwidth_stats_iterator (void *cls, const struct GNUNET_TESTBED_Peer *peer,
287 const char *subsystem, const char *name,
288 uint64_t value, int is_persistent)
289{
290 return GNUNET_OK;
291}
292
293
294/**
295 * Task that collects bandwidth used by all the peers.
296 *
297 * @param cls Closure (NULL).
298 * @param tc Task Context.
299 */
300static void
301collect_bandwidth_stats (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
302{
303 if ((GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason) != 0)
304 return;
305
306 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Start collecting bandwidth statistics...\n");
307 //FIXME: what is the name of transport subsystem?
308 stats_op = GNUNET_TESTBED_get_statistics (n_active, testbed_handles,
309 NULL, NULL,
310 bandwidth_stats_iterator,
311 bandwidth_stats_cont, NULL);
312}
313
314
248static void 315static void
249summarize () 316summarize ()
250{ 317{
@@ -254,7 +321,9 @@ summarize ()
254 INFO ("# GETS made: %u\n", n_gets); 321 INFO ("# GETS made: %u\n", n_gets);
255 INFO ("# GETS succeeded: %u\n", n_gets_ok); 322 INFO ("# GETS succeeded: %u\n", n_gets_ok);
256 INFO ("# GETS failed: %u\n", n_gets_fail); 323 INFO ("# GETS failed: %u\n", n_gets_fail);
257 GNUNET_SCHEDULER_shutdown (); 324 //FIXME: is this the right place to call b/w stats?
325 GNUNET_SCHEDULER_add_now (&collect_bandwidth_stats, NULL);
326 GNUNET_SCHEDULER_shutdown ();
258} 327}
259 328
260 329
@@ -398,6 +467,70 @@ put_cont (void *cls, int success)
398 ac->delay_task = GNUNET_SCHEDULER_add_delayed (delay, &delayed_get, ac); 467 ac->delay_task = GNUNET_SCHEDULER_add_delayed (delay, &delayed_get, ac);
399} 468}
400 469
470/**
471 * Stats callback. Finish the stats testbed operation and when all stats have
472 * been iterated, shutdown the test.
473 *
474 * @param cls closure
475 * @param op the operation that has been finished
476 * @param emsg error message in case the operation has failed; will be NULL if
477 * operation has executed successfully.
478 */
479static void
480finger_stats_cont (void *cls,
481 struct GNUNET_TESTBED_Operation *op,
482 const char *emsg)
483{
484
485}
486
487
488/**
489 * Process statistic values.
490 *
491 * @param cls closure
492 * @param peer the peer the statistic belong to
493 * @param subsystem name of subsystem that created the statistic
494 * @param name the name of the datum
495 * @param value the current value
496 * @param is_persistent GNUNET_YES if the value is persistent, GNUNET_NO if not
497 * @return GNUNET_OK to continue, GNUNET_SYSERR to abort iteration
498 */
499static int
500finger_stats_iterator (void *cls, const struct GNUNET_TESTBED_Peer *peer,
501 const char *subsystem, const char *name,
502 uint64_t value, int is_persistent)
503{
504 uint32_t i;
505
506 i = GNUNET_TESTBED_get_index (peer);
507 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " STATS %u - %s [%s]: %llu\n",
508 i, subsystem, name, value);
509
510 return GNUNET_OK;
511}
512
513
514/**
515 * Task check that keepalives were sent and received.
516 *
517 * @param cls Closure (NULL).
518 * @param tc Task Context.
519 */
520static void
521collect_finger_stats (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
522{
523 if ((GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason) != 0)
524 return;
525
526 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Start collecting statistics...\n");
527 /* FIXME: Write subsystem name. */
528 stats_op = GNUNET_TESTBED_get_statistics (n_active, testbed_handles,
529 "dht", NULL,
530 finger_stats_iterator,
531 finger_stats_cont, NULL);
532}
533
401 534
402/** 535/**
403 * Task to do DHT PUTS 536 * Task to do DHT PUTS
@@ -410,6 +543,12 @@ delayed_put (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
410{ 543{
411 struct ActiveContext *ac = cls; 544 struct ActiveContext *ac = cls;
412 545
546 /*FIXME: Before doing anything else, first collect statistics from each peer
547 DHT and check if circle is formed. If yes then go ahead with more puts,
548 else wait for 'delay' time. This function does not return anything, so we
549 should have some way to notify that circle is done or we need to wait.*/
550 GNUNET_SCHEDULER_add_now(collect_finger_stats,NULL);
551
413 ac->delay_task = GNUNET_SCHEDULER_NO_TASK; 552 ac->delay_task = GNUNET_SCHEDULER_NO_TASK;
414 /* Generate and DHT PUT some random data */ 553 /* Generate and DHT PUT some random data */
415 ac->put_data_size = 16; /* minimum */ 554 ac->put_data_size = 16; /* minimum */