[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r18173 - gnunet/src/transport
From: |
gnunet |
Subject: |
[GNUnet-SVN] r18173 - gnunet/src/transport |
Date: |
Wed, 16 Nov 2011 15:06:33 +0100 |
Author: wachs
Date: 2011-11-16 15:06:33 +0100 (Wed, 16 Nov 2011)
New Revision: 18173
Modified:
gnunet/src/transport/template_cfg_peer1.conf
gnunet/src/transport/template_cfg_peer2.conf
gnunet/src/transport/test_quota_compliance.c
gnunet/src/transport/test_transport_api.c
gnunet/src/transport/test_transport_api_bidirectional_connect.c
gnunet/src/transport/test_transport_api_disconnect.c
gnunet/src/transport/test_transport_api_reliability.c
gnunet/src/transport/test_transport_api_timeout.c
gnunet/src/transport/test_transport_api_unreliability.c
gnunet/src/transport/test_transport_api_unreliability_constant.c
gnunet/src/transport/test_transport_testing.c
gnunet/src/transport/transport-testing.c
gnunet/src/transport/transport-testing.h
Log:
transport-testing uses precomputed hostkeys to improve speed especially on slow
systems
Modified: gnunet/src/transport/template_cfg_peer1.conf
===================================================================
--- gnunet/src/transport/template_cfg_peer1.conf 2011-11-16 11:02:27 UTC
(rev 18172)
+++ gnunet/src/transport/template_cfg_peer1.conf 2011-11-16 14:06:33 UTC
(rev 18173)
@@ -3,6 +3,9 @@
SERVICEHOME = /tmp/test-transport/api-tcp-p1/
DEFAULTCONFIG = template_cfg_peer1.conf
+[gnunetd]
+HOSTKEY = $SERVICEHOME/.hostkey
+
[nat]
RETURN_LOCAL_ADDRESSES = YES
DISABLEV6 = NO
@@ -30,6 +33,7 @@
[transport]
PORT = 12001
+#DEBUG = YES
UNIXPATH = /tmp/gnunet-p1-service-transport.sock
[ats]
Modified: gnunet/src/transport/template_cfg_peer2.conf
===================================================================
--- gnunet/src/transport/template_cfg_peer2.conf 2011-11-16 11:02:27 UTC
(rev 18172)
+++ gnunet/src/transport/template_cfg_peer2.conf 2011-11-16 14:06:33 UTC
(rev 18173)
@@ -3,6 +3,9 @@
SERVICEHOME = /tmp/test-transport/api-tcp-p2/
DEFAULTCONFIG = template_cfg_peer2.conf
+[gnunetd]
+HOSTKEY = $SERVICEHOME/.hostkey
+
[nat]
RETURN_LOCAL_ADDRESSES = YES
DISABLEV6 = NO
Modified: gnunet/src/transport/test_quota_compliance.c
===================================================================
--- gnunet/src/transport/test_quota_compliance.c 2011-11-16 11:02:27 UTC
(rev 18172)
+++ gnunet/src/transport/test_quota_compliance.c 2011-11-16 14:06:33 UTC
(rev 18173)
@@ -587,11 +587,6 @@
{
int nat_res;
- tth = GNUNET_TRANSPORT_TESTING_init ();
-
- GNUNET_TRANSPORT_TESTING_get_test_source_name (__FILE__, &test_source);
- GNUNET_TRANSPORT_TESTING_get_test_plugin_name (argv[0], test_source,
- &test_plugin);
GNUNET_TRANSPORT_TESTING_get_test_name (argv[0], &test_name);
GNUNET_log_setup (test_name,
@@ -602,6 +597,12 @@
#endif
NULL);
+ GNUNET_TRANSPORT_TESTING_get_test_source_name (__FILE__, &test_source);
+ GNUNET_TRANSPORT_TESTING_get_test_plugin_name (argv[0], test_source,
+ &test_plugin);
+
+ tth = GNUNET_TRANSPORT_TESTING_init ();
+
if ((strcmp (test_plugin, "tcp_nat") == 0) ||
(strcmp (test_plugin, "udp_nat") == 0))
{
Modified: gnunet/src/transport/test_transport_api.c
===================================================================
--- gnunet/src/transport/test_transport_api.c 2011-11-16 11:02:27 UTC (rev
18172)
+++ gnunet/src/transport/test_transport_api.c 2011-11-16 14:06:33 UTC (rev
18173)
@@ -370,12 +370,10 @@
int ret;
int nat_res;
- tth = GNUNET_TRANSPORT_TESTING_init ();
-
+ GNUNET_TRANSPORT_TESTING_get_test_name (argv[0], &test_name);
GNUNET_TRANSPORT_TESTING_get_test_source_name (__FILE__, &test_source);
GNUNET_TRANSPORT_TESTING_get_test_plugin_name (argv[0], test_source,
&test_plugin);
- GNUNET_TRANSPORT_TESTING_get_test_name (argv[0], &test_name);
GNUNET_log_setup (test_name,
#if VERBOSE
@@ -385,6 +383,8 @@
#endif
NULL);
+ tth = GNUNET_TRANSPORT_TESTING_init ();
+
if ((strcmp (test_plugin, "tcp_nat") == 0) ||
(strcmp (test_plugin, "udp_nat") == 0))
{
Modified: gnunet/src/transport/test_transport_api_bidirectional_connect.c
===================================================================
--- gnunet/src/transport/test_transport_api_bidirectional_connect.c
2011-11-16 11:02:27 UTC (rev 18172)
+++ gnunet/src/transport/test_transport_api_bidirectional_connect.c
2011-11-16 14:06:33 UTC (rev 18173)
@@ -378,11 +378,6 @@
int ret;
int nat_res;
- tth = GNUNET_TRANSPORT_TESTING_init ();
-
- GNUNET_TRANSPORT_TESTING_get_test_source_name (__FILE__, &test_source);
- GNUNET_TRANSPORT_TESTING_get_test_plugin_name (argv[0], test_source,
- &test_plugin);
GNUNET_TRANSPORT_TESTING_get_test_name (argv[0], &test_name);
GNUNET_log_setup (test_name,
@@ -393,6 +388,12 @@
#endif
NULL);
+ GNUNET_TRANSPORT_TESTING_get_test_source_name (__FILE__, &test_source);
+ GNUNET_TRANSPORT_TESTING_get_test_plugin_name (argv[0], test_source,
+ &test_plugin);
+
+ tth = GNUNET_TRANSPORT_TESTING_init ();
+
if ((strcmp (test_plugin, "tcp_nat") == 0) ||
(strcmp (test_plugin, "udp_nat") == 0))
{
Modified: gnunet/src/transport/test_transport_api_disconnect.c
===================================================================
--- gnunet/src/transport/test_transport_api_disconnect.c 2011-11-16
11:02:27 UTC (rev 18172)
+++ gnunet/src/transport/test_transport_api_disconnect.c 2011-11-16
14:06:33 UTC (rev 18173)
@@ -401,11 +401,6 @@
int ret;
int nat_res;
- tth = GNUNET_TRANSPORT_TESTING_init ();
-
- GNUNET_TRANSPORT_TESTING_get_test_source_name (__FILE__, &test_source);
- GNUNET_TRANSPORT_TESTING_get_test_plugin_name (argv[0], test_source,
- &test_plugin);
GNUNET_TRANSPORT_TESTING_get_test_name (argv[0], &test_name);
GNUNET_log_setup (test_name,
@@ -416,6 +411,12 @@
#endif
NULL);
+ GNUNET_TRANSPORT_TESTING_get_test_source_name (__FILE__, &test_source);
+ GNUNET_TRANSPORT_TESTING_get_test_plugin_name (argv[0], test_source,
+ &test_plugin);
+
+ tth = GNUNET_TRANSPORT_TESTING_init ();
+
if ((strcmp (test_plugin, "tcp_nat") == 0) ||
(strcmp (test_plugin, "udp_nat") == 0))
{
Modified: gnunet/src/transport/test_transport_api_reliability.c
===================================================================
--- gnunet/src/transport/test_transport_api_reliability.c 2011-11-16
11:02:27 UTC (rev 18172)
+++ gnunet/src/transport/test_transport_api_reliability.c 2011-11-16
14:06:33 UTC (rev 18173)
@@ -437,6 +437,7 @@
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Test triest to send from %u (%s) -> peer %u (%s)\n", sender->no,
sender_c, receiver->no, GNUNET_i2s (&receiver->id));
+ GNUNET_free (sender_c);
cc = GNUNET_TRANSPORT_TESTING_connect_peers (tth, p1, p2,
&testing_connect_cb,
NULL);
@@ -500,11 +501,6 @@
int ret;
int nat_res;
- tth = GNUNET_TRANSPORT_TESTING_init ();
-
- GNUNET_TRANSPORT_TESTING_get_test_source_name (__FILE__, &test_source);
- GNUNET_TRANSPORT_TESTING_get_test_plugin_name (argv[0], test_source,
- &test_plugin);
GNUNET_TRANSPORT_TESTING_get_test_name (argv[0], &test_name);
GNUNET_log_setup (test_name,
@@ -515,6 +511,12 @@
#endif
NULL);
+ GNUNET_TRANSPORT_TESTING_get_test_source_name (__FILE__, &test_source);
+ GNUNET_TRANSPORT_TESTING_get_test_plugin_name (argv[0], test_source,
+ &test_plugin);
+
+ tth = GNUNET_TRANSPORT_TESTING_init ();
+
if ((strcmp (test_plugin, "tcp_nat") == 0) ||
(strcmp (test_plugin, "udp_nat") == 0))
{
Modified: gnunet/src/transport/test_transport_api_timeout.c
===================================================================
--- gnunet/src/transport/test_transport_api_timeout.c 2011-11-16 11:02:27 UTC
(rev 18172)
+++ gnunet/src/transport/test_transport_api_timeout.c 2011-11-16 14:06:33 UTC
(rev 18173)
@@ -321,11 +321,6 @@
int ret;
int nat_res;
- tth = GNUNET_TRANSPORT_TESTING_init ();
-
- GNUNET_TRANSPORT_TESTING_get_test_source_name (__FILE__, &test_source);
- GNUNET_TRANSPORT_TESTING_get_test_plugin_name (argv[0], test_source,
- &test_plugin);
GNUNET_TRANSPORT_TESTING_get_test_name (argv[0], &test_name);
GNUNET_log_setup (test_name,
@@ -336,6 +331,12 @@
#endif
NULL);
+ GNUNET_TRANSPORT_TESTING_get_test_source_name (__FILE__, &test_source);
+ GNUNET_TRANSPORT_TESTING_get_test_plugin_name (argv[0], test_source,
+ &test_plugin);
+
+ tth = GNUNET_TRANSPORT_TESTING_init ();
+
if ((strcmp (test_plugin, "tcp_nat") == 0) ||
(strcmp (test_plugin, "udp_nat") == 0))
{
Modified: gnunet/src/transport/test_transport_api_unreliability.c
===================================================================
--- gnunet/src/transport/test_transport_api_unreliability.c 2011-11-16
11:02:27 UTC (rev 18172)
+++ gnunet/src/transport/test_transport_api_unreliability.c 2011-11-16
14:06:33 UTC (rev 18173)
@@ -549,11 +549,6 @@
int ret;
int nat_res;
- tth = GNUNET_TRANSPORT_TESTING_init ();
-
- GNUNET_TRANSPORT_TESTING_get_test_source_name (__FILE__, &test_source);
- GNUNET_TRANSPORT_TESTING_get_test_plugin_name (argv[0], test_source,
- &test_plugin);
GNUNET_TRANSPORT_TESTING_get_test_name (argv[0], &test_name);
GNUNET_log_setup (test_name,
@@ -564,6 +559,12 @@
#endif
NULL);
+ GNUNET_TRANSPORT_TESTING_get_test_source_name (__FILE__, &test_source);
+ GNUNET_TRANSPORT_TESTING_get_test_plugin_name (argv[0], test_source,
+ &test_plugin);
+
+ tth = GNUNET_TRANSPORT_TESTING_init ();
+
if ((strcmp (test_plugin, "tcp_nat") == 0) ||
(strcmp (test_plugin, "udp_nat") == 0))
{
Modified: gnunet/src/transport/test_transport_api_unreliability_constant.c
===================================================================
--- gnunet/src/transport/test_transport_api_unreliability_constant.c
2011-11-16 11:02:27 UTC (rev 18172)
+++ gnunet/src/transport/test_transport_api_unreliability_constant.c
2011-11-16 14:06:33 UTC (rev 18173)
@@ -487,11 +487,6 @@
int ret;
int nat_res;
- tth = GNUNET_TRANSPORT_TESTING_init ();
-
- GNUNET_TRANSPORT_TESTING_get_test_source_name (__FILE__, &test_source);
- GNUNET_TRANSPORT_TESTING_get_test_plugin_name (argv[0], test_source,
- &test_plugin);
GNUNET_TRANSPORT_TESTING_get_test_name (argv[0], &test_name);
GNUNET_log_setup (test_name,
@@ -502,6 +497,12 @@
#endif
NULL);
+ GNUNET_TRANSPORT_TESTING_get_test_source_name (__FILE__, &test_source);
+ GNUNET_TRANSPORT_TESTING_get_test_plugin_name (argv[0], test_source,
+ &test_plugin);
+
+ tth = GNUNET_TRANSPORT_TESTING_init ();
+
if ((strcmp (test_plugin, "tcp_nat") == 0) ||
(strcmp (test_plugin, "udp_nat") == 0))
{
Modified: gnunet/src/transport/test_transport_testing.c
===================================================================
--- gnunet/src/transport/test_transport_testing.c 2011-11-16 11:02:27 UTC
(rev 18172)
+++ gnunet/src/transport/test_transport_testing.c 2011-11-16 14:06:33 UTC
(rev 18173)
@@ -145,6 +145,7 @@
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Test tries to connect peer %u (`%s') -> peer %u (`%s')\n",
p1->no, sender_c, p2->no, GNUNET_i2s (&p2->id));
+ GNUNET_free (sender_c);
cc = GNUNET_TRANSPORT_TESTING_connect_peers (tth, p1, p2,
&testing_connect_cb,
NULL);
@@ -165,11 +166,16 @@
"test_transport_api_tcp_peer1.conf",
1, ¬ify_receive,
¬ify_connect,
¬ify_disconnect, &start_cb, p1);
+
+ GNUNET_assert (p1->hostkeyfile != NULL);
+
p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth,
"test_transport_api_tcp_peer2.conf",
2, ¬ify_receive,
¬ify_connect,
¬ify_disconnect, &start_cb, p2);
+ GNUNET_assert (p2->hostkeyfile != NULL);
+
if (p1 == NULL)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
Modified: gnunet/src/transport/transport-testing.c
===================================================================
--- gnunet/src/transport/transport-testing.c 2011-11-16 11:02:27 UTC (rev
18172)
+++ gnunet/src/transport/transport-testing.c 2011-11-16 14:06:33 UTC (rev
18173)
@@ -28,7 +28,30 @@
#include "transport-testing.h"
#define VERBOSE GNUNET_EXTRA_LOGGING
+#define HOSTKEYFILESIZE 914
+static const char *
+get_host_key (struct GNUNET_TRANSPORT_TESTING_handle *tth)
+{
+ if (tth->hostkey_data == NULL)
+ {
+ GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-testing",
+ "No precomputed hostkeys available\n");
+ return NULL;
+ }
+ if (tth->hostkeys_total > tth->hostkeys_last)
+ {
+ tth->hostkeys_last++;
+ GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-testing",
+ "Used hostkey %u of %u available hostkeys\n",
+ tth->hostkeys_last, tth->hostkeys_total);
+ return &tth->hostkey_data[(tth->hostkeys_last - 1) * HOSTKEYFILESIZE];
+ }
+ GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-testing",
+ "No hostkey available (%u of %u already used)\n",
+ tth->hostkeys_last, tth->hostkeys_total);
+ return NULL;
+}
static struct PeerContext *
find_peer_context (struct GNUNET_TRANSPORT_TESTING_handle *tth,
@@ -246,6 +269,9 @@
GNUNET_TRANSPORT_TESTING_start_cb
start_cb,
void *cb_cls)
{
+ const char *hostkey = NULL;
+ struct GNUNET_DISK_FileHandle *fn;
+
GNUNET_assert (tth != NULL);
if (GNUNET_DISK_file_test (cfgname) == GNUNET_NO)
{
@@ -259,13 +285,36 @@
p->cfg = GNUNET_CONFIGURATION_create ();
GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname));
+
+
if (GNUNET_CONFIGURATION_have_value (p->cfg, "PATHS", "SERVICEHOME"))
GNUNET_assert (GNUNET_OK ==
GNUNET_CONFIGURATION_get_value_string (p->cfg, "PATHS",
"SERVICEHOME",
&p->servicehome));
- if (NULL != p->servicehome)
- GNUNET_DISK_directory_remove (p->servicehome);
+
+ if (NULL != p->servicehome)
+ GNUNET_DISK_directory_remove (p->servicehome);
+
+ hostkey = get_host_key(tth);
+ if (hostkey != NULL)
+ {
+
+ GNUNET_asprintf (&p->hostkeyfile, "%s/.hostkey", p->servicehome);
+ GNUNET_assert(GNUNET_OK == GNUNET_DISK_directory_create_for_file
(p->hostkeyfile));
+ fn = GNUNET_DISK_file_open (p->hostkeyfile,
+ GNUNET_DISK_OPEN_READWRITE |
+ GNUNET_DISK_OPEN_CREATE,
+ GNUNET_DISK_PERM_USER_READ |
+ GNUNET_DISK_PERM_USER_WRITE);
+ GNUNET_assert (fn != NULL);
+ GNUNET_assert (HOSTKEYFILESIZE ==
+ GNUNET_DISK_file_write (fn, hostkey, HOSTKEYFILESIZE));
+ GNUNET_assert (GNUNET_OK == GNUNET_DISK_file_close (fn));
+ GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-testing",
+ "Wrote hostkey to file: `%s' \n", p->hostkeyfile);
+ }
+
p->arm_proc =
GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
"gnunet-service-arm", "-c", cfgname,
@@ -326,6 +375,12 @@
p->arm_proc = NULL;
}
+ if (p->hostkeyfile != NULL)
+ {
+ GNUNET_DISK_directory_remove (p->hostkeyfile);
+ GNUNET_free (p->hostkeyfile);
+ }
+
if (p->servicehome != NULL)
{
GNUNET_DISK_directory_remove (p->servicehome);
@@ -454,6 +509,8 @@
p = t;
}
+ GNUNET_free_non_null (tth->hostkey_data);
+
GNUNET_free (tth);
tth = NULL;
}
@@ -467,7 +524,51 @@
{
struct GNUNET_TRANSPORT_TESTING_handle *tth =
GNUNET_malloc (sizeof (struct GNUNET_TRANSPORT_TESTING_handle));
+ struct GNUNET_DISK_FileHandle *fd;
+ uint64_t fs;
+ uint64_t total_hostkeys;
+
+ /* prepare hostkeys */
+ tth->hostkey_data = NULL;
+ char * hostkeys_file = "../../contrib/testing_hostkeys.dat";
+ if (GNUNET_YES != GNUNET_DISK_file_test (hostkeys_file))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ _("Could not read hostkeys file!\n"));
+ }
+ else
+ {
+ /* Check hostkey file size, read entire thing into memory */
+ fd = GNUNET_DISK_file_open (hostkeys_file, GNUNET_DISK_OPEN_READ,
+ GNUNET_DISK_PERM_NONE);
+ if (NULL == fd)
+ {
+ GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "open",
+ hostkeys_file);
+ return NULL;
+ }
+
+ if (GNUNET_YES != GNUNET_DISK_file_size (hostkeys_file, &fs, GNUNET_YES))
+ fs = 0;
+
+ if (0 != (fs % HOSTKEYFILESIZE))
+ {
+ GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, "transport-testing",
+ "File size %llu seems incorrect for hostkeys...\n", fs);
+ }
+ else
+ {
+ total_hostkeys = fs / HOSTKEYFILESIZE;
+ tth->hostkey_data = GNUNET_malloc_large (fs);
+ GNUNET_assert (fs == GNUNET_DISK_file_read (fd, tth->hostkey_data, fs));
+ GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-testing",
+ "Read %llu hostkeys from file\n", total_hostkeys);
+ tth->hostkeys_total = total_hostkeys;
+ }
+ GNUNET_assert (GNUNET_OK == GNUNET_DISK_file_close (fd));
+ }
+
return tth;
}
Modified: gnunet/src/transport/transport-testing.h
===================================================================
--- gnunet/src/transport/transport-testing.h 2011-11-16 11:02:27 UTC (rev
18172)
+++ gnunet/src/transport/transport-testing.h 2011-11-16 14:06:33 UTC (rev
18173)
@@ -94,6 +94,8 @@
char *servicehome;
+ char *hostkeyfile;
+
unsigned int no;
};
@@ -118,6 +120,10 @@
struct ConnectingContext *cc_head;
struct ConnectingContext *cc_tail;
+ char *hostkey_data;
+ int hostkeys_total;
+ int hostkeys_last;
+
struct PeerContext *p_head;
struct PeerContext *p_tail;
};
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r18173 - gnunet/src/transport,
gnunet <=