#define VERBOSE GNUNET_YES
#define START_ARM GNUNET_YES
-#define DEBUG_CONNECTIONS GNUNET_NO
+#define DEBUG_CONNECTIONS GNUNET_YES
/**
* Note that this value must not significantly exceed
ok = 42;
}
-static void connect_notify (void *cls,
- const struct GNUNET_PeerIdentity *peer,
- const struct GNUNET_TRANSPORT_ATS_Information *atsi)
-{
- struct PeerContext *pc = cls;
- GNUNET_assert (pc->connect_status == 0);
- pc->connect_status = 1;
-#if DEBUG_CONNECTIONS
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Encrypted connection established to peer `%4s'\n",
- GNUNET_i2s (peer));
-#endif
-}
-
-
-static void
-disconnect_notify (void *cls,
- const struct GNUNET_PeerIdentity *peer)
-{
- struct PeerContext *pc = cls;
- pc->connect_status = 0;
-#if DEBUG_CONNECTIONS
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Encrypted connection to `%4s' cut\n", GNUNET_i2s (peer));
-#endif
-}
-
-
-static int
-inbound_notify (void *cls,
- const struct GNUNET_PeerIdentity *other,
- const struct GNUNET_MessageHeader *message,
- const struct GNUNET_TRANSPORT_ATS_Information *atsi)
-{
- total_bytes_recv += ntohs (message->size);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Core provides inbound data from `%4s' size %u.\n", GNUNET_i2s (other), ntohs (message->size));
-#if DEBUG_CONNECTIONS
- #endif
- return GNUNET_OK;
-}
-
-
-static int
-outbound_notify (void *cls,
- const struct GNUNET_PeerIdentity *other,
- const struct GNUNET_MessageHeader *message,
- const struct GNUNET_TRANSPORT_ATS_Information *atsi)
-{
-#if DEBUG_CONNECTIONS
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Core notifies about outbound data for `%4s'.\n",
- GNUNET_i2s (other));
-#endif
- return GNUNET_OK;
-}
-
static void
next_fin (void *cls, int success)
{
return GNUNET_OK;
}
+static size_t
+transmit_ready (void *cls, size_t size, void *buf);
+
+static void
+send_tsk (void *cls,
+ const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+ send_task = GNUNET_SCHEDULER_NO_TASK;
+
+ ch = GNUNET_CORE_notify_transmit_ready (p1.ch,
+ 0,
+ FAST_TIMEOUT,
+ &p2.id,
+ sizeof (struct TestMessage) + MEASUREMENT_MSG_SIZE,
+ &transmit_ready, &p1);
+}
+
static void
measurement_end (void *cls,
const struct GNUNET_SCHEDULER_TaskContext *tc)
{
struct GNUNET_TIME_Relative duration;
-
+
measure_task = GNUNET_SCHEDULER_NO_TASK;
if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
return;
-
+
if (err_task != GNUNET_SCHEDULER_NO_TASK)
GNUNET_SCHEDULER_cancel (err_task);
if (send_task != GNUNET_SCHEDULER_NO_TASK)
GNUNET_SCHEDULER_cancel (send_task);
-
+
GNUNET_STATISTICS_get(p1.stats,"core","# discarded CORE_SEND requests",GNUNET_TIME_UNIT_SECONDS, &next_fin, &check_2, &p1);
GNUNET_STATISTICS_get(p1.stats,"core","# discarded CORE_SEND requests",GNUNET_TIME_UNIT_SECONDS, &next_fin, &check_2, &p2);
GNUNET_STATISTICS_get(p1.stats,"core","# discarded lower priority CORE_SEND requests",GNUNET_TIME_UNIT_SECONDS, &next_fin, &check_2, &p1);
GNUNET_STATISTICS_get(p1.stats,"core","# discarded lower priority CORE_SEND requests",GNUNET_TIME_UNIT_SECONDS, &next_fin, &check_2, &p2);
-
+
GNUNET_STATISTICS_get(p1.stats,"core","# discarded CORE_SEND request bytes",GNUNET_TIME_UNIT_SECONDS, &next_fin, &check_2, &p1);
GNUNET_STATISTICS_get(p1.stats,"core","# discarded CORE_SEND request bytes",GNUNET_TIME_UNIT_SECONDS, &next_fin, &check_2, &p2);
GNUNET_STATISTICS_get(p1.stats,"core","# discarded lower priority CORE_SEND request bytes",GNUNET_TIME_UNIT_SECONDS, &next_fin, &check_2, &p1);
GNUNET_SCHEDULER_add_now (&terminate_task, NULL);
}
-static size_t
-transmit_ready (void *cls, size_t size, void *buf);
static void
-send_tsk (void *cls,
- const struct GNUNET_SCHEDULER_TaskContext *tc)
-{
- send_task = GNUNET_SCHEDULER_NO_TASK;
-
- ch = GNUNET_CORE_notify_transmit_ready (p1.ch,
- 0,
- FAST_TIMEOUT,
- &p2.id,
- sizeof (struct TestMessage) + MEASUREMENT_MSG_SIZE,
- &transmit_ready, &p1);
-}
-
-
-static void
measure (unsigned long long quota_p1, unsigned long long quota_p2)
{
#if VERBOSE
&transmit_ready, &p1);
}
+static void connect_notify (void *cls,
+ const struct GNUNET_PeerIdentity *peer,
+ const struct GNUNET_TRANSPORT_ATS_Information *atsi)
+{
+ struct PeerContext *pc = cls;
+
+ GNUNET_assert (pc->connect_status == 0);
+ pc->connect_status = 1;
+ if (pc == &p1)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Encrypted connection established to peer `%4s'\n",
+ GNUNET_i2s (peer));
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Asking core (1) for transmission to peer `%4s'\n",
+ GNUNET_i2s (&p2.id));
+ measure (MEASUREMENT_MIN_QUOTA, MEASUREMENT_MIN_QUOTA);
+ }
+}
+
+
+static void
+disconnect_notify (void *cls,
+ const struct GNUNET_PeerIdentity *peer)
+{
+ struct PeerContext *pc = cls;
+ pc->connect_status = 0;
+#if DEBUG_CONNECTIONS
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Encrypted connection to `%4s' cut\n", GNUNET_i2s (peer));
+#endif
+}
+
+
+static int
+inbound_notify (void *cls,
+ const struct GNUNET_PeerIdentity *other,
+ const struct GNUNET_MessageHeader *message,
+ const struct GNUNET_TRANSPORT_ATS_Information *atsi)
+{
+ total_bytes_recv += ntohs (message->size);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Core provides inbound data from `%4s' size %u.\n", GNUNET_i2s (other), ntohs (message->size));
+#if DEBUG_CONNECTIONS
+ #endif
+ return GNUNET_OK;
+}
+
+
+static int
+outbound_notify (void *cls,
+ const struct GNUNET_PeerIdentity *other,
+ const struct GNUNET_MessageHeader *message,
+ const struct GNUNET_TRANSPORT_ATS_Information *atsi)
+{
+#if DEBUG_CONNECTIONS
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Core notifies about outbound data for `%4s'.\n",
+ GNUNET_i2s (other));
+#endif
+ return GNUNET_OK;
+}
+
+
static int tr_n;
if (measurement_running != GNUNET_YES)
return 0;
- GNUNET_assert (size <= GNUNET_CONSTANTS_MAX_ENCRYPTED_MESSAGE_SIZE);
+ GNUNET_assert (size <= GNUNET_CONSTANTS_MAX_ENCRYPTED_MESSAGE_SIZE);
if (buf == NULL)
{
if (p1.ch != NULL)
while (size - ret >= s);
GNUNET_SCHEDULER_cancel (err_task);
err_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT,
- &terminate_task_error,
+ &terminate_task_error,
NULL);
total_bytes += ret;
&init_notify,
&connect_notify,
&disconnect_notify,
- NULL,
+ NULL,
&inbound_notify,
GNUNET_YES,
&outbound_notify, GNUNET_YES, handlers);
GNUNET_assert (ok == 3);
OKPP;
GNUNET_assert (cls == &p2);
-
- measure (MEASUREMENT_MIN_QUOTA, MEASUREMENT_MIN_QUOTA);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Asking core (1) to connect to peer `%4s'\n",
+ GNUNET_i2s (&p2.id));
+ GNUNET_CORE_peer_request_connect (p1.ch,
+ GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5),
+ &p2.id,
+ NULL, NULL);
}
}