* messages, so the number should be chosen rather generously.
*
* The expectation here is that most of the time the queue is large
- * enough so that a drop is virtually never required.
+ * enough so that a drop is virtually never required. Note that
+ * this value must be about as large as 'TOTAL_MSGS' in the
+ * 'test_transport_api_reliability.c', otherwise that testcase may
+ * fail.
*/
-#define MAX_PENDING 128
+#define MAX_PENDING (128 * 1024)
/**
* Size of the per-transport blacklist hash maps.
}
+/**
+ * Convert an address to a string.
+ *
+ * @param plugin name of the plugin responsible for the address
+ * @param addr binary address
+ * @param addr_len number of bytes in addr
+ * @return NULL on error, otherwise address string
+ */
+static const char*
+a2s (const char *plugin,
+ const void *addr,
+ uint16_t addr_len)
+{
+ struct TransportPlugin *p;
+
+ if (plugin == NULL)
+ return NULL;
+ p = find_transport (plugin);
+ if (p == NULL)
+ return NULL;
+ return p->api->address_to_string (p->api->cls,
+ addr,
+ addr_len);
+}
+
+
/**
* Mark the given FAL entry as 'connected' (and hence preferred for
* sending); also mark all others for the same peer as 'not connected'
{
if (GNUNET_YES == pos->connected)
{
+#if DEBUG_TRANSPORT
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Marking address `%s' as no longer connected (due to connect on other address)\n",
+ a2s (pos->ready_list->plugin->short_name,
+ pos->addr,
+ pos->addrlen));
+#endif
GNUNET_break (cnt == GNUNET_YES);
cnt = GNUNET_NO;
pos->connected = GNUNET_NO;
+ GNUNET_STATISTICS_update (stats,
+ gettext_noop ("# connected addresses"),
+ -1,
+ GNUNET_NO);
}
pos = pos->next;
}
{
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
_
- ("Dropping message, have %u messages pending (%u is the soft limit)\n"),
- client->message_count, MAX_PENDING);
- /* TODO: call to statistics... */
+ ("Dropping message of type %u and size %u, have %u messages pending (%u is the soft limit)\n"),
+ ntohs (msg->type),
+ ntohs (msg->size),
+ client->message_count,
+ MAX_PENDING);
+ GNUNET_STATISTICS_update (stats,
+ gettext_noop ("# messages dropped due to slow client"),
+ 1,
+ GNUNET_NO);
return;
}
msize = ntohs (msg->size);
{
if (mq->specific_address->connected != GNUNET_NO)
{
+#if DEBUG_TRANSPORT
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Marking address `%s' as no longer connected (due to transmission problem)\n",
+ a2s (mq->specific_address->ready_list->plugin->short_name,
+ mq->specific_address->addr,
+ mq->specific_address->addrlen));
+#endif
GNUNET_STATISTICS_update (stats,
gettext_noop ("# connected addresses"),
-1,
}
-/**
- * Convert an address to a string.
- *
- * @param plugin name of the plugin responsible for the address
- * @param addr binary address
- * @param addr_len number of bytes in addr
- * @return NULL on error, otherwise address string
- */
-static const char*
-a2s (const char *plugin,
- const void *addr,
- uint16_t addr_len)
-{
- struct TransportPlugin *p;
-
- if (plugin == NULL)
- return NULL;
- p = find_transport (plugin);
- if (p == NULL)
- return NULL;
- return p->api->address_to_string (p->api->cls,
- addr,
- addr_len);
-}
-
-
/**
* Find an address in any of the available transports for
* the given neighbour that would be good for message
{
#if DEBUG_TRANSPORT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Best address found has latency of %llu ms.\n",
+ "Best address found (`%s') has latency of %llu ms.\n",
+ a2s (best_address->ready_list->plugin->short_name,
+ best_address->addr,
+ best_address->addrlen),
best_address->latency.value);
#endif
}
}
#if DEBUG_TRANSPORT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Received message of type %u from `%4s', sending to all clients.\n",
+ "Received message of type %u and size %u from `%4s', sending to all clients.\n",
ntohs (message->type),
+ ntohs (message->size),
GNUNET_i2s (&n->id));
#endif
if (GNUNET_YES == GNUNET_BANDWIDTH_tracker_consume (&n->in_tracker,
NULL);
GNUNET_PEERINFO_add_peer (peerinfo, plain_hello);
GNUNET_free (plain_hello);
-#if DEBUG_TRANSPORT || 1
+#if DEBUG_TRANSPORT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"PEERINFO had no `%s' message for peer `%4s', full validation needed.\n",
"HELLO",
}
#if DEBUG_PING_PONG
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Received message of type %u from `%4s', sending to all clients.\n",
- ntohs (message->type), GNUNET_i2s (peer));
+ "Received message of type %u and size %u from `%4s', sending to all clients.\n",
+ ntohs (message->type),
+ ntohs (message->size),
+ GNUNET_i2s (peer));
#endif
switch (ntohs (message->type))
{
#include "plugin_transport.h"
#include "transport.h"
-#define DEBUG_TCP GNUNET_YES
+#define DEBUG_TCP GNUNET_NO
/**
* How long until we give up on transmitting the welcome message?
#include "gnunet_transport_service.h"
#include "transport.h"
-#define VERBOSE GNUNET_YES
+#define VERBOSE GNUNET_NO
#define VERBOSE_ARM GNUNET_NO
#define START_ARM GNUNET_YES
+/**
+ * Note that this value must not significantly exceed
+ * 'MAX_PENDING' in 'gnunet-service-transport.c', otherwise
+ * messages may be dropped even for a reliable transport.
+ */
#define TOTAL_MSGS (60000 * 2)
/**
static int is_http;
+static unsigned long long total_bytes;
+
+static struct GNUNET_TIME_Absolute start_time;
+
static GNUNET_SCHEDULER_TaskIdentifier die_task;
#if VERBOSE
static void
end ()
{
- GNUNET_assert (ok == 6);
+ unsigned long long delta;
+
GNUNET_SCHEDULER_cancel (sched, die_task);
+ die_task = GNUNET_SCHEDULER_NO_TASK;
+#if VERBOSE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting from transports!\n");
+#endif
GNUNET_TRANSPORT_disconnect (p1.th);
GNUNET_TRANSPORT_disconnect (p2.th);
-
- die_task = GNUNET_SCHEDULER_NO_TASK;
+#if VERBOSE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Transports disconnected, returning success!\n");
+#endif
+ delta = GNUNET_TIME_absolute_get_duration (start_time).value;
+ fprintf (stderr,
+ "\nThroughput was %llu kb/s\n",
+ total_bytes * 1000 / 1024 / delta);
ok = 0;
}
die_task = GNUNET_SCHEDULER_add_now (sched, &end_badly, NULL);
return;
}
+#if VERBOSE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Got message %u of size %u\n",
ntohl (hdr->num),
ntohs (message->size));
+#endif
n++;
+ if (0 == (n % (TOTAL_MSGS/100)))
+ fprintf (stderr, ".");
if (n == TOTAL_MSGS)
end ();
}
ret += sizeof (struct TestMessage);
memset (&cbuf[ret], n, s - sizeof (struct TestMessage));
ret += s - sizeof (struct TestMessage);
+#if VERBOSE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Sending message %u of size %u\n",
n,
s);
+#endif
n++;
s = get_size (n);
if (0 == GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 16))
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Returning total message block of size %u\n",
ret);
+ total_bytes += ret;
return ret;
}
GNUNET_BANDWIDTH_value_init (1024 * 1024 * 1024),
GNUNET_TIME_UNIT_FOREVER_REL,
NULL, NULL);
+ start_time = GNUNET_TIME_absolute_get ();
GNUNET_TRANSPORT_notify_transmit_ready (p1.th,
&p2.id,
get_size (0), 0, TIMEOUT,
GNUNET_TIME_UNIT_FOREVER_REL,
NULL, NULL);
}
+#if VERBOSE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Peer `%4s' connected to us (%p)!\n", GNUNET_i2s (peer), cls);
+#endif
}
static void
notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
{
+#if VERBOSE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Peer `%4s' disconnected (%p)!\n",
GNUNET_i2s (peer), cls);
+#endif
}
struct PeerContext *me = cls;
GNUNET_TRANSPORT_get_hello_cancel (p2.th, &exchange_hello_last, me);
+#if VERBOSE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Exchanging HELLO with peer (%p)!\n", cls);
+#endif
GNUNET_assert (ok >= 3);
OKPP;
GNUNET_assert (message != NULL);
struct PeerContext *me = cls;
GNUNET_TRANSPORT_get_hello_cancel (p1.th, &exchange_hello, me);
+#if VERBOSE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Exchanging HELLO with peer (%p)!\n", cls);
+#endif
GNUNET_assert (ok >= 2);
OKPP;
GNUNET_assert (message != NULL);
GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *)
message, &me->id));
+#if VERBOSE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Received HELLO size %d\n", GNUNET_HELLO_size((const struct GNUNET_HELLO_Message *)message));
-
+ "Received HELLO size %d\n",
+ GNUNET_HELLO_size((const struct GNUNET_HELLO_Message *)message));
+#endif
GNUNET_TRANSPORT_offer_hello (p2.th, message);
GNUNET_TRANSPORT_get_hello (p2.th, &exchange_hello_last, &p2);
}
#endif
ok = 1;
GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1,
- argv, "test-transport-api", "nohelp",
+ argv, "test-transport-api-reliability", "nohelp",
options, &run, &ok);
stop_arm (&p1);
stop_arm (&p2);
[transport-tcp]
PORT = 12368
+BINDTO = 127.0.0.1
[fs]
AUTOSTART = NO
[transport]
PLUGINS = tcp
-#DEBUG = YES
+DEBUG = NO
#PREFIX = xterm -T transport2 -e gdb --command=cmd --args
#PREFIX = valgrind --leak-check=full
ACCEPT_FROM6 = ::1;
PORT = 12367
[arm]
-DEFAULTSERVICES =
+DEFAULTSERVICES = transport statistics
ACCEPT_FROM6 = ::1;
ACCEPT_FROM = 127.0.0.1;
BINARY = gnunet-service-arm
[transport-tcp]
PORT = 22368
+BINDTO = 127.0.0.1
[core]
AUTOSTART = NO
[transport]
PLUGINS = tcp
-#DEBUG = YES
+DEBUG = NO
# PREFIX =
ACCEPT_FROM6 = ::1;
ACCEPT_FROM = 127.0.0.1;
PORT = 22367
[arm]
-DEFAULTSERVICES =
+DEFAULTSERVICES = transport statistics
ACCEPT_FROM6 = ::1;
ACCEPT_FROM = 127.0.0.1;
BINARY = gnunet-service-arm
#include "gnunet_time_lib.h"
#include "gnunet_transport_service.h"
-#define DEBUG_TRANSPORT GNUNET_YES
-#define DEBUG_TRANSPORT_TIMEOUT GNUNET_YES
-#define DEBUG_TRANSPORT_DISCONNECT GNUNET_YES
+#define DEBUG_TRANSPORT GNUNET_NO
+#define DEBUG_TRANSPORT_TIMEOUT GNUNET_NO
+#define DEBUG_TRANSPORT_DISCONNECT GNUNET_NO
/**
* For how long do we allow unused bandwidth
h->control_tail,
cm);
nret = cm->notify (cm->notify_cls, size, &cbuf[ret]);
+#if DEBUG_TRANSPORT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Added %u bytes of control message at %u\n",
nret,
ret);
+#endif
GNUNET_free (cm);
ret += nret;
size -= nret;