[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnunet] branch master updated: - added configuration to the tng communi
From: |
gnunet |
Subject: |
[gnunet] branch master updated: - added configuration to the tng communicator test code |
Date: |
Tue, 05 Jan 2021 21:26:39 +0100 |
This is an automated email from the git hooks/post-receive script.
t3sserakt pushed a commit to branch master
in repository gnunet.
The following commit(s) were added to refs/heads/master by this push:
new 6bf35601f - added configuration to the tng communicator test code
new 438aca2f6 Merge branch 'master' of ssh://gnunet.org/gnunet
6bf35601f is described below
commit 6bf35601f3eb93a7fcd3401b42be8d53f79c47d8
Author: t3sserakt <t3ss@posteo.de>
AuthorDate: Tue Jan 5 17:39:22 2021 +0100
- added configuration to the tng communicator test code
---
src/transport/test_communicator_basic.c | 415 +++++++++++++--------
.../test_communicator_tcp_basic_peer1.conf | 5 +
2 files changed, 274 insertions(+), 146 deletions(-)
diff --git a/src/transport/test_communicator_basic.c
b/src/transport/test_communicator_basic.c
index 1f85a9895..0250de474 100644
--- a/src/transport/test_communicator_basic.c
+++ b/src/transport/test_communicator_basic.c
@@ -81,10 +81,14 @@ static struct GNUNET_STATISTICS_GetHandle *box_stats;
static struct GNUNET_STATISTICS_GetHandle *rekey_stats;
+#define TEST_SECTION "test-setup"
+
#define SHORT_MESSAGE_SIZE 128
#define LONG_MESSAGE_SIZE 32000 /* FIXME */
+#define ALLOWED_PACKET_LOSS 91
+
#define BURST_PACKETS 5000
#define TOTAL_ITERATIONS 1
@@ -114,6 +118,27 @@ enum TestPhase
TP_SIZE_CHECK
};
+static unsigned int phase_short;
+
+static unsigned int phase_long;
+
+static unsigned int phase_size;
+
+static long long unsigned int allowed_packet_loss_short;
+
+static long long unsigned int allowed_packet_loss_long;
+
+static long long unsigned int burst_packets_short;
+
+static long long unsigned int burst_packets_long;
+
+static long long unsigned int delay_long_value;
+
+static long long unsigned int delay_short_value;
+
+static struct GNUNET_TIME_Relative delay_short;
+
+static struct GNUNET_TIME_Relative delay_long;
static size_t num_sent_short = 0;
@@ -300,10 +325,6 @@ latency_timeout (void *cls)
GNUNET_SCHEDULER_shutdown ();
}
-
-/*static void
- size_test (void *cls);*/
-
static void
size_test (void *cls)
{
@@ -350,7 +371,7 @@ long_test_cb (void *cls)
payload = make_payload (long_message_size);
num_sent_long++;
GNUNET_TRANSPORT_TESTING_transport_communicator_send (my_tc,
- (BURST_PACKETS ==
+ (burst_packets_long ==
num_sent_long)
? NULL
: &long_test,
@@ -368,10 +389,7 @@ long_test_cb (void *cls)
static void
long_test (void *cls)
{
- /*LOG (GNUNET_ERROR_TYPE_DEBUG,
- "long_test %u\n",
- num_sent_long);*/
- GNUNET_SCHEDULER_add_delayed (DELAY,
+ GNUNET_SCHEDULER_add_delayed (delay_long,
&long_test_cb,
NULL);
}
@@ -393,7 +411,7 @@ short_test_cb (void *cls)
payload = make_payload (SHORT_MESSAGE_SIZE);
num_sent_short++;
GNUNET_TRANSPORT_TESTING_transport_communicator_send (my_tc,
- (BURST_PACKETS ==
+ (burst_packets_short ==
num_sent_short)
? NULL
: &short_test,
@@ -410,40 +428,164 @@ short_test_cb (void *cls)
static void
short_test (void *cls)
{
- GNUNET_SCHEDULER_add_delayed (DELAY,
+ GNUNET_SCHEDULER_add_delayed (delay_short,
&short_test_cb,
NULL);
}
-static int test_prepared = GNUNET_NO;
+/* static int test_prepared = GNUNET_NO; */
+
+/* This helps establishing the backchannel */
+/* static void */
+/* prepare_test (void *cls) */
+/* { */
+/* char *payload; */
+
+/* if (GNUNET_YES == test_prepared) */
+/* { */
+/* GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, */
+/* &short_test, */
+/* NULL); */
+/* return; */
+/* } */
+/* test_prepared = GNUNET_YES; */
+/* payload = make_payload (SHORT_MESSAGE_SIZE); */
+/* GNUNET_TRANSPORT_TESTING_transport_communicator_send (my_tc, */
+/* &prepare_test, */
+/* NULL, */
+/* payload, */
+/*
SHORT_MESSAGE_SIZE); */
+/* GNUNET_free (payload); */
+/* } */
-/**
- * This helps establishing the backchannel
- */
static void
-prepare_test (void *cls)
+process_statistics_box_done (void *cls, int success)
{
- char *payload;
+ if (NULL != box_stats)
+ box_stats = NULL;
+ if (NULL == rekey_stats)
+ {
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Finished\n");
+ GNUNET_SCHEDULER_shutdown ();
+ }
+}
- if (GNUNET_YES == test_prepared)
+
+static void
+process_statistics_rekey_done (void *cls, int success)
+{
+ if (NULL != rekey_stats)
+ rekey_stats = NULL;
+ if (NULL == box_stats)
{
- GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
- &short_test,
- NULL);
- return;
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Finished\n");
+ GNUNET_SCHEDULER_shutdown ();
}
- test_prepared = GNUNET_YES;
- payload = make_payload (SHORT_MESSAGE_SIZE);
- GNUNET_TRANSPORT_TESTING_transport_communicator_send (my_tc,
- &prepare_test,
- NULL,
- payload,
- SHORT_MESSAGE_SIZE);
- GNUNET_free (payload);
}
+static int
+process_statistics (void *cls,
+ const char *subsystem,
+ const char *name,
+ uint64_t value,
+ int is_persistent)
+{
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Statistic: Name %s and value %lu\n",
+ name,
+ value);
+ if ((0 == strcmp ("rekey", test_name)) && (0 == strcmp (
+ "# rekeying successful",
+ name)) && (0 == value))
+ {
+ ret = 2;
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "No successful rekeying!\n");
+ GNUNET_SCHEDULER_shutdown ();
+ }
+ if ((0 == strcmp ("backchannel", test_name)) &&
+ (0 == strcmp (
+ "# messages decrypted with BOX",
+ name))
+ && (9000 > value))
+ {
+ ret = 2;
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Not enough BOX messages!\n");
+ GNUNET_SCHEDULER_shutdown ();
+ }
+ if ((0 == strcmp ("rekey", test_name)) &&
+ (0 == strcmp (
+ "# messages decrypted with BOX",
+ name))
+ && (6000 > value))
+ {
+ ret = 2;
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Not enough BOX messages!\n");
+ GNUNET_SCHEDULER_shutdown ();
+ }
+ return GNUNET_OK;
+}
+
+static void
+choose_phase ()
+{
+ if (GNUNET_YES == phase_short)
+ {
+ phase = TP_BURST_SHORT;
+ start_short = GNUNET_TIME_absolute_get ();
+ short_test (NULL);
+ }
+ else if (GNUNET_YES == phase_long)
+ {
+ phase = TP_BURST_LONG;
+ start_long = GNUNET_TIME_absolute_get ();
+ long_test (NULL);
+ }
+ else if (GNUNET_YES == phase_size)
+ {
+ phase = TP_SIZE_CHECK;
+ size_test (NULL);
+ }
+ else
+ {
+ if ((0 == strcmp ("udp", communicator_name)) && ((0 == strcmp ("rekey",
+ test_name))
+ ||(0 == strcmp (
+ "backchannel",
+ test_name))) )
+ {
+ if (NULL != box_stats)
+ GNUNET_STATISTICS_get_cancel (box_stats);
+ box_stats = GNUNET_STATISTICS_get (stats[1],
+ "C-UDP",
+ "# messages decrypted with BOX",
+ process_statistics_box_done,
+ &process_statistics,
+ NULL);
+ if (NULL != rekey_stats)
+ GNUNET_STATISTICS_get_cancel (rekey_stats);
+ rekey_stats = GNUNET_STATISTICS_get (stats[0],
+ "C-UDP",
+ "# rekeying successful",
+ process_statistics_rekey_done,
+ &process_statistics,
+ NULL);
+ }
+ else
+ {
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Finished\n");
+ GNUNET_SCHEDULER_shutdown ();
+ }
+ }
+}
+
/**
* @brief Handle opening of queue
*
@@ -468,14 +610,14 @@ add_queue_cb (void *cls,
return; // TODO?
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Queue established, starting test...\n");
- start_short = GNUNET_TIME_absolute_get ();
+ // start_short = GNUNET_TIME_absolute_get ();
my_tc = tc_h;
if (0 != mtu) /* Message header overhead */
long_message_size = mtu - sizeof(struct GNUNET_TRANSPORT_SendMessageTo)
- sizeof(struct GNUNET_MessageHeader);
else
long_message_size = LONG_MESSAGE_SIZE;
- phase = TP_BURST_SHORT;
+ // phase = TP_BURST_SHORT;
timeout = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_relative_multiply (
GNUNET_TIME_UNIT_SECONDS,
TIMEOUT_MULTIPLIER));
@@ -486,7 +628,8 @@ add_queue_cb (void *cls,
&latency_timeout,
NULL);
// prepare_test (NULL);
- short_test (NULL);
+ // short_test (NULL);
+ choose_phase ();
}
@@ -501,10 +644,7 @@ update_avg_latency (const char*payload)
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: %s\n",
- GNUNET_STRINGS_relative_time_to_string (latency,
- GNUNET_YES));
+
switch (phase)
{
case TP_INIT:
@@ -525,83 +665,40 @@ update_avg_latency (const char*payload)
else
avg_latency = ((avg_latency * (num_received - 1)) + latency.rel_value_us)
/ num_received;
-
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Latency of received packet: %s with avg latency %lu\n",
+ GNUNET_STRINGS_relative_time_to_string (latency,
+ GNUNET_YES),
+ avg_latency);
}
-static void
-process_statistics_box_done (void *cls, int success)
-{
- if (NULL != box_stats)
- box_stats = NULL;
- if (NULL == rekey_stats)
- {
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Finished\n");
- GNUNET_SCHEDULER_shutdown ();
- }
-}
static void
-process_statistics_rekey_done (void *cls, int success)
+load_phase_config ()
{
- if (NULL != rekey_stats)
- rekey_stats = NULL;
- if (NULL == box_stats)
- {
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Finished\n");
- GNUNET_SCHEDULER_shutdown ();
- }
-}
+ phase_short = GNUNET_CONFIGURATION_get_value_yesno (cfg_peers[0],
+ TEST_SECTION,
+ "PHASE_SHORT");
+ if (GNUNET_SYSERR == phase_short)
+ phase_short = GNUNET_YES;
-static int
-process_statistics (void *cls,
- const char *subsystem,
- const char *name,
- uint64_t value,
- int is_persistent)
-{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Statistic: Name %s and value %lu\n",
- name,
- value);
- if ((0 == strcmp ("rekey", test_name)) && (0 == strcmp (
- "# rekeying successful",
- name)) && (0 == value))
- {
- ret = 2;
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "No successful rekeying!\n");
- GNUNET_SCHEDULER_shutdown ();
- }
- if ((0 == strcmp ("backchannel", test_name)) &&
- (0 == strcmp (
- "# messages decrypted with BOX",
- name))
- && (9000 > value))
- {
- ret = 2;
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Not enough BOX messages!\n");
- GNUNET_SCHEDULER_shutdown ();
- }
- if ((0 == strcmp ("rekey", test_name)) &&
- (0 == strcmp (
- "# messages decrypted with BOX",
- name))
- && (6000 > value))
- {
- ret = 2;
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Not enough BOX messages!\n");
- GNUNET_SCHEDULER_shutdown ();
- }
- return GNUNET_OK;
-}
+ phase_long = GNUNET_CONFIGURATION_get_value_yesno (cfg_peers[0],
+ TEST_SECTION,
+ "PHASE_LONG");
+ if (GNUNET_SYSERR == phase_long)
+ phase_long = GNUNET_YES;
+
+ phase_size = GNUNET_CONFIGURATION_get_value_yesno (cfg_peers[0],
+ TEST_SECTION,
+ "PHASE_SIZE");
+
+ if (GNUNET_SYSERR == phase_size)
+ phase_size = GNUNET_YES;
+}
/**
* @brief Handle an incoming message
@@ -641,8 +738,10 @@ incoming_message_cb (
num_received_short++;
duration = GNUNET_TIME_absolute_get_duration (start_short);
update_avg_latency (payload);
- if ((num_sent_short == BURST_PACKETS) && (num_received_short >
- BURST_PACKETS * 0.91) )
+ if ((num_sent_short == burst_packets_short) && (num_received_short >
+ burst_packets_short / 100
+ *
+
allowed_packet_loss_short) )
{
LOG (GNUNET_ERROR_TYPE_MESSAGE,
"Short size packet test done.\n");
@@ -657,12 +756,14 @@ incoming_message_cb (
goodput,
(unsigned long long) avg_latency);
GNUNET_free (goodput);
- start_long = GNUNET_TIME_absolute_get ();
- phase = TP_BURST_LONG;
+ // start_long = GNUNET_TIME_absolute_get ();
+ // phase = TP_BURST_LONG;
// num_sent_short = 0;
avg_latency = 0;
// num_received = 0;
- long_test (NULL);
+ phase_short = GNUNET_NO;
+ choose_phase ();
+ // long_test (NULL);
}
break;
}
@@ -677,8 +778,10 @@ incoming_message_cb (
num_received_long++;
duration = GNUNET_TIME_absolute_get_duration (start_long);
update_avg_latency (payload);
- if ((num_sent_long == BURST_PACKETS) && (num_received_long >
BURST_PACKETS
- * 0.91) )
+ if ((num_sent_long == burst_packets_long) && (num_received_long >
+ burst_packets_long
+ / 100
+ *
allowed_packet_loss_short) )
{
LOG (GNUNET_ERROR_TYPE_MESSAGE,
"Long size packet test done.\n");
@@ -696,11 +799,13 @@ incoming_message_cb (
(unsigned long long) avg_latency);
GNUNET_free (goodput);
ack = 0;
- phase = TP_SIZE_CHECK;
+ // phase = TP_SIZE_CHECK;
// num_received = 0;
// num_sent_long = 0;
avg_latency = 0;
- size_test (NULL);
+ // size_test (NULL);
+ phase_long = GNUNET_NO;
+ choose_phase ();
}
break;
}
@@ -728,44 +833,19 @@ incoming_message_cb (
iterations_left--;
if (0 != iterations_left)
{
- start_short = GNUNET_TIME_absolute_get ();
- phase = TP_BURST_SHORT;
+ // 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);
+ // short_test (NULL);
+ load_phase_config ();
+ choose_phase ();
break;
}
- if ((0 == strcmp ("udp", communicator_name)) && ((0 == strcmp ("rekey",
-
test_name))
- ||(0 == strcmp (
- "backchannel",
- test_name))) )
- {
- if (NULL != box_stats)
- GNUNET_STATISTICS_get_cancel (box_stats);
- box_stats = GNUNET_STATISTICS_get (stats[1],
- "C-UDP",
- "# messages decrypted with BOX",
- process_statistics_box_done,
- &process_statistics,
- NULL);
- if (NULL != rekey_stats)
- GNUNET_STATISTICS_get_cancel (rekey_stats);
- rekey_stats = GNUNET_STATISTICS_get (stats[0],
- "C-UDP",
- "# rekeying successful",
- process_statistics_rekey_done,
- &process_statistics,
- NULL);
- }
- else
- {
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Finished\n");
- GNUNET_SCHEDULER_shutdown ();
- }
+ phase_size = GNUNET_NO;
+ choose_phase ();
}
break;
}
@@ -802,6 +882,7 @@ do_shutdown (void *cls)
}
+
/**
* @brief Main function called by the scheduler
*
@@ -846,7 +927,6 @@ run (void *cls)
NULL);
}
-
int
main (int argc,
char *const *argv)
@@ -924,6 +1004,49 @@ main (int argc,
i,
GNUNET_i2s_full (&peer_id[i]));
}
+ if (GNUNET_OK !=
+ GNUNET_CONFIGURATION_get_value_number (cfg_peers[0],
+ TEST_SECTION,
+ "ALLOWED_PACKET_LOSS_SHORT",
+ &allowed_packet_loss_short))
+ allowed_packet_loss_short = ALLOWED_PACKET_LOSS;
+ if (GNUNET_OK !=
+ GNUNET_CONFIGURATION_get_value_number (cfg_peers[0],
+ TEST_SECTION,
+ "ALLOWED_PACKET_LOSS_LONG",
+ &allowed_packet_loss_long))
+ allowed_packet_loss_long = ALLOWED_PACKET_LOSS;
+ if (GNUNET_OK !=
+ GNUNET_CONFIGURATION_get_value_number (cfg_peers[0],
+ TEST_SECTION,
+ "BURST_PACKETS_SHORT",
+ &burst_packets_short))
+ burst_packets_short = BURST_PACKETS;
+ if (GNUNET_OK !=
+ GNUNET_CONFIGURATION_get_value_number (cfg_peers[0],
+ TEST_SECTION,
+ "BURST_ÜACKETS_LONG",
+ &burst_packets_long))
+ burst_packets_long = BURST_PACKETS;
+ if (GNUNET_OK !=
+ GNUNET_CONFIGURATION_get_value_number (cfg_peers[0],
+ TEST_SECTION,
+ "DELAY_SHORT",
+ &delay_short_value))
+ delay_short = DELAY;
+ else
+ GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MICROSECONDS,
+ delay_short_value);
+ if (GNUNET_OK !=
+ GNUNET_CONFIGURATION_get_value_number (cfg_peers[0],
+ TEST_SECTION,
+ "DELAY_SHORT",
+ &delay_long_value))
+ delay_long = DELAY;
+ else
+ GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MICROSECONDS,
+ delay_long_value);
+ load_phase_config ();
LOG (GNUNET_ERROR_TYPE_MESSAGE, "Starting test...\n");
LOG (GNUNET_ERROR_TYPE_DEBUG,
"argv[0]: %s\n",
diff --git a/src/transport/test_communicator_tcp_basic_peer1.conf
b/src/transport/test_communicator_tcp_basic_peer1.conf
index b32aa1c17..dbc227ac6 100644
--- a/src/transport/test_communicator_tcp_basic_peer1.conf
+++ b/src/transport/test_communicator_tcp_basic_peer1.conf
@@ -1,5 +1,10 @@
@INLINE@ test_transport_defaults.conf
+[test-setup]
+#PHASE_LONG=NO
+#PHASE_SIZE=NO
+#BURST_PACKETS_SHORT=1
+
[PATHS]
GNUNET_TEST_HOME = $GNUNET_TMP/test-communicator-unix-1/
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnunet] branch master updated: - added configuration to the tng communicator test code,
gnunet <=