aboutsummaryrefslogtreecommitdiff
path: root/src/dht
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-09-30 01:06:19 +0000
committerChristian Grothoff <christian@grothoff.org>2011-09-30 01:06:19 +0000
commit793b4afffb37ca663e9a4fb6155dddd688b21b52 (patch)
tree1c5f2ca4e5ff08e5cab424ba3d418a3a1bab3ff8 /src/dht
parent25e636d19d7220430cac2a4fbdda0cac09f0b15d (diff)
downloadgnunet-793b4afffb37ca663e9a4fb6155dddd688b21b52.tar.gz
gnunet-793b4afffb37ca663e9a4fb6155dddd688b21b52.zip
re-add logging, move BF add operations to the latest possible time to avoid polluting tests needlessly
Diffstat (limited to 'src/dht')
-rw-r--r--src/dht/dht.h2
-rw-r--r--src/dht/gnunet-service-dht_neighbours.c72
-rw-r--r--src/dht/test_dht_multipeer.c56
3 files changed, 97 insertions, 33 deletions
diff --git a/src/dht/dht.h b/src/dht/dht.h
index 2a6717788..479c3527d 100644
--- a/src/dht/dht.h
+++ b/src/dht/dht.h
@@ -31,7 +31,7 @@
31/** 31/**
32 * Size of the bloom filter the DHT uses to filter peers. 32 * Size of the bloom filter the DHT uses to filter peers.
33 */ 33 */
34#define DHT_BLOOM_SIZE 128 34#define DHT_BLOOM_SIZE 1024
35 35
36 36
37/** 37/**
diff --git a/src/dht/gnunet-service-dht_neighbours.c b/src/dht/gnunet-service-dht_neighbours.c
index 46220a855..b0e607ba2 100644
--- a/src/dht/gnunet-service-dht_neighbours.c
+++ b/src/dht/gnunet-service-dht_neighbours.c
@@ -640,6 +640,10 @@ handle_core_connect (void *cls, const struct GNUNET_PeerIdentity *peer,
640 /* Check for connect to self message */ 640 /* Check for connect to self message */
641 if (0 == memcmp (&my_identity, peer, sizeof (struct GNUNET_PeerIdentity))) 641 if (0 == memcmp (&my_identity, peer, sizeof (struct GNUNET_PeerIdentity)))
642 return; 642 return;
643 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
644 "Connected %s to %s\n",
645 GNUNET_i2s (&my_identity),
646 GNUNET_h2s (&peer->hashPubKey));
643 if (GNUNET_YES == 647 if (GNUNET_YES ==
644 GNUNET_CONTAINER_multihashmap_contains (all_known_peers, 648 GNUNET_CONTAINER_multihashmap_contains (all_known_peers,
645 &peer->hashPubKey)) 649 &peer->hashPubKey))
@@ -698,6 +702,10 @@ handle_core_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
698 /* Check for disconnect from self message */ 702 /* Check for disconnect from self message */
699 if (0 == memcmp (&my_identity, peer, sizeof (struct GNUNET_PeerIdentity))) 703 if (0 == memcmp (&my_identity, peer, sizeof (struct GNUNET_PeerIdentity)))
700 return; 704 return;
705 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
706 "Disconnected %s from %s\n",
707 GNUNET_i2s (&my_identity),
708 GNUNET_h2s (&peer->hashPubKey));
701 to_remove = 709 to_remove =
702 GNUNET_CONTAINER_multihashmap_get (all_known_peers, &peer->hashPubKey); 710 GNUNET_CONTAINER_multihashmap_get (all_known_peers, &peer->hashPubKey);
703 if (NULL == to_remove) 711 if (NULL == to_remove)
@@ -1022,9 +1030,10 @@ select_peer (const GNUNET_HashCode *key,
1022 count = 0; 1030 count = 0;
1023 while ((pos != NULL) && (count < bucket_size)) 1031 while ((pos != NULL) && (count < bucket_size))
1024 { 1032 {
1025 if (GNUNET_NO == 1033 if ( (bloom == NULL) ||
1026 GNUNET_CONTAINER_bloomfilter_test (bloom, &pos->id.hashPubKey)) 1034 (GNUNET_NO ==
1027 { 1035 GNUNET_CONTAINER_bloomfilter_test (bloom, &pos->id.hashPubKey)) )
1036 {
1028 dist = get_distance (key, &pos->id.hashPubKey); 1037 dist = get_distance (key, &pos->id.hashPubKey);
1029 if (dist < smallest_distance) 1038 if (dist < smallest_distance)
1030 { 1039 {
@@ -1033,7 +1042,11 @@ select_peer (const GNUNET_HashCode *key,
1033 } 1042 }
1034 } 1043 }
1035 else 1044 else
1036 { 1045 {
1046 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1047 "Excluded peer `%s' due to BF match in greedy routing for %s\n",
1048 GNUNET_i2s (&pos->id),
1049 GNUNET_h2s (key));
1037 GNUNET_STATISTICS_update (GDS_stats, 1050 GNUNET_STATISTICS_update (GDS_stats,
1038 gettext_noop ("# Peers excluded from routing due to Bloomfilter"), 1, 1051 gettext_noop ("# Peers excluded from routing due to Bloomfilter"), 1,
1039 GNUNET_NO); 1052 GNUNET_NO);
@@ -1064,6 +1077,10 @@ select_peer (const GNUNET_HashCode *key,
1064 GNUNET_STATISTICS_update (GDS_stats, 1077 GNUNET_STATISTICS_update (GDS_stats,
1065 gettext_noop ("# Peers excluded from routing due to Bloomfilter"), 1, 1078 gettext_noop ("# Peers excluded from routing due to Bloomfilter"), 1,
1066 GNUNET_NO); 1079 GNUNET_NO);
1080 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1081 "Excluded peer `%s' due to BF match in random routing for %s\n",
1082 GNUNET_i2s (&pos->id),
1083 GNUNET_h2s (key));
1067 pos = pos->next; 1084 pos = pos->next;
1068 continue; /* Ignore bloomfiltered peers */ 1085 continue; /* Ignore bloomfiltered peers */
1069 } 1086 }
@@ -1144,8 +1161,15 @@ get_target_peers (const GNUNET_HashCode *key,
1144 rtargets[off] = nxt; 1161 rtargets[off] = nxt;
1145 GNUNET_break (GNUNET_NO == 1162 GNUNET_break (GNUNET_NO ==
1146 GNUNET_CONTAINER_bloomfilter_test (bloom, &nxt->id.hashPubKey)); 1163 GNUNET_CONTAINER_bloomfilter_test (bloom, &nxt->id.hashPubKey));
1147 GNUNET_CONTAINER_bloomfilter_add (bloom, &nxt->id.hashPubKey);
1148 } 1164 }
1165 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1166 "Selected %u/%u peers at hop %u for %s (target was %u)\n",
1167 off,
1168 GNUNET_CONTAINER_multihashmap_size (all_known_peers),
1169 (unsigned int) hop_count,
1170 GNUNET_h2s (key),
1171 ret);
1172
1149 if (0 == off) 1173 if (0 == off)
1150 { 1174 {
1151 GNUNET_free (rtargets); 1175 GNUNET_free (rtargets);
@@ -1153,6 +1177,8 @@ get_target_peers (const GNUNET_HashCode *key,
1153 return 0; 1177 return 0;
1154 } 1178 }
1155 *targets = rtargets; 1179 *targets = rtargets;
1180 for (ret = 0; ret < off; ret++)
1181 GNUNET_CONTAINER_bloomfilter_add (bloom, &rtargets[ret].hashPubKey);
1156 return off; 1182 return off;
1157} 1183}
1158 1184
@@ -1207,7 +1233,12 @@ GDS_NEIGHBOURS_handle_put (enum GNUNET_BLOCK_Type type,
1207 desired_replication_level, 1233 desired_replication_level,
1208 &targets); 1234 &targets);
1209 if (0 == target_count) 1235 if (0 == target_count)
1210 { 1236 {
1237 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1238 "Routing PUT for %s terminates after %u hops at %s\n",
1239 GNUNET_h2s (key),
1240 (unsigned int) hop_count,
1241 GNUNET_i2s (&my_identity));
1211 return; 1242 return;
1212 } 1243 }
1213 msize = put_path_length * sizeof (struct GNUNET_PeerIdentity) + data_size + sizeof (struct PeerPutMessage); 1244 msize = put_path_length * sizeof (struct GNUNET_PeerIdentity) + data_size + sizeof (struct PeerPutMessage);
@@ -1227,6 +1258,11 @@ GDS_NEIGHBOURS_handle_put (enum GNUNET_BLOCK_Type type,
1227 for (i=0;i<target_count;i++) 1258 for (i=0;i<target_count;i++)
1228 { 1259 {
1229 target = targets[i]; 1260 target = targets[i];
1261 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1262 "Routing PUT for %s after %u hops to %s\n",
1263 GNUNET_h2s (key),
1264 (unsigned int) hop_count,
1265 GNUNET_i2s (&target->id));
1230 pending = GNUNET_malloc (sizeof (struct P2PPendingMessage) + msize); 1266 pending = GNUNET_malloc (sizeof (struct P2PPendingMessage) + msize);
1231 pending->importance = 0; /* FIXME */ 1267 pending->importance = 0; /* FIXME */
1232 pending->timeout = expiration_time; 1268 pending->timeout = expiration_time;
@@ -1299,15 +1335,20 @@ GDS_NEIGHBOURS_handle_get (enum GNUNET_BLOCK_Type type,
1299 size_t reply_bf_size; 1335 size_t reply_bf_size;
1300 1336
1301 GNUNET_assert (NULL != peer_bf); 1337 GNUNET_assert (NULL != peer_bf);
1302 GNUNET_CONTAINER_bloomfilter_add (peer_bf, &my_identity.hashPubKey);
1303 GNUNET_STATISTICS_update (GDS_stats, 1338 GNUNET_STATISTICS_update (GDS_stats,
1304 gettext_noop ("# GET requests routed"), 1, 1339 gettext_noop ("# GET requests routed"), 1,
1305 GNUNET_NO); 1340 GNUNET_NO);
1306 target_count = get_target_peers (key, peer_bf, hop_count, 1341 target_count = get_target_peers (key, peer_bf, hop_count,
1307 desired_replication_level, 1342 desired_replication_level,
1308 &targets); 1343 &targets);
1344 GNUNET_CONTAINER_bloomfilter_add (peer_bf, &my_identity.hashPubKey);
1309 if (0 == target_count) 1345 if (0 == target_count)
1310 { 1346 {
1347 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1348 "Routing GET for %s terminates after %u hops at %s\n",
1349 GNUNET_h2s (key),
1350 (unsigned int) hop_count,
1351 GNUNET_i2s (&my_identity));
1311 return; 1352 return;
1312 } 1353 }
1313 reply_bf_size = GNUNET_CONTAINER_bloomfilter_get_size (reply_bf); 1354 reply_bf_size = GNUNET_CONTAINER_bloomfilter_get_size (reply_bf);
@@ -1324,6 +1365,11 @@ GDS_NEIGHBOURS_handle_get (enum GNUNET_BLOCK_Type type,
1324 for (i=0;i<target_count;i++) 1365 for (i=0;i<target_count;i++)
1325 { 1366 {
1326 target = targets[i]; 1367 target = targets[i];
1368 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1369 "Routing GET for %s after %u hops to %s\n",
1370 GNUNET_h2s (key),
1371 (unsigned int) hop_count,
1372 GNUNET_i2s (&target->id));
1327 pending = GNUNET_malloc (sizeof (struct P2PPendingMessage) + msize); 1373 pending = GNUNET_malloc (sizeof (struct P2PPendingMessage) + msize);
1328 pending->importance = 0; /* FIXME */ 1374 pending->importance = 0; /* FIXME */
1329 pending->timeout = GNUNET_TIME_relative_to_absolute (GET_TIMEOUT); 1375 pending->timeout = GNUNET_TIME_relative_to_absolute (GET_TIMEOUT);
@@ -1527,6 +1573,10 @@ handle_dht_p2p_put (void *cls,
1527 /* cannot verify, good luck */ 1573 /* cannot verify, good luck */
1528 break; 1574 break;
1529 } 1575 }
1576 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1577 "PUT for %s at %s\n",
1578 GNUNET_h2s (&put->key),
1579 GNUNET_i2s (&my_identity));
1530 bf = GNUNET_CONTAINER_bloomfilter_init (put->bloomfilter, 1580 bf = GNUNET_CONTAINER_bloomfilter_init (put->bloomfilter,
1531 DHT_BLOOM_SIZE, 1581 DHT_BLOOM_SIZE,
1532 GNUNET_CONSTANTS_BLOOMFILTER_K); 1582 GNUNET_CONSTANTS_BLOOMFILTER_K);
@@ -1757,12 +1807,16 @@ handle_dht_p2p_get (void *cls, const struct GNUNET_PeerIdentity *peer,
1757 &get->key, 1807 &get->key,
1758 xquery, xquery_size, 1808 xquery, xquery_size,
1759 reply_bf, get->bf_mutator); 1809 reply_bf, get->bf_mutator);
1760 1810 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1811 "GET for %s at %s after %u hops\n",
1812 GNUNET_h2s (&get->key),
1813 GNUNET_i2s (&my_identity),
1814 (unsigned int) ntohl (get->hop_count));
1761 /* local lookup (this may update the reply_bf) */ 1815 /* local lookup (this may update the reply_bf) */
1762 if ( (0 != (options & GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE)) || 1816 if ( (0 != (options & GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE)) ||
1763 (am_closest_peer (&get->key, 1817 (am_closest_peer (&get->key,
1764 peer_bf) ) ) 1818 peer_bf) ) )
1765 { 1819 {
1766 if ( (0 != (options & GNUNET_DHT_RO_FIND_PEER))) 1820 if ( (0 != (options & GNUNET_DHT_RO_FIND_PEER)))
1767 { 1821 {
1768 GNUNET_STATISTICS_update (GDS_stats, 1822 GNUNET_STATISTICS_update (GDS_stats,
diff --git a/src/dht/test_dht_multipeer.c b/src/dht/test_dht_multipeer.c
index 6f78dac2e..82d9aa55d 100644
--- a/src/dht/test_dht_multipeer.c
+++ b/src/dht/test_dht_multipeer.c
@@ -36,6 +36,9 @@
36/* Timeout for waiting for replies to get requests */ 36/* Timeout for waiting for replies to get requests */
37#define GET_TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 60) 37#define GET_TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 60)
38 38
39/* */
40#define START_DELAY GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 60)
41
39/* Timeout for waiting for gets to complete */ 42/* Timeout for waiting for gets to complete */
40#define GET_DELAY GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 50) 43#define GET_DELAY GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 50)
41 44
@@ -554,35 +557,16 @@ do_put (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
554} 557}
555 558
556 559
557
558/**
559 * This function is called once testing has finished setting up the topology.
560 *
561 * @param cls unused
562 * @param emsg variable is NULL on success (peers connected), and non-NULL on
563 * failure (peers failed to connect).
564 */
565static void 560static void
566run_dht_test (void *cls, const char *emsg) 561run_dht_test (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
567{ 562{
568 unsigned long long i; 563 unsigned long long i;
569 struct TestPutContext *test_put; 564 struct TestPutContext *test_put;
570 565
571 if (emsg != NULL)
572 {
573 fprintf (stderr,
574 "Failed to setup topology: %s\n",
575 emsg);
576 die_task =
577 GNUNET_SCHEDULER_add_now (&end_badly,
578 "topology setup failed");
579 return;
580 }
581
582#if PATH_TRACKING 566#if PATH_TRACKING
583 route_option = GNUNET_DHT_RO_RECORD_ROUTE | GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE; 567 route_option = GNUNET_DHT_RO_RECORD_ROUTE | GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE;
584#else 568#else
585 route_option = GNUNET_DHT_RO_NONE | GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE; 569 route_option = GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE;
586#endif 570#endif
587 die_task = 571 die_task =
588 GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, 572 GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly,
@@ -603,6 +587,32 @@ run_dht_test (void *cls, const char *emsg)
603} 587}
604 588
605 589
590/**
591 * This function is called once testing has finished setting up the topology.
592 *
593 * @param cls unused
594 * @param emsg variable is NULL on success (peers connected), and non-NULL on
595 * failure (peers failed to connect).
596 */
597static void
598startup_done (void *cls, const char *emsg)
599{
600 if (emsg != NULL)
601 {
602 fprintf (stderr,
603 "Failed to setup topology: %s\n",
604 emsg);
605 die_task =
606 GNUNET_SCHEDULER_add_now (&end_badly,
607 "topology setup failed");
608 return;
609 }
610 die_task =
611 GNUNET_SCHEDULER_add_delayed (START_DELAY, &run_dht_test,
612 "from setup puts/gets");
613}
614
615
606static void 616static void
607run (void *cls, char *const *args, const char *cfgfile, 617run (void *cls, char *const *args, const char *cfgfile,
608 const struct GNUNET_CONFIGURATION_Handle *cfg) 618 const struct GNUNET_CONFIGURATION_Handle *cfg)
@@ -624,7 +634,7 @@ run (void *cls, char *const *args, const char *cfgfile,
624 num_peers, 634 num_peers,
625 TIMEOUT, 635 TIMEOUT,
626 NULL, 636 NULL,
627 &run_dht_test, 637 &startup_done,
628 NULL, 638 NULL,
629 NULL); 639 NULL);
630 GNUNET_assert (NULL != pg); 640 GNUNET_assert (NULL != pg);