[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r37616 - in gnunet/src: ats-tests include
From: |
gnunet |
Subject: |
[GNUnet-SVN] r37616 - in gnunet/src: ats-tests include |
Date: |
Fri, 29 Jul 2016 22:32:23 +0200 |
Author: grothoff
Date: 2016-07-29 22:32:23 +0200 (Fri, 29 Jul 2016)
New Revision: 37616
Modified:
gnunet/src/ats-tests/Makefile.am
gnunet/src/ats-tests/ats-testing-traffic.c
gnunet/src/ats-tests/ats-testing.c
gnunet/src/ats-tests/ats-testing.h
gnunet/src/ats-tests/perf_ats.c
gnunet/src/include/gnunet_transport_core_service.h
Log:
-migrating ATS tests to new transport (and core) API; core tests disabled as
new core API doesn't exist yet
Modified: gnunet/src/ats-tests/Makefile.am
===================================================================
--- gnunet/src/ats-tests/Makefile.am 2016-07-29 20:31:52 UTC (rev 37615)
+++ gnunet/src/ats-tests/Makefile.am 2016-07-29 20:32:23 UTC (rev 37616)
@@ -14,23 +14,31 @@
endif
if HAVE_LIBGLPK
- PERF_MLP = perf_ats_mlp_transport_none \
- perf_ats_mlp_core_none \
+ PERF_MLP = \
+ perf_ats_mlp_transport_none \
perf_ats_mlp_transport_bandwidth \
- perf_ats_mlp_core_bandwidth \
- perf_ats_mlp_transport_latency \
- perf_ats_mlp_core_latency
+ perf_ats_mlp_transport_latency
+# core-related test commented out while we wait
+# for GNUNET_CORE_connecT to be implemented!
+# perf_ats_mlp_core_none \
+# perf_ats_mlp_core_bandwidth \
+# perf_ats_mlp_core_latency
endif
if HAVE_TESTING
TESTING_TESTS = \
perf_ats_proportional_transport_none \
- perf_ats_proportional_core_none \
perf_ats_proportional_transport_bandwidth \
- perf_ats_proportional_core_bandwidth \
perf_ats_proportional_transport_latency \
- perf_ats_proportional_core_latency \
$(PERF_MLP)
+
+# core-related test commented out while we wait
+# for GNUNET_CORE_connecT to be implemented!
+# perf_ats_proportional_core_none \
+# perf_ats_proportional_core_bandwidth \
+# perf_ats_proportional_core_latency
+
+# RIL-tests commented out as RIL is currently badly broken.
# perf_ats_ril_transport_none perf_ats_ril_core_none
perf_ats_ril_transport_bandwidth perf_ats_ril_core_bandwidth
perf_ats_ril_transport_latency perf_ats_ril_core_latency
endif
@@ -257,7 +265,7 @@
EXTRA_DIST = \
- gnunet_ats_sim_default.conf \
+ gnunet_ats_sim_default.conf \
perf_ats_proportional_none.conf \
perf_ats_proportional_bandwidth.conf \
perf_ats_proportional_latency.conf \
Modified: gnunet/src/ats-tests/ats-testing-traffic.c
===================================================================
--- gnunet/src/ats-tests/ats-testing-traffic.c 2016-07-29 20:31:52 UTC (rev
37615)
+++ gnunet/src/ats-tests/ats-testing-traffic.c 2016-07-29 20:32:23 UTC (rev
37616)
@@ -1,6 +1,6 @@
/*
This file is part of GNUnet.
- Copyright (C) 2010-2013 GNUnet e.V.
+ Copyright (C) 2010-2013, 2016 GNUnet e.V.
GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
@@ -100,51 +100,12 @@
}
-static size_t
-send_ping_ready_cb (void *cls, size_t size, void *buf)
+static void
+update_ping_data (void *cls)
{
struct BenchmarkPartner *p = cls;
- static char msgbuf[TEST_MESSAGE_SIZE];
- struct GNUNET_MessageHeader *msg;
struct GNUNET_TIME_Relative delay;
- if (NULL == buf)
- {
- GNUNET_break (0);
- return 0;
- }
- if (size < TEST_MESSAGE_SIZE)
- {
- GNUNET_break (0);
- return 0;
- }
-
- GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
- "Master [%u]: Sending PING to [%u]\n",
- p->me->no, p->dest->no);
- if (top->test_core)
- {
- if (NULL == p->cth)
- {
- GNUNET_break (0);
- }
- p->cth = NULL;
- }
- else
- {
- if (NULL == p->tth)
- {
- GNUNET_break (0);
- }
- p->tth = NULL;
- }
-
- msg = (struct GNUNET_MessageHeader *) &msgbuf;
- memset (&msgbuf, 'a', TEST_MESSAGE_SIZE);
- msg->type = htons (TEST_MESSAGE_TYPE_PING);
- msg->size = htons (TEST_MESSAGE_SIZE);
- GNUNET_memcpy (buf, msg, TEST_MESSAGE_SIZE);
-
p->messages_sent++;
p->bytes_sent += TEST_MESSAGE_SIZE;
p->me->total_messages_sent++;
@@ -153,16 +114,16 @@
if (NULL == p->tg)
{
GNUNET_break (0);
- return TEST_MESSAGE_SIZE;
+ return;
}
delay = get_delay (p->tg);
-
- GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Delay for next transmission %llu ms\n",
- (long long unsigned int) delay.rel_value_us / 1000);
- p->tg->next_ping_transmission =
GNUNET_TIME_absolute_add(GNUNET_TIME_absolute_get(),
- delay);
-
- return TEST_MESSAGE_SIZE;
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Delay for next transmission %s\n",
+ GNUNET_STRINGS_relative_time_to_string (delay,
+ GNUNET_YES));
+ p->tg->next_ping_transmission
+ = GNUNET_TIME_absolute_add (GNUNET_TIME_absolute_get(),
+ delay);
}
@@ -170,53 +131,37 @@
comm_schedule_send (void *cls)
{
struct BenchmarkPartner *p = cls;
+ struct TestMessage *msg;
+ struct GNUNET_MQ_Envelope *env;
p->tg->send_task = NULL;
p->last_message_sent = GNUNET_TIME_absolute_get();
- if (GNUNET_YES == top->test_core)
- {
- p->cth = GNUNET_CORE_notify_transmit_ready (p->me->ch, GNUNET_NO,
- GNUNET_CORE_PRIO_BEST_EFFORT,
- GNUNET_TIME_UNIT_MINUTES,
- &p->dest->id,
- TEST_MESSAGE_SIZE,
- &send_ping_ready_cb, p);
- }
- else
- {
- p->tth = GNUNET_TRANSPORT_notify_transmit_ready (p->me->th,
- &p->dest->id,
- TEST_MESSAGE_SIZE,
- GNUNET_TIME_UNIT_MINUTES,
- &send_ping_ready_cb, p);
- }
+ env = GNUNET_MQ_msg (msg,
+ TEST_MESSAGE_TYPE_PING);
+ memset (msg->padding,
+ 'a',
+ sizeof (msg->padding));
+ GNUNET_MQ_notify_sent (env,
+ &update_ping_data,
+ p);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Master [%u]: Sending PING to [%u]\n",
+ p->me->no,
+ p->dest->no);
+ GNUNET_MQ_send (p->mq,
+ env);
}
-static size_t
-comm_send_pong_ready (void *cls, size_t size, void *buf)
+static void
+update_pong_data (void *cls)
{
- static char msgbuf[TEST_MESSAGE_SIZE];
struct BenchmarkPartner *p = cls;
- struct GNUNET_MessageHeader *msg;
- if (GNUNET_YES == top->test_core)
- p->cth = NULL;
- else
- p->tth = NULL;
-
p->messages_sent++;
p->bytes_sent += TEST_MESSAGE_SIZE;
p->me->total_messages_sent++;
p->me->total_bytes_sent += TEST_MESSAGE_SIZE;
-
- msg = (struct GNUNET_MessageHeader *) &msgbuf;
- memset (&msgbuf, 'a', TEST_MESSAGE_SIZE);
- msg->type = htons (TEST_MESSAGE_TYPE_PONG);
- msg->size = htons (TEST_MESSAGE_SIZE);
- GNUNET_memcpy (buf, msg, TEST_MESSAGE_SIZE);
-
- return TEST_MESSAGE_SIZE;
}
@@ -223,33 +168,29 @@
void
GNUNET_ATS_TEST_traffic_handle_ping (struct BenchmarkPartner *p)
{
+ struct TestMessage *msg;
+ struct GNUNET_MQ_Envelope *env;
+
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Slave [%u]: Received PING from [%u], sending PONG\n", p->me->no,
- p->dest->no);
-
+ "Slave [%u]: Received PING from [%u], sending PONG\n",
+ p->me->no,
+ p->dest->no);
p->messages_received++;
p->bytes_received += TEST_MESSAGE_SIZE;
p->me->total_messages_received++;
p->me->total_bytes_received += TEST_MESSAGE_SIZE;
- if (GNUNET_YES == top->test_core)
- {
- GNUNET_assert (NULL == p->cth);
-
- p->cth
- = GNUNET_CORE_notify_transmit_ready (p->me->ch, GNUNET_NO,
- GNUNET_CORE_PRIO_BEST_EFFORT,
- GNUNET_TIME_UNIT_MINUTES,
- &p->dest->id, TEST_MESSAGE_SIZE,
- &comm_send_pong_ready, p);
- }
- else
- {
- GNUNET_assert (NULL == p->tth);
- p->tth = GNUNET_TRANSPORT_notify_transmit_ready (p->me->th, &p->dest->id,
- TEST_MESSAGE_SIZE, GNUNET_TIME_UNIT_MINUTES, &comm_send_pong_ready,
- p);
- }
+
+ env = GNUNET_MQ_msg (msg,
+ TEST_MESSAGE_TYPE_PING);
+ memset (msg->padding,
+ 'a',
+ sizeof (msg->padding));
+ GNUNET_MQ_notify_sent (env,
+ &update_pong_data,
+ p);
+ GNUNET_MQ_send (p->mq,
+ env);
}
@@ -258,8 +199,9 @@
{
struct GNUNET_TIME_Relative left;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Master [%u]: Received PONG from [%u], next message\n", p->me->no,
- p->dest->no);
+ "Master [%u]: Received PONG from [%u], next message\n",
+ p->me->no,
+ p->dest->no);
p->messages_received++;
p->bytes_received += TEST_MESSAGE_SIZE;
@@ -325,7 +267,9 @@
}
tg = GNUNET_new (struct TrafficGenerator);
- GNUNET_CONTAINER_DLL_insert (tg_head, tg_tail, tg);
+ GNUNET_CONTAINER_DLL_insert (tg_head,
+ tg_tail,
+ tg);
tg->type = type;
tg->src = src;
tg->dest = dest;
@@ -336,50 +280,53 @@
tg->next_ping_transmission = GNUNET_TIME_UNIT_FOREVER_ABS;
switch (type) {
- case GNUNET_ATS_TEST_TG_CONSTANT:
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Setting up constant traffic generator master[%u] `%s' and
slave [%u] `%s' max %u Bips\n",
- dest->me->no, GNUNET_i2s (&dest->me->id),
- dest->dest->no, GNUNET_i2s (&dest->dest->id),
- base_rate);
+ case GNUNET_ATS_TEST_TG_CONSTANT:
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Setting up constant traffic generator master[%u] `%s' and
slave [%u] `%s' max %u Bips\n",
+ dest->me->no,
+ GNUNET_i2s (&dest->me->id),
+ dest->dest->no,
+ GNUNET_i2s (&dest->dest->id),
+ base_rate);
+ break;
+ case GNUNET_ATS_TEST_TG_LINEAR:
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Setting up linear traffic generator master[%u] `%s' and slave
[%u] `%s' min %u Bips max %u Bips\n",
+ dest->me->no,
+ GNUNET_i2s (&dest->me->id),
+ dest->dest->no,
+ GNUNET_i2s (&dest->dest->id),
+ base_rate,
+ max_rate);
+ break;
+ case GNUNET_ATS_TEST_TG_SINUS:
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Setting up sinus traffic generator master[%u] `%s' and slave
[%u] `%s' baserate %u Bips, amplitude %u Bps\n",
+ dest->me->no,
+ GNUNET_i2s (&dest->me->id),
+ dest->dest->no,
+ GNUNET_i2s (&dest->dest->id),
+ base_rate,
+ max_rate);
+ break;
+ case GNUNET_ATS_TEST_TG_RANDOM:
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Setting up random traffic generator master[%u] `%s' and slave
[%u] `%s' min %u Bips max %u Bps\n",
+ dest->me->no,
+ GNUNET_i2s (&dest->me->id),
+ dest->dest->no,
+ GNUNET_i2s (&dest->dest->id),
+ base_rate,
+ max_rate);
break;
- case GNUNET_ATS_TEST_TG_LINEAR:
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Setting up linear traffic generator master[%u] `%s' and
slave [%u] `%s' min %u Bips max %u Bips\n",
- dest->me->no, GNUNET_i2s (&dest->me->id),
- dest->dest->no, GNUNET_i2s (&dest->dest->id),
- base_rate,
- max_rate);
- break;
- case GNUNET_ATS_TEST_TG_SINUS:
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Setting up sinus traffic generator master[%u] `%s' and
slave [%u] `%s' baserate %u Bips, amplitude %u Bps\n",
- dest->me->no, GNUNET_i2s (&dest->me->id),
- dest->dest->no, GNUNET_i2s (&dest->dest->id),
- base_rate, max_rate);
- break;
- case GNUNET_ATS_TEST_TG_RANDOM:
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Setting up random traffic generator master[%u] `%s' and
slave [%u] `%s' min %u Bips max %u Bps\n",
- dest->me->no, GNUNET_i2s (&dest->me->id),
- dest->dest->no, GNUNET_i2s (&dest->dest->id),
- base_rate, max_rate);
- break;
default:
break;
}
- if ( ((GNUNET_YES == top->test_core) && (NULL != dest->cth)) ||
- ((GNUNET_NO == top->test_core) && (NULL != dest->tth)) )
- {
- GNUNET_break (0);
- GNUNET_CONTAINER_DLL_remove (tg_head, tg_tail, tg);
- GNUNET_free (tg);
- return NULL;
- }
-
dest->tg = tg;
- tg->send_task = GNUNET_SCHEDULER_add_now (&comm_schedule_send, dest);
+ tg->send_task
+ = GNUNET_SCHEDULER_add_now (&comm_schedule_send,
+ dest);
return tg;
}
@@ -387,30 +334,15 @@
void
GNUNET_ATS_TEST_generate_traffic_stop (struct TrafficGenerator *tg)
{
- GNUNET_CONTAINER_DLL_remove (tg_head, tg_tail, tg);
+ GNUNET_CONTAINER_DLL_remove (tg_head,
+ tg_tail,
+ tg);
tg->dest->tg = NULL;
-
if (NULL != tg->send_task)
{
GNUNET_SCHEDULER_cancel (tg->send_task);
tg->send_task = NULL;
}
- if (top->test_core)
- {
- if (NULL != tg->dest->cth)
- {
- GNUNET_CORE_notify_transmit_ready_cancel (tg->dest->cth);
- tg->dest->cth = NULL;
- }
- }
- else
- {
- if (NULL != tg->dest->tth)
- {
- GNUNET_TRANSPORT_notify_transmit_ready_cancel (tg->dest->tth);
- tg->dest->tth = NULL;
- }
- }
GNUNET_free (tg);
}
@@ -423,11 +355,12 @@
{
struct TrafficGenerator *cur;
struct TrafficGenerator *next;
+
next = tg_head;
for (cur = next; NULL != cur; cur = next)
{
- next = cur->next;
- GNUNET_ATS_TEST_generate_traffic_stop(cur);
+ next = cur->next;
+ GNUNET_ATS_TEST_generate_traffic_stop(cur);
}
}
Modified: gnunet/src/ats-tests/ats-testing.c
===================================================================
--- gnunet/src/ats-tests/ats-testing.c 2016-07-29 20:31:52 UTC (rev 37615)
+++ gnunet/src/ats-tests/ats-testing.c 2016-07-29 20:32:23 UTC (rev 37616)
@@ -1,6 +1,6 @@
/*
This file is part of GNUnet.
- Copyright (C) 2010-2013 GNUnet e.V.
+ Copyright (C) 2010-2013, 2016 GNUnet e.V.
GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
@@ -93,18 +93,13 @@
GNUNET_CORE_notify_transmit_ready_cancel (p->partners[c_op].cth);
p->partners[c_op].cth = NULL;
}
- if (NULL != p->partners[c_op].tth)
- {
- GNUNET_TRANSPORT_notify_transmit_ready_cancel (p->partners[c_op].tth);
- p->partners[c_op].tth = NULL;
- }
if ( (NULL != p->core_connect_ops) &&
(NULL != p->core_connect_ops[c_op].connect_op) )
{
- GNUNET_log(GNUNET_ERROR_TYPE_INFO,
- _("Failed to connect peer 0 and %u\n"), c_op);
- GNUNET_TESTBED_operation_done (
- p->core_connect_ops[c_op].connect_op);
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Failed to connect peer 0 and %u\n",
+ c_op);
+ GNUNET_TESTBED_operation_done (p->core_connect_ops[c_op].connect_op);
p->core_connect_ops[c_op].connect_op = NULL;
}
}
@@ -141,11 +136,6 @@
GNUNET_CORE_notify_transmit_ready_cancel (p->partners[c_op].cth);
p->partners[c_op].cth = NULL;
}
- if (NULL != p->partners[c_op].tth)
- {
- GNUNET_TRANSPORT_notify_transmit_ready_cancel (p->partners[c_op].tth);
- p->partners[c_op].tth = NULL;
- }
}
if (NULL != p->ats_perf_op)
{
@@ -216,13 +206,17 @@
*
* @param cls closure
* @param peer peer identity this notification is about
+ * @param mq queue to use to send messages to @a peer
+ * @return the `struct BenchmarkPartner` of @a peer
*/
-static void
+static void *
comm_connect_cb (void *cls,
- const struct GNUNET_PeerIdentity *peer)
+ const struct GNUNET_PeerIdentity *peer,
+ struct GNUNET_MQ_Handle *mq)
{
struct BenchmarkPeer *me = cls;
struct BenchmarkPeer *remote;
+ struct BenchmarkPartner *p;
char *id;
int c;
int completed;
@@ -233,28 +227,32 @@
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
"Unknown peer connected: `%s'\n",
GNUNET_i2s (peer));
- GNUNET_break(0);
- return;
+ GNUNET_break (0);
+ return NULL;
}
id = GNUNET_strdup (GNUNET_i2s (&me->id));
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"%s [%u] `%s' connected to %s [%u] %s\n",
- (me->master == GNUNET_YES) ? "Master": "Slave", me->no, id,
- (remote->master == GNUNET_YES) ? "Master": "Slave", remote->no,
+ (me->master == GNUNET_YES) ? "Master": "Slave",
+ me->no,
+ id,
+ (remote->master == GNUNET_YES) ? "Master": "Slave",
+ remote->no,
GNUNET_i2s (peer));
me->core_connections++;
- if ((GNUNET_YES == me->master) && (GNUNET_NO == remote->master)
- && (GNUNET_NO == top->state.connected_CORE))
+ if ((GNUNET_YES == me->master) &&
+ (GNUNET_NO == remote->master) &&
+ (GNUNET_NO == top->state.connected_CORE))
{
me->core_slave_connections++;
if (me->core_slave_connections == top->num_slaves)
{
- GNUNET_log(GNUNET_ERROR_TYPE_INFO,
- "Master [%u] connected all slaves\n",
- me->no);
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Master [%u] connected all slaves\n",
+ me->no);
}
completed = GNUNET_YES;
for (c = 0; c < top->num_masters; c++)
@@ -269,22 +267,35 @@
top->state.connected_CORE = GNUNET_YES;
/* Notify about setup done */
if (NULL != top->done_cb)
- top->done_cb (top->done_cb_cls, top->mps, top->sps);
+ top->done_cb (top->done_cb_cls,
+ top->mps,
+ top->sps);
}
}
- GNUNET_free(id);
+ GNUNET_free (id);
+ p = find_partner (me,
+ peer);
+ if (NULL != p)
+ p->mq = mq;
+ return p;
}
+/**
+ * @param cls this peer
+ * @param peer id of disconnecting peer
+ * @param internal_cls the `struct BenchmarkPartner` of @a peer
+ */
static void
comm_disconnect_cb (void *cls,
- const struct GNUNET_PeerIdentity *peer)
+ const struct GNUNET_PeerIdentity *peer,
+ void *internal_cls)
{
struct BenchmarkPeer *me = cls;
- struct BenchmarkPartner *p;
+ struct BenchmarkPartner *p = internal_cls;
char *id;
- if (NULL == (p = find_partner (me, peer)))
+ if (NULL == p)
return;
id = GNUNET_strdup (GNUNET_i2s (&me->id));
@@ -292,7 +303,7 @@
"%s disconnected from %s\n",
id,
GNUNET_i2s (peer));
- GNUNET_assert(me->core_connections > 0);
+ GNUNET_assert (me->core_connections > 0);
me->core_connections--;
if ( (GNUNET_YES == top->state.benchmarking) &&
@@ -299,15 +310,10 @@
( (GNUNET_YES == me->master) ||
(GNUNET_YES == p->dest->master) ) )
{
- GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
- "%s disconnected from %s while benchmarking\n",
- id,
- GNUNET_i2s (peer));
- if (NULL != p->tth)
- {
- GNUNET_TRANSPORT_notify_transmit_ready_cancel (p->tth);
- p->tth = NULL;
- }
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "%s disconnected from %s while benchmarking\n",
+ id,
+ GNUNET_i2s (peer));
if (NULL != p->cth)
{
GNUNET_CORE_notify_transmit_ready_cancel (p->cth);
@@ -318,121 +324,106 @@
}
-static void *
-core_connect_adapter (void *cls,
- const struct GNUNET_CONFIGURATION_Handle *cfg)
+static void
+handle_pong (void *cls,
+ const struct TestMessage *message)
{
- struct BenchmarkPeer *me = cls;
+ struct BenchmarkPartner *p = cls;
- me->ch = GNUNET_CORE_connect (cfg,
- me,
- NULL,
- &comm_connect_cb,
- &comm_disconnect_cb,
- NULL,
- GNUNET_NO,
- NULL,
- GNUNET_NO,
- top->handlers);
- if (NULL == me->ch)
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Failed to create core connection \n");
- return me->ch;
+ GNUNET_ATS_TEST_traffic_handle_pong (p);
}
static void
-core_disconnect_adapter (void *cls, void *op_result)
+handle_ping (void *cls,
+ const struct TestMessage *message)
{
- struct BenchmarkPeer *me = cls;
+ struct BenchmarkPartner *p = cls;
- GNUNET_CORE_disconnect (me->ch);
- me->ch = NULL;
+ GNUNET_ATS_TEST_traffic_handle_ping (p);
}
-static int
-comm_handle_pong (void *cls,
- const struct GNUNET_PeerIdentity *other,
- const struct GNUNET_MessageHeader *message)
+static void *
+transport_connect_adapter (void *cls,
+ const struct GNUNET_CONFIGURATION_Handle *cfg)
{
+ GNUNET_MQ_hd_fixed_size (ping,
+ TEST_MESSAGE_TYPE_PING,
+ struct TestMessage);
+ GNUNET_MQ_hd_fixed_size (pong,
+ TEST_MESSAGE_TYPE_PONG,
+ struct TestMessage);
struct BenchmarkPeer *me = cls;
- struct BenchmarkPartner *p = NULL;
+ struct GNUNET_MQ_MessageHandler handlers[] = {
+ make_ping_handler (me),
+ make_pong_handler (me),
+ GNUNET_MQ_handler_end ()
+ };
- if (NULL == (p = find_partner (me, other)))
- {
- GNUNET_break(0);
- return GNUNET_SYSERR;
- }
-
- GNUNET_ATS_TEST_traffic_handle_pong (p);
-
- return GNUNET_OK;
+ me->th = GNUNET_TRANSPORT_core_connect (cfg,
+ &me->id,
+ handlers,
+ me,
+ &comm_connect_cb,
+ &comm_disconnect_cb,
+ NULL);
+ if (NULL == me->th)
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Failed to create transport connection \n");
+ return me->th;
}
-static int
-comm_handle_ping (void *cls,
- const struct GNUNET_PeerIdentity *other,
- const struct GNUNET_MessageHeader *message)
+static void
+transport_disconnect_adapter (void *cls,
+ void *op_result)
{
struct BenchmarkPeer *me = cls;
- struct BenchmarkPartner *p = NULL;
- if (NULL == (p = find_partner(me, other)))
- {
- GNUNET_break(0);
- return GNUNET_SYSERR;
- }
- GNUNET_ATS_TEST_traffic_handle_ping (p);
- return GNUNET_OK;
+ GNUNET_TRANSPORT_core_disconnect (me->th);
+ me->th = NULL;
}
-static void
-test_recv_cb (void *cls,
- const struct GNUNET_PeerIdentity *peer,
- const struct GNUNET_MessageHeader *message)
-{
- if ( (TEST_MESSAGE_SIZE != ntohs (message->size)) ||
- ( (TEST_MESSAGE_TYPE_PING != ntohs (message->type)) &&
- (TEST_MESSAGE_TYPE_PONG != ntohs (message->type)) ) )
- {
- return;
- }
- if (TEST_MESSAGE_TYPE_PING == ntohs (message->type))
- comm_handle_ping (cls, peer, message);
- if (TEST_MESSAGE_TYPE_PONG == ntohs (message->type))
- comm_handle_pong (cls, peer, message);
-}
-
-
static void *
-transport_connect_adapter (void *cls,
- const struct GNUNET_CONFIGURATION_Handle *cfg)
+core_connect_adapter (void *cls,
+ const struct GNUNET_CONFIGURATION_Handle *cfg)
{
+ GNUNET_MQ_hd_fixed_size (ping,
+ TEST_MESSAGE_TYPE_PING,
+ struct TestMessage);
+ GNUNET_MQ_hd_fixed_size (pong,
+ TEST_MESSAGE_TYPE_PONG,
+ struct TestMessage);
struct BenchmarkPeer *me = cls;
+ struct GNUNET_MQ_MessageHandler handlers[] = {
+ make_ping_handler (me),
+ make_pong_handler (me),
+ GNUNET_MQ_handler_end ()
+ };
- me->th = GNUNET_TRANSPORT_connect (cfg,
- &me->id,
- me,
- &test_recv_cb,
- &comm_connect_cb,
- &comm_disconnect_cb);
- if (NULL == me->th)
- GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
- "Failed to create transport connection \n");
- return me->th;
+ me->ch = GNUNET_CORE_connecT (cfg,
+ me,
+ NULL,
+ &comm_connect_cb,
+ &comm_disconnect_cb,
+ handlers);
+ if (NULL == me->ch)
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Failed to create core connection \n");
+ return me->ch;
}
static void
-transport_disconnect_adapter (void *cls, void *op_result)
+core_disconnect_adapter (void *cls,
+ void *op_result)
{
struct BenchmarkPeer *me = cls;
- GNUNET_TRANSPORT_disconnect (me->th);
- me->th = NULL;
+ GNUNET_CORE_disconnect (me->ch);
+ me->ch = NULL;
}
@@ -484,8 +475,8 @@
(top->state.connected_COMM_service == GNUNET_NO))
return;
- GNUNET_log(GNUNET_ERROR_TYPE_INFO, _("Connecting peers on CORE level\n"));
-
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Connecting peers on CORE level\n");
for (c_m = 0; c_m < top->num_masters; c_m++)
{
p = &top->mps[c_m];
@@ -494,18 +485,24 @@
for (c_s = 0; c_s < top->num_slaves; c_s++)
{
- GNUNET_log(GNUNET_ERROR_TYPE_INFO,
- _("Connecting master [%u] with slave [%u]\n"), p->no,
top->sps[c_s].no);
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Connecting master [%u] with slave [%u]\n",
+ p->no,
+ top->sps[c_s].no);
p->core_connect_ops[c_s].master = p;
p->core_connect_ops[c_s].slave = &top->sps[c_s];
- p->core_connect_ops[c_s].connect_op = GNUNET_TESTBED_overlay_connect (
- NULL, &connect_completion_callback, &p->core_connect_ops[c_s],
- top->sps[c_s].peer, p->peer);
+ p->core_connect_ops[c_s].connect_op
+ = GNUNET_TESTBED_overlay_connect (NULL,
+ &connect_completion_callback,
+ &p->core_connect_ops[c_s],
+ top->sps[c_s].peer,
+ p->peer);
if (NULL == p->core_connect_ops[c_s].connect_op)
- {
- GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
- _("Could not connect master [%u] and slave [%u]\n"), p->no,
- top->sps[c_s].no);
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Could not connect master [%u] and slave [%u]\n",
+ p->no,
+ top->sps[c_s].no);
GNUNET_break(0);
GNUNET_SCHEDULER_shutdown ();
return;
@@ -535,10 +532,12 @@
if (comm_done == top->num_slaves + top->num_masters)
{
- GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Connected to all %s services\n",
- (GNUNET_YES == top->test_core) ? "CORE" : "TRANSPORT");
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Connected to all %s services\n",
+ (GNUNET_YES == top->test_core) ? "CORE" : "TRANSPORT");
top->state.connected_COMM_service = GNUNET_YES;
- GNUNET_SCHEDULER_add_now (&do_connect_peers, NULL );
+ GNUNET_SCHEDULER_add_now (&do_connect_peers,
+ NULL);
}
}
@@ -548,19 +547,32 @@
{
int c_s;
int c_m;
- GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Connecting to all %s services\n",
- (GNUNET_YES == top->test_core) ? "CORE" : "TRANSPORT");
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Connecting to all %s services\n",
+ (GNUNET_YES == top->test_core) ? "CORE" : "TRANSPORT");
for (c_m = 0; c_m < top->num_masters; c_m++)
{
if (GNUNET_YES == top->test_core)
- top->mps[c_m].comm_op = GNUNET_TESTBED_service_connect (NULL,
top->mps[c_m].peer,
- "core", &comm_connect_completion_cb, NULL, &core_connect_adapter,
- &core_disconnect_adapter, &top->mps[c_m]);
+ top->mps[c_m].comm_op
+ = GNUNET_TESTBED_service_connect (NULL,
+ top->mps[c_m].peer,
+ "core",
+ &comm_connect_completion_cb,
+ NULL,
+ &core_connect_adapter,
+ &core_disconnect_adapter,
+ &top->mps[c_m]);
else
{
- top->mps[c_m].comm_op = GNUNET_TESTBED_service_connect (NULL,
top->mps[c_m].peer,
- "transport", &comm_connect_completion_cb, NULL,
&transport_connect_adapter,
- &transport_disconnect_adapter, &top->mps[c_m]);
+ top->mps[c_m].comm_op
+ = GNUNET_TESTBED_service_connect (NULL,
+ top->mps[c_m].peer,
+ "transport",
+ &comm_connect_completion_cb,
+ NULL,
+ &transport_connect_adapter,
+ &transport_disconnect_adapter,
+ &top->mps[c_m]);
}
}
@@ -567,14 +579,26 @@
for (c_s = 0; c_s < top->num_slaves; c_s++)
{
if (GNUNET_YES == top->test_core)
- top->sps[c_s].comm_op = GNUNET_TESTBED_service_connect (NULL,
top->sps[c_s].peer,
- "core", &comm_connect_completion_cb, NULL, &core_connect_adapter,
- &core_disconnect_adapter, &top->sps[c_s]);
+ top->sps[c_s].comm_op
+ = GNUNET_TESTBED_service_connect (NULL,
+ top->sps[c_s].peer,
+ "core",
+ &comm_connect_completion_cb,
+ NULL,
+ &core_connect_adapter,
+ &core_disconnect_adapter,
+ &top->sps[c_s]);
else
{
- top->sps[c_s].comm_op = GNUNET_TESTBED_service_connect (NULL,
top->sps[c_s].peer,
- "transport", &comm_connect_completion_cb, NULL,
&transport_connect_adapter,
- &transport_disconnect_adapter, &top->sps[c_s]);
+ top->sps[c_s].comm_op
+ = GNUNET_TESTBED_service_connect (NULL,
+ top->sps[c_s].peer,
+ "transport",
+ &comm_connect_completion_cb,
+ NULL,
+ &transport_connect_adapter,
+ &transport_disconnect_adapter,
+ &top->sps[c_s]);
}
}
}
@@ -595,12 +619,14 @@
if (NULL == address)
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Peer %u: ATS Service
disconnected!\n",
- me->no);
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Peer %u: ATS Service disconnected!\n",
+ me->no);
return;
}
- p = find_partner (me, &address->peer);
+ p = find_partner (me,
+ &address->peer);
if (NULL == p)
{
/* This is not one of my partners
@@ -657,7 +683,8 @@
static void
-ats_perf_disconnect_adapter (void *cls, void *op_result)
+ats_perf_disconnect_adapter (void *cls,
+ void *op_result)
{
struct BenchmarkPeer *me = cls;
@@ -743,9 +770,11 @@
GNUNET_assert(pinfo->pit == GNUNET_TESTBED_PIT_IDENTITY);
p->id = *pinfo->result.id;
- GNUNET_log(GNUNET_ERROR_TYPE_INFO, "%s [%u] has peer id `%s'\n",
- (p->master == GNUNET_YES) ? "Master" : "Slave", p->no,
- GNUNET_i2s (&p->id));
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "%s [%u] has peer id `%s'\n",
+ (p->master == GNUNET_YES) ? "Master" : "Slave",
+ p->no,
+ GNUNET_i2s (&p->id));
GNUNET_TESTBED_operation_done (op);
p->peer_id_op = NULL;
@@ -753,12 +782,14 @@
if (done == top->num_slaves + top->num_masters)
{
- GNUNET_log(GNUNET_ERROR_TYPE_INFO,
- "Retrieved all peer ID, connect to ATS\n");
- GNUNET_SCHEDULER_add_now (&do_connect_ats, NULL );
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Retrieved all peer ID, connect to ATS\n");
+ GNUNET_SCHEDULER_add_now (&do_connect_ats,
+ NULL);
}
}
+
/**
* Signature of a main function for a testcase.
*
@@ -772,7 +803,8 @@
* failed
*/
static void
-main_run (void *cls, struct GNUNET_TESTBED_RunHandle *h,
+main_run (void *cls,
+ struct GNUNET_TESTBED_RunHandle *h,
unsigned int num_peers,
struct GNUNET_TESTBED_Peer **peers_,
unsigned int links_succeeded,
@@ -781,9 +813,9 @@
int c_m;
int c_s;
- GNUNET_assert(NULL == cls);
- GNUNET_assert(top->num_masters + top->num_slaves == num_peers);
- GNUNET_assert(NULL != peers_);
+ GNUNET_assert (NULL == cls);
+ GNUNET_assert (top->num_masters + top->num_slaves == num_peers);
+ GNUNET_assert (NULL != peers_);
GNUNET_SCHEDULER_add_shutdown (&do_shutdown,
top);
@@ -812,8 +844,11 @@
top->mps[c_m].partners[c_s].dest = &top->sps[c_s];
}
/* Get configuration */
- top->mps[c_m].peer_id_op = GNUNET_TESTBED_peer_get_information
(top->mps[c_m].peer,
- GNUNET_TESTBED_PIT_IDENTITY, &peerinformation_cb, &top->mps[c_m]);
+ top->mps[c_m].peer_id_op
+ = GNUNET_TESTBED_peer_get_information (top->mps[c_m].peer,
+ GNUNET_TESTBED_PIT_IDENTITY,
+ &peerinformation_cb,
+ &top->mps[c_m]);
}
/* Setup slave peers */
@@ -824,7 +859,8 @@
top->sps[c_s].no = c_s + top->num_masters;
top->sps[c_s].master = GNUNET_NO;
top->sps[c_s].partners =
- GNUNET_malloc (top->num_masters * sizeof (struct BenchmarkPartner));
+ GNUNET_new_array (top->num_masters,
+ struct BenchmarkPartner);
top->sps[c_s].num_partners = top->num_masters;
/* Initialize partners */
for (c_m = 0; c_m < top->num_masters; c_m++)
@@ -840,11 +876,15 @@
top->sps[c_s].partners[c_m].props.utilization_out = 0;
}
/* Get configuration */
- top->sps[c_s].peer_id_op = GNUNET_TESTBED_peer_get_information
(top->sps[c_s].peer,
- GNUNET_TESTBED_PIT_IDENTITY, &peerinformation_cb, &top->sps[c_s]);
+ top->sps[c_s].peer_id_op
+ = GNUNET_TESTBED_peer_get_information (top->sps[c_s].peer,
+ GNUNET_TESTBED_PIT_IDENTITY,
+ &peerinformation_cb,
+ &top->sps[c_s]);
}
}
+
/**
* Controller event callback
*
@@ -878,7 +918,8 @@
struct BenchmarkPartner *
-GNUNET_ATS_TEST_get_partner (int src, int dest)
+GNUNET_ATS_TEST_get_partner (int src,
+ int dest)
{
if (src > top->num_masters)
return NULL;
@@ -909,20 +950,13 @@
void *done_cb_cls,
GNUNET_ATS_AddressInformationCallback
log_request_cb)
{
- static struct GNUNET_CORE_MessageHandler handlers[] = {
- {&comm_handle_ping, TEST_MESSAGE_TYPE_PING, 0 },
- {&comm_handle_pong, TEST_MESSAGE_TYPE_PONG, 0 },
- { NULL, 0, 0 } };
-
top = GNUNET_new (struct GNUNET_ATS_TEST_Topology);
top->num_masters = num_masters;
top->num_slaves = num_slaves;
- top->handlers = handlers;
top->done_cb = done_cb;
top->done_cb_cls = done_cb_cls;
top->test_core = test_core;
top->ats_perf_cb = log_request_cb;
-
top->mps = GNUNET_new_array (num_masters,
struct BenchmarkPeer);
top->sps = GNUNET_new_array (num_slaves,
@@ -933,8 +967,8 @@
event_mask = 0;
event_mask |= (1LL << GNUNET_TESTBED_ET_CONNECT);
event_mask |= (1LL << GNUNET_TESTBED_ET_OPERATION_FINISHED);
- (void) GNUNET_TESTBED_test_run (name, cfg_file,
-
+ (void) GNUNET_TESTBED_test_run (name,
+ cfg_file,
num_slaves + num_masters,
event_mask,
&controller_event_cb, NULL,
@@ -954,7 +988,4 @@
}
-
-
-
/* end of file ats-testing.c */
Modified: gnunet/src/ats-tests/ats-testing.h
===================================================================
--- gnunet/src/ats-tests/ats-testing.h 2016-07-29 20:31:52 UTC (rev 37615)
+++ gnunet/src/ats-tests/ats-testing.h 2016-07-29 20:32:23 UTC (rev 37616)
@@ -28,6 +28,7 @@
#include "gnunet_testbed_service.h"
#include "gnunet_ats_service.h"
#include "gnunet_core_service.h"
+#include "gnunet_transport_core_service.h"
#define TEST_ATS_PREFERENCE_DEFAULT 1.0
@@ -46,6 +47,15 @@
*/
#define TEST_MESSAGE_SIZE 100
+
+struct TestMessage
+{
+ struct GNUNET_MessageHeader header;
+
+ uint8_t padding[TEST_MESSAGE_SIZE - sizeof (struct GNUNET_MessageHeader)];
+};
+
+
struct BenchmarkPartner;
struct BenchmarkPeer;
@@ -147,14 +157,14 @@
struct TestbedConnectOperation *core_connect_ops;
/**
- * Core handle
+ * Core handle
*/
struct GNUNET_CORE_Handle *ch;
/**
- * Core handle
+ * Transport handle
*/
- struct GNUNET_TRANSPORT_Handle *th;
+ struct GNUNET_TRANSPORT_CoreHandle *th;
/**
* Masters only:
@@ -280,11 +290,10 @@
struct GNUNET_CORE_TransmitHandle *cth;
/**
- * Transport transmit handles
+ * Message queue handle.
*/
- struct GNUNET_TRANSPORT_TransmitHandle *tth;
+ struct GNUNET_MQ_Handle *mq;
-
/**
* Handle for traffic generator
*/
@@ -325,24 +334,34 @@
*/
unsigned int bytes_received;
- /* Current ATS properties */
+ /**
+ * Current ATS properties
+ */
struct GNUNET_ATS_Properties props;
- /* Bandwidth assigned inbound */
+ /**
+ * Bandwidth assigned inbound
+ */
uint32_t bandwidth_in;
- /* Bandwidth assigned outbound */
+ /**
+ * Bandwidth assigned outbound
+ */
uint32_t bandwidth_out;
- /* Current preference values for bandwidth */
+ /**
+ * Current preference values for bandwidth
+ */
double pref_bandwidth;
- /* Current preference values for delay */
+ /**
+ * Current preference values for delay
+ */
double pref_delay;
-
};
+
/**
* Overall state of the performance benchmark
*/
@@ -387,7 +406,8 @@
*/
int result;
- /**Test core (GNUNET_YES) or transport (GNUNET_NO)
+ /**
+ * Test core (#GNUNET_YES) or transport (#GNUNET_NO)
*/
int test_core;
@@ -446,10 +466,10 @@
*/
struct BenchmarkState state;
- struct GNUNET_CORE_MessageHandler *handlers;
+ GNUNET_ATS_TEST_TopologySetupDoneCallback done_cb;
- GNUNET_ATS_TEST_TopologySetupDoneCallback done_cb;
GNUNET_ATS_AddressInformationCallback ats_perf_cb;
+
void *done_cb_cls;
};
@@ -465,11 +485,13 @@
struct Experiment;
-typedef void (*GNUNET_ATS_TESTING_EpisodeDoneCallback) (
- struct Episode *e);
+typedef void
+(*GNUNET_ATS_TESTING_EpisodeDoneCallback) (struct Episode *e);
-typedef void (*GNUNET_ATS_TESTING_ExperimentDoneCallback) (struct Experiment
*e,
- struct GNUNET_TIME_Relative duration,int success);
+typedef void
+(*GNUNET_ATS_TESTING_ExperimentDoneCallback) (struct Experiment *e,
+ struct GNUNET_TIME_Relative
duration,
+ int success);
/**
* An operation in an experiment
@@ -524,9 +546,7 @@
GNUNET_ATS_TESTING_ExperimentDoneCallback e_done_cb;
};
-/*
- * Experiment related functions
- */
+
extern struct GNUNET_CONFIGURATION_Handle *cfg;
/**
@@ -560,13 +580,11 @@
void
GNUNET_ATS_TEST_experimentation_stop (struct Experiment *e);
-/*
- * Traffic related functions
- */
void
GNUNET_ATS_TEST_traffic_handle_ping (struct BenchmarkPartner *p);
+
void
GNUNET_ATS_TEST_traffic_handle_pong (struct BenchmarkPartner *p);
@@ -597,6 +615,7 @@
void
GNUNET_ATS_TEST_generate_traffic_stop (struct TrafficGenerator *tg);
+
/**
* Stop all traffic generators
*/
@@ -628,6 +647,7 @@
struct GNUNET_TIME_Relative
frequency,
enum GNUNET_ATS_PreferenceKind
kind);
+
void
GNUNET_ATS_TEST_generate_preferences_stop (struct PreferenceGenerator *pg);
@@ -635,9 +655,6 @@
void
GNUNET_ATS_TEST_generate_preferences_stop_all (void);
-/*
- * Logging related functions
- */
/**
* Start logging
@@ -651,12 +668,12 @@
* @return the logging handle or NULL on error
*/
struct LoggingHandle *
-GNUNET_ATS_TEST_logging_start(struct GNUNET_TIME_Relative log_frequency,
- const char *testname,
- struct BenchmarkPeer *masters,
- int num_masters,
- int num_slaves,
- int verbose);
+GNUNET_ATS_TEST_logging_start (struct GNUNET_TIME_Relative log_frequency,
+ const char *testname,
+ struct BenchmarkPeer *masters,
+ int num_masters,
+ int num_slaves,
+ int verbose);
/**
Modified: gnunet/src/ats-tests/perf_ats.c
===================================================================
--- gnunet/src/ats-tests/perf_ats.c 2016-07-29 20:31:52 UTC (rev 37615)
+++ gnunet/src/ats-tests/perf_ats.c 2016-07-29 20:32:23 UTC (rev 37616)
@@ -573,11 +573,11 @@
*/
GNUNET_ATS_TEST_create_topology ("perf-ats",
conf_name,
- num_slaves, num_masters,
+ num_slaves,
+ num_masters,
test_core,
&do_benchmark,
NULL,
- NULL,
&log_request_cb);
return result;
Modified: gnunet/src/include/gnunet_transport_core_service.h
===================================================================
--- gnunet/src/include/gnunet_transport_core_service.h 2016-07-29 20:31:52 UTC
(rev 37615)
+++ gnunet/src/include/gnunet_transport_core_service.h 2016-07-29 20:32:23 UTC
(rev 37616)
@@ -79,7 +79,7 @@
* connect notification will be destroyed and must not be used
* henceforth.
*
- * @param cls closure from #GNUNET_TRANSPORT_connecT
+ * @param cls closure from #GNUNET_TRANSPORT_core_connect
* @param peer the peer that disconnected
* @param handlers_cls closure of the handlers, was returned from the
* connect notification callback
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r37616 - in gnunet/src: ats-tests include,
gnunet <=