summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authort3sserakt <t3ss@posteo.de>2020-10-14 13:08:54 +0200
committert3sserakt <t3ss@posteo.de>2020-10-14 13:08:54 +0200
commit032f5c0850c7034752be1c4c86a68fb9914ec3e0 (patch)
tree564f87de975bbc056606c6bdfd2c7a50d2f34c12
parente0ff55875db012dc8bc8daa02f1f71e872ccc347 (diff)
- Changed delay. Removed intial waiting
-rw-r--r--src/transport/test_communicator_basic.c207
-rw-r--r--src/transport/transport-testing2.c1
2 files changed, 159 insertions, 49 deletions
diff --git a/src/transport/test_communicator_basic.c b/src/transport/test_communicator_basic.c
index 43c98a401..d599d06c6 100644
--- a/src/transport/test_communicator_basic.c
+++ b/src/transport/test_communicator_basic.c
@@ -68,8 +68,6 @@ static struct GNUNET_TIME_Absolute timeout;
static struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *my_tc;
-#define DROP_RATIO 0.91
-
#define SHORT_MESSAGE_SIZE 128
#define LONG_MESSAGE_SIZE 32000 /* FIXME */
@@ -84,6 +82,11 @@ static struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *my_tc;
static unsigned int iterations_left = TOTAL_ITERATIONS;
+#define TIMEOUT_MULTIPLIER 1
+
+#define DELAY \
+ GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MICROSECONDS,30)
+
#define SHORT_BURST_WINDOW \
GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS,2)
@@ -99,13 +102,21 @@ enum TestPhase
};
-static size_t num_sent = 0;
+static size_t num_sent_short = 0;
+
+static size_t num_sent_long = 0;
+
+static size_t num_sent_size = 0;
static uint32_t ack = 0;
static enum TestPhase phase;
-static size_t num_received = 0;
+static size_t num_received_short = 0;
+
+static size_t num_received_long = 0;
+
+static size_t num_received_size = 0;
static uint64_t avg_latency = 0;
@@ -232,17 +243,34 @@ make_payload (size_t payload_size)
static void
latency_timeout (void *cls)
{
+
+ size_t num_sent = 0;
+ size_t num_received = 0;
+
to_task = NULL;
if (GNUNET_TIME_absolute_get_remaining (timeout).rel_value_us > 0)
{
- LOG (GNUNET_ERROR_TYPE_ERROR,
- "Reschedule latency task\n");
to_task = GNUNET_SCHEDULER_add_at (timeout,
&latency_timeout,
NULL);
return;
}
+ switch (phase)
+ {
+ case TP_BURST_SHORT:
+ num_sent = num_sent_short;
+ num_received = num_received_short;
+ break;
+ case TP_BURST_LONG:
+ num_sent = num_sent_long;
+ num_received = num_received_long;
+ break;
+ case TP_SIZE_CHECK:
+ num_sent = num_sent_size;
+ num_received = num_received_size;
+ break;
+ }
LOG (GNUNET_ERROR_TYPE_ERROR,
"Latency too high. Test failed. (Phase: %d. Sent: %lu, Received: %lu)\n",
phase, num_sent, num_received);
@@ -250,6 +278,8 @@ latency_timeout (void *cls)
GNUNET_SCHEDULER_shutdown ();
}
+/*static void
+ size_test (void *cls);*/
static void
size_test (void *cls)
@@ -257,6 +287,9 @@ size_test (void *cls)
char *payload;
size_t max_size = 64000;
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "size_test_cb %u\n",
+ num_sent_size);
GNUNET_assert (TP_SIZE_CHECK == phase);
if (LONG_MESSAGE_SIZE != long_message_size)
max_size = long_message_size;
@@ -264,7 +297,7 @@ size_test (void *cls)
return; /* Leave some room for our protocol, so not 2^16 exactly */
ack += 10;
payload = make_payload (ack);
- num_sent++;
+ num_sent_size++;
GNUNET_TRANSPORT_TESTING_transport_communicator_send (my_tc,
(ack < max_size)
? &size_test
@@ -273,47 +306,98 @@ size_test (void *cls)
payload,
ack);
GNUNET_free (payload);
- timeout = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_SECONDS);
+ timeout = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_relative_multiply (
+ GNUNET_TIME_UNIT_SECONDS,
+ TIMEOUT_MULTIPLIER));
}
+/*static void
+size_test (void *cls)
+{
+ GNUNET_SCHEDULER_add_delayed (DELAY,
+ &size_test_cb,
+ NULL);
+ }*/
+
+static void
+long_test (void *cls);
static void
-long_test (void *cls)
+long_test_cb (void *cls)
{
char *payload;
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "long_test_cb %u/%u\n",
+ num_sent_long,
+ num_received_long);
payload = make_payload (long_message_size);
- num_sent++;
+ num_sent_long++;
GNUNET_TRANSPORT_TESTING_transport_communicator_send (my_tc,
- (BURST_PACKETS ==
- num_sent)
+ ((BURST_PACKETS
+ * 0.91 ==
+ num_received_long) ||
+ (BURST_PACKETS ==
+ num_sent_long))
? NULL
: &long_test,
NULL,
payload,
long_message_size);
GNUNET_free (payload);
- timeout = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_SECONDS);
+ timeout = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_relative_multiply (
+ GNUNET_TIME_UNIT_SECONDS,
+ TIMEOUT_MULTIPLIER));
}
+static void
+long_test (void *cls)
+{
+ /*LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "long_test %u\n",
+ num_sent_long);*/
+ GNUNET_SCHEDULER_add_delayed (DELAY,
+ &long_test_cb,
+ NULL);
+}
static void
-short_test (void *cls)
+short_test (void *cls);
+
+static void
+short_test_cb (void *cls)
{
char *payload;
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "short_test_cb %u/%u\n",
+ num_sent_short,
+ num_received_short);
payload = make_payload (SHORT_MESSAGE_SIZE);
- num_sent++;
+ num_sent_short++;
GNUNET_TRANSPORT_TESTING_transport_communicator_send (my_tc,
- (BURST_PACKETS ==
- num_sent)
+ ((BURST_PACKETS
+ * 0.91 ==
+ num_received_short) ||
+ (BURST_PACKETS ==
+ num_sent_short))
? NULL
: &short_test,
NULL,
payload,
SHORT_MESSAGE_SIZE);
GNUNET_free (payload);
- timeout = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_SECONDS);
+ timeout = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_relative_multiply (
+ GNUNET_TIME_UNIT_SECONDS,
+ TIMEOUT_MULTIPLIER));
+}
+
+static void
+short_test (void *cls)
+{
+ GNUNET_SCHEDULER_add_delayed (DELAY,
+ &short_test_cb,
+ NULL);
}
@@ -378,10 +462,12 @@ add_queue_cb (void *cls,
long_message_size = LONG_MESSAGE_SIZE;
phase = TP_BURST_SHORT;
timeout = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_relative_multiply (
- GNUNET_TIME_UNIT_SECONDS, 2));
+ GNUNET_TIME_UNIT_SECONDS,
+ TIMEOUT_MULTIPLIER));
GNUNET_assert (NULL == to_task);
to_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (
- GNUNET_TIME_UNIT_SECONDS, 2),
+ GNUNET_TIME_UNIT_SECONDS,
+ TIMEOUT_MULTIPLIER),
&latency_timeout,
NULL);
// prepare_test (NULL);
@@ -395,10 +481,26 @@ update_avg_latency (const char*payload)
struct GNUNET_TIME_AbsoluteNBO *ts_n;
struct GNUNET_TIME_Absolute ts;
struct GNUNET_TIME_Relative latency;
+ size_t num_received = 0;
ts_n = (struct GNUNET_TIME_AbsoluteNBO *) payload;
ts = GNUNET_TIME_absolute_ntoh (*ts_n);
latency = GNUNET_TIME_absolute_get_duration (ts);
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Latency of received packet: %u\n",
+ latency);
+ switch (phase)
+ {
+ case TP_BURST_SHORT:
+ num_received = num_received_short;
+ break;
+ case TP_BURST_LONG:
+ num_received = num_received_long;
+ break;
+ case TP_SIZE_CHECK:
+ num_received = num_received_size;
+ break;
+ }
if (1 >= num_received)
avg_latency = latency.rel_value_us;
else
@@ -407,7 +509,6 @@ update_avg_latency (const char*payload)
}
-
/**
* @brief Handle an incoming message
*
@@ -419,7 +520,8 @@ update_avg_latency (const char*payload)
*/
static void
incoming_message_cb (void *cls,
- struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle
+ struct
+ GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle
*tc_h,
const char*payload,
size_t payload_len)
@@ -430,10 +532,10 @@ incoming_message_cb (void *cls,
"unexpected receiver...\n");
return;
}
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Incomming message\n");
/* Reset timeout */
- timeout = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_SECONDS);
+ timeout = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_relative_multiply (
+ GNUNET_TIME_UNIT_SECONDS,
+ TIMEOUT_MULTIPLIER));
switch (phase)
{
case TP_INIT:
@@ -442,30 +544,31 @@ incoming_message_cb (void *cls,
case TP_BURST_SHORT:
{
GNUNET_assert (SHORT_MESSAGE_SIZE == payload_len);
- num_received++;
+ num_received_short++;
duration = GNUNET_TIME_absolute_get_duration (start_short);
update_avg_latency (payload);
- if (num_received == BURST_PACKETS * DROP_RATIO)
+ if (num_received_short == BURST_PACKETS * 0.91)
{
LOG (GNUNET_ERROR_TYPE_MESSAGE,
"Short size packet test done.\n");
char *goodput = GNUNET_STRINGS_byte_size_fancy ((SHORT_MESSAGE_SIZE
- * num_received * 1000
+ * num_received_short
+ * 1000
* 1000)
/ duration.rel_value_us);
LOG (GNUNET_ERROR_TYPE_MESSAGE,
"%lu/%lu packets in %llu us (%s/s) -- avg latency: %llu us\n",
- (unsigned long) num_received,
- (unsigned long) num_sent,
+ (unsigned long) num_received_short,
+ (unsigned long) num_sent_short,
(unsigned long long) duration.rel_value_us,
goodput,
(unsigned long long) avg_latency);
GNUNET_free (goodput);
start_long = GNUNET_TIME_absolute_get ();
phase = TP_BURST_LONG;
- num_sent = 0;
+ // num_sent_short = 0;
avg_latency = 0;
- num_received = 0;
+ // num_received = 0;
long_test (NULL);
}
break;
@@ -476,32 +579,34 @@ incoming_message_cb (void *cls,
{
LOG (GNUNET_ERROR_TYPE_WARNING,
"Ignoring packet with wrong length\n");
- return; // Ignore
+ return; // Ignore
}
- num_received++;
+ num_received_long++;
duration = GNUNET_TIME_absolute_get_duration (start_long);
update_avg_latency (payload);
- if (num_received == BURST_PACKETS * DROP_RATIO)
+ if (num_received_long == BURST_PACKETS * 0.91)
{
LOG (GNUNET_ERROR_TYPE_MESSAGE,
"Long size packet test done.\n");
char *goodput = GNUNET_STRINGS_byte_size_fancy ((long_message_size
- * num_received * 1000
+ * num_received_long
+ * 1000
* 1000)
- / duration.rel_value_us);
+ / duration.
+ rel_value_us);
LOG (GNUNET_ERROR_TYPE_MESSAGE,
"%lu/%lu packets in %llu us (%s/s) -- avg latency: %llu us\n",
- (unsigned long) num_received,
- (unsigned long) num_sent,
+ (unsigned long) num_received_long,
+ (unsigned long) num_sent_long,
(unsigned long long) duration.rel_value_us,
goodput,
(unsigned long long) avg_latency);
GNUNET_free (goodput);
ack = 0;
phase = TP_SIZE_CHECK;
- num_received = 0;
- num_sent = 0;
+ // num_received = 0;
+ // num_sent_long = 0;
avg_latency = 0;
size_test (NULL);
}
@@ -514,25 +619,29 @@ incoming_message_cb (void *cls,
GNUNET_assert (TP_SIZE_CHECK == phase);
if (LONG_MESSAGE_SIZE != long_message_size)
max_size = long_message_size;
- num_received++;
+ num_received_size++;
update_avg_latency (payload);
- if (num_received >= (max_size) / 10)
+ if (num_received_size >= (max_size) / 10)
{
LOG (GNUNET_ERROR_TYPE_MESSAGE,
"Size packet test done.\n");
LOG (GNUNET_ERROR_TYPE_MESSAGE,
"%lu/%lu packets -- avg latency: %llu us\n",
- (unsigned long) num_received,
- (unsigned long) num_sent,
+ (unsigned long) num_received_size,
+ (unsigned long) num_sent_size,
(unsigned long long) avg_latency);
- num_received = 0;
- num_sent = 0;
+ num_received_size = 0;
+ num_sent_size = 0;
avg_latency = 0;
iterations_left--;
if (0 != iterations_left)
{
start_short = GNUNET_TIME_absolute_get ();
phase = TP_BURST_SHORT;
+ num_sent_short = 0;
+ num_sent_long = 0;
+ num_received_short = 0;
+ num_received_long = 0;
short_test (NULL);
break;
}
@@ -570,8 +679,8 @@ static void
run (void *cls)
{
ret = 0;
- num_received = 0;
- num_sent = 0;
+ // num_received = 0;
+ // num_sent = 0;
for (unsigned int i = 0; i < NUM_PEERS; i++)
{
tc_hs[i] = GNUNET_TRANSPORT_TESTING_transport_communicator_service_start (
diff --git a/src/transport/transport-testing2.c b/src/transport/transport-testing2.c
index baafff249..1e2579048 100644
--- a/src/transport/transport-testing2.c
+++ b/src/transport/transport-testing2.c
@@ -557,6 +557,7 @@ handle_update_queue_message (void *cls,
// tc_queue->q_len += GNUNET_ntohll (msg->q_len);
// Uncomment this for alternativ 2 of backchannel functionality
tc_queue->q_len = GNUNET_ntohll (msg->q_len);
+ // Until here for alternativ 2
GNUNET_SERVICE_client_continue (client->client);
}