GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
- by the Free Software Foundation; either version 2, or (at your
+ by the Free Software Foundation; either version 3, or (at your
option) any later version.
GNUnet is distributed in the hope that it will be useful, but
*/
#include "platform.h"
#include "gnunet_common.h"
+#include "gnunet_constants.h"
#include "gnunet_arm_service.h"
#include "gnunet_core_service.h"
#include "gnunet_getopt_lib.h"
#include "gnunet_scheduler_lib.h"
#include "gnunet_transport_service.h"
-#define VERBOSE GNUNET_YES
+#define VERBOSE 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 (600 * 10)
+
/**
* How long until we give up on transmitting the message?
*/
-#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 60)
+#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 6000)
+
+/**
+ * What delay do we request from the core service for transmission?
+ * Any value smaller than the CORK delay will disable CORKing, which
+ * is what we want here.
+ */
+#define FAST_TIMEOUT GNUNET_TIME_relative_divide (GNUNET_CONSTANTS_MAX_CORK_DELAY, 2)
#define MTYPE 12345
static struct GNUNET_TIME_Absolute start_time;
-/**
- * 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)
-
struct PeerContext
{
struct GNUNET_CONFIGURATION_Handle *cfg;
unsigned long long delta;
GNUNET_CORE_disconnect (p1.ch);
+ p1.ch = NULL;
GNUNET_CORE_disconnect (p2.ch);
+ p2.ch = NULL;
GNUNET_TRANSPORT_disconnect (p1.th);
+ p1.th = NULL;
GNUNET_TRANSPORT_disconnect (p2.th);
+ p2.th = NULL;
delta = GNUNET_TIME_absolute_get_duration (start_time).value;
fprintf (stderr,
"\nThroughput was %llu kb/s\n",
{
GNUNET_break (0);
GNUNET_CORE_disconnect (p1.ch);
+ p1.ch = NULL;
GNUNET_CORE_disconnect (p2.ch);
+ p2.ch = NULL;
GNUNET_TRANSPORT_disconnect (p1.th);
+ p1.th = NULL;
GNUNET_TRANSPORT_disconnect (p2.th);
+ p2.th = NULL;
ok = 42;
}
struct GNUNET_TIME_Relative latency,
uint32_t distance)
{
+#if VERBOSE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Core provides inbound data from `%4s'.\n", GNUNET_i2s (other));
+#endif
return GNUNET_OK;
}
struct GNUNET_TIME_Relative latency,
uint32_t distance)
{
+#if VERBOSE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Core notifies about outbound data for `%4s'.\n",
GNUNET_i2s (other));
+#endif
return GNUNET_OK;
}
static GNUNET_SCHEDULER_TaskIdentifier err_task;
+static size_t
+transmit_ready (void *cls, size_t size, void *buf);
+
+static int tr_n;
+
+
static int
process_mtype (void *cls,
const struct GNUNET_PeerIdentity *peer,
GNUNET_SCHEDULER_cancel (sched, err_task);
GNUNET_SCHEDULER_add_now (sched, &terminate_task, NULL);
}
+ else
+ {
+ if (n == tr_n)
+ GNUNET_break (NULL !=
+ GNUNET_CORE_notify_transmit_ready (p1.ch,
+ 0,
+ FAST_TIMEOUT,
+ &p2.id,
+ get_size(tr_n),
+ &transmit_ready, &p1));
+ }
return GNUNET_OK;
}
static size_t
transmit_ready (void *cls, size_t size, void *buf)
{
- static int n;
char *cbuf = buf;
struct TestMessage hdr;
unsigned int s;
unsigned int ret;
+ GNUNET_assert (size <= GNUNET_CONSTANTS_MAX_ENCRYPTED_MESSAGE_SIZE);
if (buf == NULL)
{
- GNUNET_break (0);
- ok = 42;
+ if (p1.ch != NULL)
+ GNUNET_break (NULL !=
+ GNUNET_CORE_notify_transmit_ready (p1.ch,
+ 0,
+ FAST_TIMEOUT,
+ &p2.id,
+ get_size(tr_n),
+ &transmit_ready, &p1));
return 0;
}
+ GNUNET_assert (tr_n < TOTAL_MSGS);
ret = 0;
- s = get_size (n);
+ s = get_size (tr_n);
GNUNET_assert (size >= s);
GNUNET_assert (buf != NULL);
cbuf = buf;
do
{
+#if VERBOSE
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Sending message %u of size %u at offset %u\n",
+ tr_n,
+ s,
+ ret);
+#endif
hdr.header.size = htons (s);
hdr.header.type = htons (MTYPE);
- hdr.num = htonl (n);
+ hdr.num = htonl (tr_n);
memcpy (&cbuf[ret], &hdr, sizeof (struct TestMessage));
ret += sizeof (struct TestMessage);
- memset (&cbuf[ret], n, s - sizeof (struct TestMessage));
+ memset (&cbuf[ret], tr_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);
+ tr_n++;
+ s = get_size (tr_n);
if (0 == GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 16))
break; /* sometimes pack buffer full, sometimes not */
}
while (size - ret >= s);
- if (n < TOTAL_MSGS)
- GNUNET_break (NULL !=
- GNUNET_CORE_notify_transmit_ready (p1.ch,
- 0,
- GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 45),
- &p2.id,
- sizeof (struct GNUNET_MessageHeader),
- &transmit_ready, &p1));
+ GNUNET_SCHEDULER_cancel (sched, err_task);
+ err_task =
+ GNUNET_SCHEDULER_add_delayed (sched,
+ TIMEOUT,
+ &terminate_task_error,
+ NULL);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Returning total message block of size %u\n",
ret);
struct PeerContext *p = cls;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Core connection to `%4s' established\n",
+ "Connection to CORE service of `%4s' established\n",
GNUNET_i2s (my_identity));
GNUNET_assert (server != NULL);
p->id = *my_identity;
&init_notify,
&connect_notify,
&disconnect_notify,
+ NULL,
&inbound_notify,
GNUNET_YES,
&outbound_notify, GNUNET_YES, handlers);
GNUNET_i2s (&p2.id));
err_task =
GNUNET_SCHEDULER_add_delayed (sched,
- GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 120),
+ TIMEOUT,
&terminate_task_error,
NULL);
start_time = GNUNET_TIME_absolute_get ();
GNUNET_break (NULL !=
GNUNET_CORE_notify_transmit_ready (p1.ch,
0,
- GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 45),
+ TIMEOUT,
&p2.id,
- sizeof (struct GNUNET_MessageHeader),
+ get_size (0),
&transmit_ready, &p1));
}
}
"-c", cfgname, NULL);
#endif
GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname));
- p->th = GNUNET_TRANSPORT_connect (sched, p->cfg, p, NULL, NULL, NULL);
+ p->th = GNUNET_TRANSPORT_connect (sched, p->cfg, NULL, p, NULL, NULL, NULL);
GNUNET_assert (p->th != NULL);
GNUNET_TRANSPORT_get_hello (p->th, &process_hello, p);
}
&init_notify,
&connect_notify,
&disconnect_notify,
+ NULL,
&inbound_notify,
GNUNET_YES, &outbound_notify, GNUNET_YES, handlers);
}