aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNathan S. Evans <evans@in.tum.de>2010-07-30 14:41:29 +0000
committerNathan S. Evans <evans@in.tum.de>2010-07-30 14:41:29 +0000
commitdf381b2e92568aed1d7ac2881e89c9ad169cb2eb (patch)
tree94f6a86aee0274594c2f3e17aac53b31a6f104ac /src
parent90aa70b2a5cfacf36b77dcadf0755a4a9ee90d5e (diff)
downloadgnunet-df381b2e92568aed1d7ac2881e89c9ad169cb2eb.tar.gz
gnunet-df381b2e92568aed1d7ac2881e89c9ad169cb2eb.zip
some dht changes
Diffstat (limited to 'src')
-rw-r--r--src/dht/Makefile.am35
-rw-r--r--src/dht/dht_api.c6
-rw-r--r--src/dht/dhtlog.c1
-rw-r--r--src/dht/gnunet-dht-driver.c118
-rw-r--r--src/dht/gnunet-service-dht.c118
-rw-r--r--src/dht/plugin_dhtlog_mysql_dump.c25
-rw-r--r--src/dht/test_dht_multipeer_data.conf25
-rw-r--r--src/dht/test_dhtlog_data.conf3
8 files changed, 245 insertions, 86 deletions
diff --git a/src/dht/Makefile.am b/src/dht/Makefile.am
index b96ce45e7..9c9ce7cad 100644
--- a/src/dht/Makefile.am
+++ b/src/dht/Makefile.am
@@ -22,7 +22,18 @@ lib_LTLIBRARIES = libgnunetdht.la \
22 libgnunetdhtlog.la 22 libgnunetdhtlog.la
23 23
24plugin_LTLIBRARIES = \ 24plugin_LTLIBRARIES = \
25 libgnunet_plugin_dhtlog_dummy.la $(MYSQL_PLUGIN) 25 libgnunet_plugin_dhtlog_dummy.la $(MYSQL_PLUGIN) \
26 libgnunet_plugin_dhtlog_mysql_dump.la
27
28if HAVE_MYSQL
29libgnunet_plugin_dhtlog_mysql_la_SOURCES = \
30 plugin_dhtlog_mysql.c
31libgnunet_plugin_dhtlog_mysql_la_LIBADD = \
32 $(top_builddir)/src/util/libgnunetutil.la \
33 $(XLIB)
34libgnunet_plugin_dhtlog_mysql_la_LDFLAGS = \
35 $(GN_PLUGIN_LDFLAGS) $(MYSQL_LDFLAGS) -lmysqlclient $(ZLIB_LNK)
36endif
26 37
27libgnunet_plugin_dhtlog_dummy_la_SOURCES = \ 38libgnunet_plugin_dhtlog_dummy_la_SOURCES = \
28 plugin_dhtlog_dummy.c 39 plugin_dhtlog_dummy.c
@@ -31,6 +42,14 @@ libgnunet_plugin_dhtlog_dummy_la_LIBADD = \
31 $(XLIB) 42 $(XLIB)
32libgnunet_plugin_dhtlog_dummy_la_LDFLAGS = \ 43libgnunet_plugin_dhtlog_dummy_la_LDFLAGS = \
33 $(GN_PLUGIN_LDFLAGS) 44 $(GN_PLUGIN_LDFLAGS)
45
46libgnunet_plugin_dhtlog_mysql_dump_la_SOURCES = \
47 plugin_dhtlog_mysql_dump.c
48libgnunet_plugin_dhtlog_mysql_dump_la_LIBADD = \
49 $(top_builddir)/src/util/libgnunetutil.la \
50 $(XLIB)
51libgnunet_plugin_dhtlog_mysql_dump_la_LDFLAGS = \
52 $(GN_PLUGIN_LDFLAGS)
34 53
35libgnunetdhtlog_la_SOURCES = \ 54libgnunetdhtlog_la_SOURCES = \
36 dhtlog.c dhtlog.h 55 dhtlog.c dhtlog.h
@@ -40,18 +59,6 @@ libgnunetdhtlog_la_LDFLAGS = \
40 $(GN_LIB_LDFLAGS) $(WINFLAGS) \ 59 $(GN_LIB_LDFLAGS) $(WINFLAGS) \
41 -version-info 0:0:0 60 -version-info 0:0:0
42 61
43if HAVE_MYSQL
44libgnunet_plugin_dhtlog_mysql_la_SOURCES = \
45 plugin_dhtlog_mysql.c
46libgnunet_plugin_dhtlog_mysql_la_LIBADD = \
47 $(top_builddir)/src/util/libgnunetutil.la \
48 $(XLIB)
49libgnunet_plugin_dhtlog_mysql_la_LDFLAGS = \
50 $(GN_PLUGIN_LDFLAGS) $(MYSQL_LDFLAGS) -lmysqlclient $(ZLIB_LNK)
51libgnunet_plugin_dhtlog_mysql_la_CPPFLAGS = \
52 $(MYSQL_CPPFLAGS)
53endif
54
55libgnunetdht_la_SOURCES = \ 62libgnunetdht_la_SOURCES = \
56 dht_api.c dht.h 63 dht_api.c dht.h
57libgnunetdht_la_LIBADD = \ 64libgnunetdht_la_LIBADD = \
@@ -75,7 +82,7 @@ bin_PROGRAMS = $(STUD_PROGS) \
75 gnunet-dht-put 82 gnunet-dht-put
76 83
77noinst_PROGRAMS = \ 84noinst_PROGRAMS = \
78 gnunet-dht-driver 85 gnunet-dht-driver ${check_PROGRAMS}
79 86
80gnunet_service_dht_SOURCES = \ 87gnunet_service_dht_SOURCES = \
81 gnunet-service-dht.c 88 gnunet-service-dht.c
diff --git a/src/dht/dht_api.c b/src/dht/dht_api.c
index 2558f3a7d..58493dd0f 100644
--- a/src/dht/dht_api.c
+++ b/src/dht/dht_api.c
@@ -365,6 +365,7 @@ finish (struct GNUNET_DHT_Handle *handle, int code)
365 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 365 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
366 } 366 }
367 367
368 GNUNET_assert(handle->th == NULL);
368 if (pos->unique_id == 0) 369 if (pos->unique_id == 0)
369 GNUNET_free(pos->msg); 370 GNUNET_free(pos->msg);
370 GNUNET_free (pos); 371 GNUNET_free (pos);
@@ -570,6 +571,7 @@ service_message_handler (void *cls,
570 handle->cfg); 571 handle->cfg);
571 if (handle->current != NULL) 572 if (handle->current != NULL)
572 { 573 {
574 handle->th = NULL;
573 finish(handle, GNUNET_SYSERR); /* If there was a current message, kill it! */ 575 finish(handle, GNUNET_SYSERR); /* If there was a current message, kill it! */
574 } 576 }
575#if RETRANSMIT 577#if RETRANSMIT
@@ -686,7 +688,7 @@ GNUNET_DHT_disconnect (struct GNUNET_DHT_Handle *handle)
686 "`%s': Called GNUNET_DHT_disconnect\n", "DHT API"); 688 "`%s': Called GNUNET_DHT_disconnect\n", "DHT API");
687#endif 689#endif
688 GNUNET_assert (handle != NULL); 690 GNUNET_assert (handle != NULL);
689 if (handle->th != NULL) /* We have a live transmit request in the Aether */ 691 if (handle->th != NULL) /* We have a live transmit request */
690 { 692 {
691 GNUNET_CLIENT_notify_transmit_ready_cancel (handle->th); 693 GNUNET_CLIENT_notify_transmit_ready_cancel (handle->th);
692 handle->th = NULL; 694 handle->th = NULL;
@@ -1176,6 +1178,7 @@ GNUNET_DHT_put (struct GNUNET_DHT_Handle *handle,
1176 1178
1177 if ((handle->current != NULL) && (handle->retransmit_stage != DHT_RETRANSMITTING)) 1179 if ((handle->current != NULL) && (handle->retransmit_stage != DHT_RETRANSMITTING))
1178 { 1180 {
1181 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "handle->current is not null!\n");
1179 if (cont != NULL) 1182 if (cont != NULL)
1180 { 1183 {
1181 GNUNET_SCHEDULER_add_continuation (handle->sched, cont, cont_cls, 1184 GNUNET_SCHEDULER_add_continuation (handle->sched, cont, cont_cls,
@@ -1204,6 +1207,7 @@ GNUNET_DHT_put (struct GNUNET_DHT_Handle *handle,
1204 1207
1205 if (put_route == NULL) /* Route start failed! */ 1208 if (put_route == NULL) /* Route start failed! */
1206 { 1209 {
1210 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "route start for PUT failed!\n");
1207 if (cont != NULL) 1211 if (cont != NULL)
1208 { 1212 {
1209 GNUNET_SCHEDULER_add_continuation (handle->sched, cont, cont_cls, 1213 GNUNET_SCHEDULER_add_continuation (handle->sched, cont, cont_cls,
diff --git a/src/dht/dhtlog.c b/src/dht/dhtlog.c
index 37e9c2d95..ebc7075da 100644
--- a/src/dht/dhtlog.c
+++ b/src/dht/dhtlog.c
@@ -65,6 +65,7 @@ GNUNET_DHTLOG_connect (const struct GNUNET_CONFIGURATION_Handle *c)
65 _("Failed to load dhtlog plugin for `%s'\n"), plugin_name); 65 _("Failed to load dhtlog plugin for `%s'\n"), plugin_name);
66 GNUNET_free (plugin_name); 66 GNUNET_free (plugin_name);
67 GNUNET_free (plugin); 67 GNUNET_free (plugin);
68 return NULL;
68 } 69 }
69 70
70 api = plugin->dhtlog_api; 71 api = plugin->dhtlog_api;
diff --git a/src/dht/gnunet-dht-driver.c b/src/dht/gnunet-dht-driver.c
index 2081df970..dd2ffe1b3 100644
--- a/src/dht/gnunet-dht-driver.c
+++ b/src/dht/gnunet-dht-driver.c
@@ -22,12 +22,7 @@
22 * @brief Driver for setting up a group of gnunet peers and 22 * @brief Driver for setting up a group of gnunet peers and
23 * then issuing GETS and PUTS on the DHT. Coarse results 23 * then issuing GETS and PUTS on the DHT. Coarse results
24 * are reported, fine grained results (if requested) are 24 * are reported, fine grained results (if requested) are
25 * logged to a (mysql) database. 25 * logged to a (mysql) database, or to file.
26 *
27 * TODO: Add multiple database support; alternatively, dump
28 * sql readable (or easily transformed) logs to disk
29 * for reassembly later. This could remove the mysql
30 * server as a bottleneck during testing.
31 */ 26 */
32#include "platform.h" 27#include "platform.h"
33#include "gnunet_testing_lib.h" 28#include "gnunet_testing_lib.h"
@@ -36,7 +31,7 @@
36#include "dhtlog.h" 31#include "dhtlog.h"
37 32
38/* DEFINES */ 33/* DEFINES */
39#define VERBOSE GNUNET_YES 34#define VERBOSE GNUNET_NO
40 35
41/* Timeout for entire driver to run */ 36/* Timeout for entire driver to run */
42#define DEFAULT_TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MINUTES, 5) 37#define DEFAULT_TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MINUTES, 5)
@@ -405,6 +400,7 @@ put_disconnect_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc)
405static void 400static void
406finish_testing (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) 401finish_testing (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc)
407{ 402{
403 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Ending test normally!\n", (char *)cls);
408 GNUNET_assert (pg != NULL); 404 GNUNET_assert (pg != NULL);
409 struct TestPutContext *test_put = all_puts; 405 struct TestPutContext *test_put = all_puts;
410 struct TestGetContext *test_get = all_gets; 406 struct TestGetContext *test_get = all_gets;
@@ -433,17 +429,20 @@ finish_testing (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc)
433 429
434 /* FIXME: optionally get stats for dropped messages, etc. */ 430 /* FIXME: optionally get stats for dropped messages, etc. */
435 if (dhtlog_handle != NULL) 431 if (dhtlog_handle != NULL)
436 dhtlog_handle->update_trial (trialuid, 0, 0, 0); 432 {
433 fprintf(stderr, "Update trial endtime\n");
434 dhtlog_handle->update_trial (trialuid, 0, 0, 0);
435 }
437 436
438 if (hostkey_meter != NULL) 437 if (hostkey_meter != NULL)
439 free_meter(hostkey_meter); 438 free_meter(hostkey_meter);
440 if (hostkey_meter != NULL) 439 if (peer_start_meter != NULL)
441 free_meter(peer_start_meter); 440 free_meter(peer_start_meter);
442 if (hostkey_meter != NULL) 441 if (peer_connect_meter != NULL)
443 free_meter(peer_connect_meter); 442 free_meter(peer_connect_meter);
444 if (hostkey_meter != NULL) 443 if (put_meter != NULL)
445 free_meter(put_meter); 444 free_meter(put_meter);
446 if (hostkey_meter != NULL) 445 if (get_meter != NULL)
447 free_meter(get_meter); 446 free_meter(get_meter);
448 447
449 ok = 0; 448 ok = 0;
@@ -458,7 +457,7 @@ finish_testing (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc)
458static void 457static void
459end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) 458end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc)
460{ 459{
461 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Failing test with error: `%s'!\n", (char *)cls); 460 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Failing test with error: `%s'!\n", (char *)cls);
462 461
463 struct TestPutContext *test_put = all_puts; 462 struct TestPutContext *test_put = all_puts;
464 struct TestGetContext *test_get = all_gets; 463 struct TestGetContext *test_get = all_gets;
@@ -485,15 +484,22 @@ end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc)
485 484
486 GNUNET_TESTING_daemons_stop (pg, DEFAULT_TIMEOUT, &shutdown_callback, NULL); 485 GNUNET_TESTING_daemons_stop (pg, DEFAULT_TIMEOUT, &shutdown_callback, NULL);
487 486
487 /* FIXME: optionally get stats for dropped messages, etc. */
488 if (dhtlog_handle != NULL)
489 {
490 fprintf(stderr, "Update trial endtime\n");
491 dhtlog_handle->update_trial (trialuid, 0, 0, 0);
492 }
493
488 if (hostkey_meter != NULL) 494 if (hostkey_meter != NULL)
489 free_meter(hostkey_meter); 495 free_meter(hostkey_meter);
490 if (hostkey_meter != NULL) 496 if (peer_start_meter != NULL)
491 free_meter(peer_start_meter); 497 free_meter(peer_start_meter);
492 if (hostkey_meter != NULL) 498 if (peer_connect_meter != NULL)
493 free_meter(peer_connect_meter); 499 free_meter(peer_connect_meter);
494 if (hostkey_meter != NULL) 500 if (put_meter != NULL)
495 free_meter(put_meter); 501 free_meter(put_meter);
496 if (hostkey_meter != NULL) 502 if (get_meter != NULL)
497 free_meter(get_meter); 503 free_meter(get_meter);
498 504
499 ok = 1; 505 ok = 1;
@@ -613,6 +619,7 @@ do_get (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc)
613 } 619 }
614 if (test_get == NULL) 620 if (test_get == NULL)
615 return; /* End of the list */ 621 return; /* End of the list */
622
616 memset(data, test_get->uid, sizeof(data)); 623 memset(data, test_get->uid, sizeof(data));
617 GNUNET_CRYPTO_hash(data, test_data_size, &key); 624 GNUNET_CRYPTO_hash(data, test_data_size, &key);
618 625
@@ -654,6 +661,9 @@ put_finished (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc)
654 outstanding_puts--; 661 outstanding_puts--;
655 puts_completed++; 662 puts_completed++;
656 663
664 if (tc->reason == GNUNET_SCHEDULER_REASON_TIMEOUT)
665 fprintf(stderr, "PUT Request failed!\n");
666
657 GNUNET_SCHEDULER_cancel(sched, test_put->disconnect_task); 667 GNUNET_SCHEDULER_cancel(sched, test_put->disconnect_task);
658 test_put->disconnect_task = GNUNET_SCHEDULER_add_now(sched, &put_disconnect_task, test_put); 668 test_put->disconnect_task = GNUNET_SCHEDULER_add_now(sched, &put_disconnect_task, test_put);
659 if (GNUNET_YES == update_meter(put_meter)) 669 if (GNUNET_YES == update_meter(put_meter))
@@ -662,7 +672,7 @@ put_finished (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc)
662 GNUNET_SCHEDULER_cancel (sched, die_task); 672 GNUNET_SCHEDULER_cancel (sched, die_task);
663 die_task = GNUNET_SCHEDULER_add_delayed (sched, all_get_timeout, 673 die_task = GNUNET_SCHEDULER_add_delayed (sched, all_get_timeout,
664 &end_badly, "from do gets"); 674 &end_badly, "from do gets");
665 GNUNET_SCHEDULER_add_delayed(sched, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 100), &do_get, all_gets); 675 GNUNET_SCHEDULER_add_delayed(sched, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, settle_time), &do_get, all_gets);
666 return; 676 return;
667 } 677 }
668} 678}
@@ -749,7 +759,7 @@ setup_puts_and_gets (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc)
749 all_gets = test_get; 759 all_gets = test_get;
750 } 760 }
751 761
752 GNUNET_SCHEDULER_cancel (sched, die_task); 762 /*GNUNET_SCHEDULER_cancel (sched, die_task);*/
753 die_task = GNUNET_SCHEDULER_add_delayed (sched, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, num_puts * 2), 763 die_task = GNUNET_SCHEDULER_add_delayed (sched, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, num_puts * 2),
754 &end_badly, "from do puts"); 764 &end_badly, "from do puts");
755 GNUNET_SCHEDULER_add_now (sched, &do_put, all_puts); 765 GNUNET_SCHEDULER_add_now (sched, &do_put, all_puts);
@@ -805,8 +815,8 @@ topology_callback (void *cls,
805 dhtlog_handle->update_connections (trialuid, total_connections); 815 dhtlog_handle->update_connections (trialuid, total_connections);
806 816
807 GNUNET_SCHEDULER_cancel (sched, die_task); 817 GNUNET_SCHEDULER_cancel (sched, die_task);
808 die_task = GNUNET_SCHEDULER_add_delayed (sched, DEFAULT_TIMEOUT, 818 /*die_task = GNUNET_SCHEDULER_add_delayed (sched, DEFAULT_TIMEOUT,
809 &end_badly, "from setup puts/gets"); 819 &end_badly, "from setup puts/gets");*/
810 820
811 GNUNET_SCHEDULER_add_delayed (sched, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, settle_time), &setup_puts_and_gets, NULL); 821 GNUNET_SCHEDULER_add_delayed (sched, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, settle_time), &setup_puts_and_gets, NULL);
812 } 822 }
@@ -947,6 +957,8 @@ run (void *cls,
947 char *const *args, 957 char *const *args,
948 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) 958 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
949{ 959{
960 struct GNUNET_TESTING_Host *hosts;
961 struct GNUNET_TESTING_Host *temphost;
950 char * topology_str; 962 char * topology_str;
951 char * connect_topology_str; 963 char * connect_topology_str;
952 char * blacklist_topology_str; 964 char * blacklist_topology_str;
@@ -956,8 +968,14 @@ run (void *cls,
956 char * topology_percentage_str; 968 char * topology_percentage_str;
957 float topology_percentage; 969 float topology_percentage;
958 char * topology_probability_str; 970 char * topology_probability_str;
971 char * hostfile;
959 float topology_probability; 972 float topology_probability;
960 unsigned long long temp_config_number; 973 unsigned long long temp_config_number;
974 char *buf;
975 char *data;
976
977 struct stat frstat;
978 int count;
961 979
962 sched = s; 980 sched = s;
963 981
@@ -986,10 +1004,62 @@ run (void *cls,
986 1004
987 if (GNUNET_OK != 1005 if (GNUNET_OK !=
988 GNUNET_CONFIGURATION_get_value_string (cfg, "dht_testing", "comment", 1006 GNUNET_CONFIGURATION_get_value_string (cfg, "dht_testing", "comment",
989 &trialmessage)) 1007 &trialmessage))
990 trialmessage = NULL; 1008 trialmessage = NULL;
991 1009
992 if (GNUNET_OK != 1010 if (GNUNET_OK !=
1011 GNUNET_CONFIGURATION_get_value_string (cfg, "testing", "hostfile",
1012 &hostfile))
1013 hostfile = NULL;
1014
1015 hosts = NULL;
1016 if (hostfile != NULL)
1017 {
1018 if (GNUNET_OK != GNUNET_DISK_file_test (hostfile))
1019 GNUNET_DISK_fn_write (hostfile, NULL, 0, GNUNET_DISK_PERM_USER_READ
1020 | GNUNET_DISK_PERM_USER_WRITE);
1021 if ((0 != STAT (hostfile, &frstat)) || (frstat.st_size == 0))
1022 {
1023 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1024 "Could not open file specified for host list, ending test!");
1025 ok = 1119;
1026 GNUNET_free_non_null(trialmessage);
1027 GNUNET_free(hostfile);
1028 return;
1029 }
1030
1031 data = GNUNET_malloc_large (frstat.st_size);
1032 GNUNET_assert(data != NULL);
1033 if (frstat.st_size !=
1034 GNUNET_DISK_fn_read (hostfile, data, frstat.st_size))
1035 {
1036 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1037 "Could not read file %s specified for host list, ending test!", hostfile);
1038 GNUNET_free (hostfile);
1039 GNUNET_free (data);
1040 return;
1041 }
1042
1043 buf = data;
1044 count = 0;
1045 while (count < frstat.st_size)
1046 {
1047 count++;
1048 if (((data[count] == '\n') || (data[count] == '\0')) && (buf != &data[count]))
1049 {
1050 data[count] = '\0';
1051 temphost = GNUNET_malloc(sizeof(struct GNUNET_TESTING_Host));
1052 temphost->hostname = buf;
1053 temphost->next = hosts;
1054 hosts = temphost;
1055 buf = &data[count + 1];
1056 }
1057 else if ((data[count] == '\n') || (data[count] == '\0'))
1058 buf = &data[count + 1];
1059 }
1060 }
1061
1062 if (GNUNET_OK !=
993 GNUNET_CONFIGURATION_get_value_number (cfg, "dht_testing", "malicious_getters", 1063 GNUNET_CONFIGURATION_get_value_number (cfg, "dht_testing", "malicious_getters",
994 &malicious_getters)) 1064 &malicious_getters))
995 malicious_getters = 0; 1065 malicious_getters = 0;
@@ -1199,7 +1269,7 @@ run (void *cls,
1199 hostkey_meter = create_meter(peers_left, "Hostkeys created ", GNUNET_YES); 1269 hostkey_meter = create_meter(peers_left, "Hostkeys created ", GNUNET_YES);
1200 peer_start_meter = create_meter(peers_left, "Peers started ", GNUNET_YES); 1270 peer_start_meter = create_meter(peers_left, "Peers started ", GNUNET_YES);
1201 1271
1202 put_meter = create_meter(num_gets, "Puts completed ", GNUNET_YES); 1272 put_meter = create_meter(num_puts, "Puts completed ", GNUNET_YES);
1203 get_meter = create_meter(num_gets, "Gets completed ", GNUNET_YES); 1273 get_meter = create_meter(num_gets, "Gets completed ", GNUNET_YES);
1204 pg = GNUNET_TESTING_daemons_start (sched, cfg, 1274 pg = GNUNET_TESTING_daemons_start (sched, cfg,
1205 peers_left, 1275 peers_left,
@@ -1207,7 +1277,7 @@ run (void *cls,
1207 &hostkey_callback, NULL, 1277 &hostkey_callback, NULL,
1208 &peers_started_callback, NULL, 1278 &peers_started_callback, NULL,
1209 &topology_callback, NULL, 1279 &topology_callback, NULL,
1210 NULL); 1280 hosts);
1211 1281
1212} 1282}
1213 1283
diff --git a/src/dht/gnunet-service-dht.c b/src/dht/gnunet-service-dht.c
index 31ceff773..00dc2fc72 100644
--- a/src/dht/gnunet-service-dht.c
+++ b/src/dht/gnunet-service-dht.c
@@ -58,6 +58,12 @@
58 */ 58 */
59#define MINIMUM_PEER_THRESHOLD 20 59#define MINIMUM_PEER_THRESHOLD 20
60 60
61#define DHT_DEFAULT_FIND_PEER_REPLICATION 20
62
63#define DHT_DEFAULT_FIND_PEER_OPTIONS GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE
64
65#define DHT_DEFAULT_FIND_PEER_INTERVAL GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MINUTES, 5)
66
61/** 67/**
62 * Real maximum number of hops, at which point we refuse 68 * Real maximum number of hops, at which point we refuse
63 * to forward the message. 69 * to forward the message.
@@ -1064,6 +1070,8 @@ add_pending_message (struct ClientList *client,
1064} 1070}
1065 1071
1066 1072
1073
1074
1067/** 1075/**
1068 * Called when a reply needs to be sent to a client, as 1076 * Called when a reply needs to be sent to a client, as
1069 * a result it found to a GET or FIND PEER request. 1077 * a result it found to a GET or FIND PEER request.
@@ -1120,7 +1128,35 @@ static int route_result_message(void *cls,
1120 struct DHTQueryRecord *record; 1128 struct DHTQueryRecord *record;
1121 struct DHTRouteSource *pos; 1129 struct DHTRouteSource *pos;
1122 struct PeerInfo *peer_info; 1130 struct PeerInfo *peer_info;
1131 struct GNUNET_MessageHeader *hello_msg;
1123 1132
1133 /**
1134 * If a find peer result message is received and contains a valid
1135 * HELLO for another peer, offer it to the transport service.
1136 *
1137 * FIXME: Check whether we need this peer (based on routing table
1138 * fullness) and only try to connect to it conditionally. This should
1139 * reduce trying to connect to say (500) peers when the bucket size will
1140 * discard most of them.
1141 */
1142 if (ntohs(msg->type) == GNUNET_MESSAGE_TYPE_DHT_FIND_PEER_RESULT)
1143 {
1144 if (ntohs(msg->size) <= sizeof(struct GNUNET_MessageHeader))
1145 GNUNET_break_op(0);
1146
1147 hello_msg = &msg[1];
1148 if (ntohs(hello_msg->type) != GNUNET_MESSAGE_TYPE_HELLO)
1149 {
1150 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "%s:%s Received non-HELLO message type in find peer result message!\n", my_short_id, "DHT");
1151 GNUNET_break_op(0);
1152 }
1153 else
1154 {
1155 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "%s:%s Received HELLO message for another peer, offering to transport!\n", my_short_id, "DHT");
1156 GNUNET_TRANSPORT_offer_hello(transport_handle, hello_msg);
1157 }
1158
1159 }
1124 record = GNUNET_CONTAINER_multihashmap_get(forward_list.hashmap, message_context->key); 1160 record = GNUNET_CONTAINER_multihashmap_get(forward_list.hashmap, message_context->key);
1125 if (record == NULL) /* No record of this message! */ 1161 if (record == NULL) /* No record of this message! */
1126 { 1162 {
@@ -1131,13 +1167,6 @@ static int route_result_message(void *cls,
1131#endif 1167#endif
1132#if DEBUG_DHT_ROUTING 1168#if DEBUG_DHT_ROUTING
1133 1169
1134 /*if ((debug_routes) && (dhtlog_handle != NULL))
1135 {
1136 dhtlog_handle->insert_query (NULL, message_context->unique_id, DHTLOG_RESULT,
1137 message_context->hop_count, GNUNET_SYSERR,
1138 &my_identity, message_context->key);
1139 }*/
1140
1141 if ((debug_routes_extended) && (dhtlog_handle != NULL)) 1170 if ((debug_routes_extended) && (dhtlog_handle != NULL))
1142 { 1171 {
1143 dhtlog_handle->insert_route (NULL, 1172 dhtlog_handle->insert_route (NULL,
@@ -1161,7 +1190,7 @@ static int route_result_message(void *cls,
1161 pos = record->head; 1190 pos = record->head;
1162 while (pos != NULL) 1191 while (pos != NULL)
1163 { 1192 {
1164 if (0 == memcmp(&pos->source, &my_identity, sizeof(struct GNUNET_PeerIdentity))) /* Local client initiated request! */ 1193 if (0 == memcmp(&pos->source, &my_identity, sizeof(struct GNUNET_PeerIdentity))) /* Local client (or DHT) initiated request! */
1165 { 1194 {
1166#if DEBUG_DHT 1195#if DEBUG_DHT
1167 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1196 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -1169,14 +1198,6 @@ static int route_result_message(void *cls,
1169 "DHT", GNUNET_h2s (message_context->key), message_context->unique_id); 1198 "DHT", GNUNET_h2s (message_context->key), message_context->unique_id);
1170#endif 1199#endif
1171#if DEBUG_DHT_ROUTING 1200#if DEBUG_DHT_ROUTING
1172 /*
1173 if ((debug_routes) && (dhtlog_handle != NULL))
1174 {
1175 dhtlog_handle->insert_query (NULL, message_context->unique_id, DHTLOG_RESULT,
1176 message_context->hop_count, GNUNET_YES,
1177 &my_identity, message_context->key);
1178 }*/
1179
1180 if ((debug_routes_extended) && (dhtlog_handle != NULL)) 1201 if ((debug_routes_extended) && (dhtlog_handle != NULL))
1181 { 1202 {
1182 dhtlog_handle->insert_route (NULL, message_context->unique_id, DHTLOG_RESULT, 1203 dhtlog_handle->insert_route (NULL, message_context->unique_id, DHTLOG_RESULT,
@@ -1406,15 +1427,15 @@ handle_dht_find_peer (void *cls,
1406 GNUNET_break_op (0); 1427 GNUNET_break_op (0);
1407 return; 1428 return;
1408 } 1429 }
1430
1409 find_peer_result = GNUNET_malloc (tsize); 1431 find_peer_result = GNUNET_malloc (tsize);
1410 find_peer_result->type = htons (GNUNET_MESSAGE_TYPE_DHT_FIND_PEER_RESULT); 1432 find_peer_result->type = htons (GNUNET_MESSAGE_TYPE_DHT_FIND_PEER_RESULT);
1411 find_peer_result->size = htons (tsize); 1433 find_peer_result->size = htons (tsize);
1412 memcpy (&find_peer_result[1], my_hello, hello_size); 1434 memcpy (&find_peer_result[1], my_hello, hello_size);
1413#if DEBUG_DHT_HELLO 1435
1414 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1436 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1415 "`%s': Sending hello size %d to client.\n", 1437 "`%s': Sending hello size %d to requesting peer.\n",
1416 "DHT", hello_size); 1438 "DHT", hello_size);
1417#endif
1418 1439
1419 new_msg_ctx = GNUNET_malloc(sizeof(struct DHT_MessageContext)); 1440 new_msg_ctx = GNUNET_malloc(sizeof(struct DHT_MessageContext));
1420 memcpy(new_msg_ctx, message_context, sizeof(struct DHT_MessageContext)); 1441 memcpy(new_msg_ctx, message_context, sizeof(struct DHT_MessageContext));
@@ -1996,10 +2017,13 @@ static int route_message(void *cls,
1996 } 2017 }
1997#endif 2018#endif
1998 break; 2019 break;
1999 case GNUNET_MESSAGE_TYPE_DHT_FIND_PEER: /* Check if closest, check options, add to requests seen */ 2020 case GNUNET_MESSAGE_TYPE_DHT_FIND_PEER: /* Check if closest and not started by us, check options, add to requests seen */
2000 cache_response (cls, message_context); 2021 if (0 != memcmp(message_context->peer, &my_identity, sizeof(struct GNUNET_PeerIdentity)))
2001 if ((message_context->closest == GNUNET_YES) || (message_context->msg_options == GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE)) 2022 {
2002 handle_dht_find_peer (cls, msg, message_context); 2023 cache_response (cls, message_context);
2024 if ((message_context->closest == GNUNET_YES) || (message_context->msg_options == GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE))
2025 handle_dht_find_peer (cls, msg, message_context);
2026 }
2003 break; 2027 break;
2004 default: 2028 default:
2005 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 2029 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
@@ -2082,6 +2106,45 @@ find_active_client (struct GNUNET_SERVER_Client *client)
2082} 2106}
2083 2107
2084/** 2108/**
2109 * Task to send a find peer message for our own peer identifier
2110 * so that we can find the closest peers in the network to ourselves
2111 * and attempt to connect to them.
2112 *
2113 * @param cls closure for this task
2114 * @param tc the context under which the task is running
2115 */
2116static void
2117send_find_peer_message (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
2118{
2119 struct GNUNET_MessageHeader *find_peer_msg;
2120 struct DHT_MessageContext message_context;
2121 int ret;
2122
2123 if (tc->reason == GNUNET_SCHEDULER_REASON_SHUTDOWN)
2124 return;
2125
2126 find_peer_msg = GNUNET_malloc(sizeof(struct GNUNET_MessageHeader));
2127 find_peer_msg->size = htons(sizeof(struct GNUNET_MessageHeader));
2128 find_peer_msg->type = htons(GNUNET_MESSAGE_TYPE_DHT_FIND_PEER);
2129 memset(&message_context, 0, sizeof(struct DHT_MessageContext));
2130 message_context.key = &my_identity.hashPubKey;
2131 message_context.unique_id = GNUNET_ntohll (GNUNET_CRYPTO_random_u64(GNUNET_CRYPTO_QUALITY_WEAK, (uint64_t)-1));
2132 message_context.replication = ntohl (DHT_DEFAULT_FIND_PEER_REPLICATION);
2133 message_context.msg_options = ntohl (DHT_DEFAULT_FIND_PEER_OPTIONS);
2134 message_context.network_size = estimate_diameter();
2135 message_context.peer = &my_identity;
2136
2137 ret = route_message(NULL, find_peer_msg, &message_context);
2138
2139 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2140 "`%s:%s': Sent `%s' request to %d peers\n", my_short_id, "DHT",
2141 "FIND PEER", ret);
2142 GNUNET_SCHEDULER_add_delayed (sched,
2143 DHT_DEFAULT_FIND_PEER_INTERVAL,
2144 &send_find_peer_message, NULL);
2145}
2146
2147/**
2085 * Handler for any generic DHT messages, calls the appropriate handler 2148 * Handler for any generic DHT messages, calls the appropriate handler
2086 * depending on message type, sends confirmation if responses aren't otherwise 2149 * depending on message type, sends confirmation if responses aren't otherwise
2087 * expected. 2150 * expected.
@@ -2491,10 +2554,13 @@ run (void *cls,
2491 { 2554 {
2492 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 2555 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
2493 "Could not connect to mysql logging server, logging will not happen!"); 2556 "Could not connect to mysql logging server, logging will not happen!");
2494 return;
2495 } 2557 }
2496 } 2558 }
2497 2559
2560 GNUNET_SCHEDULER_add_delayed (sched,
2561 GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 30),
2562 &send_find_peer_message, NULL);
2563
2498 cleanup_task = GNUNET_SCHEDULER_add_delayed (sched, 2564 cleanup_task = GNUNET_SCHEDULER_add_delayed (sched,
2499 GNUNET_TIME_UNIT_FOREVER_REL, 2565 GNUNET_TIME_UNIT_FOREVER_REL,
2500 &shutdown_task, NULL); 2566 &shutdown_task, NULL);
diff --git a/src/dht/plugin_dhtlog_mysql_dump.c b/src/dht/plugin_dhtlog_mysql_dump.c
index c71f38c87..ade031c02 100644
--- a/src/dht/plugin_dhtlog_mysql_dump.c
+++ b/src/dht/plugin_dhtlog_mysql_dump.c
@@ -122,6 +122,7 @@ iopen ()
122 return GNUNET_SYSERR; 122 return GNUNET_SYSERR;
123 } 123 }
124#undef PINIT 124#undef PINIT
125
125 return GNUNET_OK; 126 return GNUNET_OK;
126} 127}
127 128
@@ -160,7 +161,8 @@ add_trial (unsigned long long *trialuid, int num_nodes, int topology,
160 int malicious_droppers, char *message) 161 int malicious_droppers, char *message)
161{ 162{
162 int ret; 163 int ret;
163 *trialuid = 0; 164 if (trialuid != NULL)
165 *trialuid = 0;
164 if (outfile == NULL) 166 if (outfile == NULL)
165 return GNUNET_SYSERR; 167 return GNUNET_SYSERR;
166 168
@@ -180,11 +182,11 @@ add_trial (unsigned long long *trialuid, int num_nodes, int topology,
180 if (ret < 0) 182 if (ret < 0)
181 return GNUNET_SYSERR; 183 return GNUNET_SYSERR;
182 ret = fprintf(outfile, "execute insert_trial using " 184 ret = fprintf(outfile, "execute insert_trial using "
183 "@num, @topology, @bl, " 185 "@num, @topology, @t_p, @t_pr,"
184 "@connect, @c_t_o, @c_t_o_m, @t_p, " 186 " @bl, @connect, @c_t_o,"
185 "@t_pr, @puts, @gets, " 187 "@c_t_o_m, @puts, @gets,"
186 "@concurrent, @settle, @rounds, " 188 "@concurrent, @settle, @rounds,"
187 "@m_gets, @m_puts, @m_drops, " 189 "@m_gets, @m_puts, @m_drops,"
188 "@message;\n"); 190 "@message;\n");
189 191
190 ret = fprintf(outfile, "execute select_trial;\n"); 192 ret = fprintf(outfile, "execute select_trial;\n");
@@ -208,7 +210,8 @@ int
208add_dhtkey (unsigned long long *dhtkeyuid, const GNUNET_HashCode * dhtkey) 210add_dhtkey (unsigned long long *dhtkeyuid, const GNUNET_HashCode * dhtkey)
209{ 211{
210 int ret; 212 int ret;
211 *dhtkeyuid = 0; 213 if (dhtkeyuid != NULL)
214 *dhtkeyuid = 0;
212 215
213 if (outfile == NULL) 216 if (outfile == NULL)
214 return GNUNET_SYSERR; 217 return GNUNET_SYSERR;
@@ -330,7 +333,7 @@ add_connections (unsigned long long trialuid, unsigned int totalConnections)
330 if (ret < 0) 333 if (ret < 0)
331 return GNUNET_SYSERR; 334 return GNUNET_SYSERR;
332 335
333 ret = fprintf(outfile, "execute update_connections using @conns;\n"); 336 ret = fprintf(outfile, "execute update_conn using @conns;\n");
334 337
335 if (ret >= 0) 338 if (ret >= 0)
336 return GNUNET_OK; 339 return GNUNET_OK;
@@ -361,7 +364,8 @@ add_query (unsigned long long *sqlqueryuid, unsigned long long queryid,
361 if (outfile == NULL) 364 if (outfile == NULL)
362 return GNUNET_SYSERR; 365 return GNUNET_SYSERR;
363 366
364 *sqlqueryuid = 0; 367 if (sqlqueryuid != NULL)
368 *sqlqueryuid = 0;
365 369
366 if (key != NULL) 370 if (key != NULL)
367 ret = fprintf(outfile, "select dhtkeyuid from dhtkeys where trialuid = @temp_trial and dhtkey = \"%s\" into @temp_dhtkey;\n", GNUNET_h2s_full(key)); 371 ret = fprintf(outfile, "select dhtkeyuid from dhtkeys where trialuid = @temp_trial and dhtkey = \"%s\" into @temp_dhtkey;\n", GNUNET_h2s_full(key));
@@ -413,7 +417,8 @@ add_route (unsigned long long *sqlqueryuid, unsigned long long queryid,
413 if (outfile == NULL) 417 if (outfile == NULL)
414 return GNUNET_SYSERR; 418 return GNUNET_SYSERR;
415 419
416 *sqlqueryuid = 0; 420 if (sqlqueryuid != NULL)
421 *sqlqueryuid = 0;
417 422
418 if (key != NULL) 423 if (key != NULL)
419 ret = fprintf(outfile, "select dhtkeyuid from dhtkeys where trialuid = @temp_trial and dhtkey = \"%s\" into @temp_dhtkey;\n", GNUNET_h2s_full(key)); 424 ret = fprintf(outfile, "select dhtkeyuid from dhtkeys where trialuid = @temp_trial and dhtkey = \"%s\" into @temp_dhtkey;\n", GNUNET_h2s_full(key));
diff --git a/src/dht/test_dht_multipeer_data.conf b/src/dht/test_dht_multipeer_data.conf
index f9283ee89..8c4c903ff 100644
--- a/src/dht/test_dht_multipeer_data.conf
+++ b/src/dht/test_dht_multipeer_data.conf
@@ -2,11 +2,12 @@
2AUTOSTART = NO 2AUTOSTART = NO
3 3
4[dht] 4[dht]
5DEBUG = YES 5DEBUG = NO
6STOP_ON_CLOSEST = YES 6STOP_ON_CLOSEST = NO
7AUTOSTART = YES 7AUTOSTART = YES
8ACCEPT_FROM6 = ::1; 8ACCEPT_FROM6 = ::1;
9ACCEPT_FROM = 127.0.0.1; 9ACCEPT_FROM = 127.0.0.1;
10BINARY = gnunet-service-dht
10#PREFIX = xterm -T dht -e gdb --args 11#PREFIX = xterm -T dht -e gdb --args
11#PREFIX = valgrind --log-file=dht_%p 12#PREFIX = valgrind --log-file=dht_%p
12CONFIG = $DEFAULTCONFIG 13CONFIG = $DEFAULTCONFIG
@@ -14,7 +15,6 @@ HOME = $SERVICEHOME
14HOSTNAME = localhost 15HOSTNAME = localhost
15PORT = 2100 16PORT = 2100
16 17
17
18[dhtcache] 18[dhtcache]
19QUOTA = 1000000 19QUOTA = 1000000
20DATABASE = sqlite 20DATABASE = sqlite
@@ -31,6 +31,9 @@ HOME = $SERVICEHOME
31HOSTNAME = localhost 31HOSTNAME = localhost
32PORT = 12365 32PORT = 12365
33 33
34[DHTLOG]
35PLUGIN = mysql_dump
36
34[core] 37[core]
35TOTAL_QUOTA_OUT = 3932160 38TOTAL_QUOTA_OUT = 3932160
36TOTAL_QUOTA_IN = 3932160 39TOTAL_QUOTA_IN = 3932160
@@ -41,6 +44,7 @@ CONFIG = $DEFAULTCONFIG
41HOME = $SERVICEHOME 44HOME = $SERVICEHOME
42HOSTNAME = localhost 45HOSTNAME = localhost
43PORT = 12092 46PORT = 12092
47DEBUG = NO
44 48
45[arm] 49[arm]
46DEFAULTSERVICES = core dht 50DEFAULTSERVICES = core dht
@@ -51,25 +55,26 @@ CONFIG = $DEFAULTCONFIG
51HOME = $SERVICEHOME 55HOME = $SERVICEHOME
52HOSTNAME = localhost 56HOSTNAME = localhost
53PORT = 12366 57PORT = 12366
54DEBUG = YES 58DEBUG = NO
55 59
56[transport-tcp] 60[transport-tcp]
57TIMEOUT = 300000 61TIMEOUT = 300000
58PORT = 12368 62PORT = 12368
59 63
60[DHT_TESTING] 64[DHT_TESTING]
61MYSQL_LOGGING_EXTENDED = NO 65MYSQL_LOGGING_EXTENDED = YES
62NUM_GETS = 10 66NUM_GETS = 10
63NUM_PUTS = 10 67NUM_PUTS = 50
64 68
65[TESTING] 69[TESTING]
66CONNECT_TOPOLOGY = CLIQUE 70TOPOLOGY = CLIQUE
67CONNECT_TOPOLOGY_OPTION = CONNECT_RANDOM_SUBSET 71CONNECT_TOPOLOGY = RING
68CONNECT_TOPOLOGY_OPTION_MODIFIER = 2 72#CONNECT_TOPOLOGY_OPTION = CONNECT_RANDOM_SUBSET
73#CONNECT_TOPOLOGY_OPTION_MODIFIER = 2
69#LOGNMODIFIER = .65 74#LOGNMODIFIER = .65
70#PERCENTAGE = .75 75#PERCENTAGE = .75
71WEAKRANDOM = YES 76WEAKRANDOM = YES
72NUM_PEERS = 5 77NUM_PEERS = 15
73 78
74[gnunetd] 79[gnunetd]
75HOSTKEY = $SERVICEHOME/.hostkey 80HOSTKEY = $SERVICEHOME/.hostkey
diff --git a/src/dht/test_dhtlog_data.conf b/src/dht/test_dhtlog_data.conf
index d2a497f43..609a0b383 100644
--- a/src/dht/test_dhtlog_data.conf
+++ b/src/dht/test_dhtlog_data.conf
@@ -36,7 +36,8 @@ DEFAULTCONFIG = test_dhtlog_data.conf
36SERVICEHOME = /tmp/test-dhtlog/ 36SERVICEHOME = /tmp/test-dhtlog/
37 37
38[DHTLOG] 38[DHTLOG]
39PLUGIN = dummy 39PLUGIN = mysql_dump
40#PLUGIN = dummy
40#PLUGIN = mysql 41#PLUGIN = mysql
41 42
42[MYSQL] 43[MYSQL]