summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authort3sserakt <t3ss@posteo.de>2020-10-09 18:14:23 +0200
committert3sserakt <t3ss@posteo.de>2020-10-09 18:14:23 +0200
commit03199f7f246e1d636c9feb921d66be48c907130f (patch)
tree11c7eeb26ad4038bfa0aaa1b9e8caa4064312093 /src
parentc25c3fd24b691d35674b1e67cbcf1066c427c7d3 (diff)
- new udp backchannel logic. Two alternatives. Test not working.
Diffstat (limited to 'src')
-rw-r--r--src/transport/gnunet-communicator-udp.c247
-rw-r--r--src/transport/test_communicator_basic.c189
-rw-r--r--src/transport/transport-testing2.c10
3 files changed, 212 insertions, 234 deletions
diff --git a/src/transport/gnunet-communicator-udp.c b/src/transport/gnunet-communicator-udp.c
index 579f744e5..1df79745a 100644
--- a/src/transport/gnunet-communicator-udp.c
+++ b/src/transport/gnunet-communicator-udp.c
@@ -93,7 +93,7 @@
*/
#define GCM_TAG_SIZE (128 / 8)
-#define GENERATE_AT_ONCE 20
+#define GENERATE_AT_ONCE 2
/**
* If we fall below this number of available KCNs,
@@ -256,6 +256,12 @@ struct UDPAck
uint32_t sequence_max GNUNET_PACKED;
/**
+ * Sequence acknowledgement limit. Specifies current maximum sequence
+ * number supported by receiver.
+ */
+ uint32_t acks_available GNUNET_PACKED;
+
+ /**
* CMAC of the base key being acknowledged.
*/
struct GNUNET_HashCode cmac;
@@ -664,6 +670,10 @@ struct BroadcastInterface
int found;
};
+/**
+ * Shared secret we finished the last kce working queue for.
+ */
+struct SharedSecret *ss_finished;
/**
* Cache of pre-generated key IDs.
@@ -681,6 +691,16 @@ static struct GNUNET_SCHEDULER_Task *read_task;
static struct GNUNET_SCHEDULER_Task *timeout_task;
/**
+ * ID of kce working queue task
+ */
+static struct GNUNET_SCHEDULER_Task *kce_task;
+
+/**
+ * Is the kce_task finished?
+ */
+static int kce_task_finished = GNUNET_NO;
+
+/**
* ID of master broadcast task
*/
static struct GNUNET_SCHEDULER_Task *broadcast_task;
@@ -807,15 +827,26 @@ bi_destroy (struct BroadcastInterface *bi)
static void
receiver_destroy (struct ReceiverAddress *receiver)
{
+ struct GNUNET_MQ_Handle *mq;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Disconnecting receiver for peer `%s'\n",
GNUNET_i2s (&receiver->target));
+ if (NULL != (mq = receiver->kx_mq))
+ {
+ receiver->kx_mq = NULL;
+ GNUNET_MQ_destroy (mq);
+ }
if (NULL != receiver->kx_qh)
{
GNUNET_TRANSPORT_communicator_mq_del (receiver->kx_qh);
receiver->kx_qh = NULL;
}
+ if (NULL != (mq = receiver->d_mq))
+ {
+ receiver->d_mq = NULL;
+ GNUNET_MQ_destroy (mq);
+ }
if (NULL != receiver->d_qh)
{
GNUNET_TRANSPORT_communicator_mq_del (receiver->d_qh);
@@ -932,19 +963,13 @@ secret_destroy (struct SharedSecret *ss)
{
GNUNET_CONTAINER_DLL_remove (sender->ss_head, sender->ss_tail, ss);
sender->num_secrets--;
- sender->acks_available -= ss->active_kce_count;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "%u acks available after secrect destroy.\n",
- sender->acks_available);
}
if (NULL != (receiver = ss->receiver))
{
GNUNET_CONTAINER_DLL_remove (receiver->ss_head, receiver->ss_tail, ss);
receiver->num_secrets--;
- receiver->acks_available -= (ss->sequence_allowed - ss->sequence_used);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "%u acks available after secrect destroy.\n",
- receiver->acks_available);
+ // Uncomment this for alternativ 1 of backchannel functionality
+ // receiver->acks_available -= (ss->sequence_allowed - ss->sequence_used);
}
while (NULL != (kce = ss->kce_head))
kce_destroy (kce);
@@ -1259,10 +1284,6 @@ setup_shared_secret_enc (const struct GNUNET_CRYPTO_EcdhePrivateKey *ephemeral,
&receiver->target.public_key,
&ss->master);
calculate_cmac (ss);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Created cmac %s for secret %p.\n",
- GNUNET_h2s (&ss->cmac),
- ss);
ss->receiver = receiver;
GNUNET_CONTAINER_DLL_insert (receiver->ss_head, receiver->ss_tail, ss);
receiver->num_secrets++;
@@ -1311,27 +1332,41 @@ handle_ack (void *cls, const struct GNUNET_PeerIdentity *pid, void *value)
allowed = ntohl (ack->sequence_max);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "%u > %u (%u)\n", allowed, ss->sequence_allowed,
- receiver->acks_available);
if (allowed > ss->sequence_allowed)
{
- receiver->acks_available += (allowed - ss->sequence_allowed);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "%u > %u (%u %u) for secrect %s\n", allowed,
+ ss->sequence_allowed,
+ receiver->acks_available,
+ ack->acks_available,
+ GNUNET_h2s (&ss->master));
+ // Uncomment this for alternativ 1 of backchannel functionality
+ /*receiver->acks_available += (allowed - ss->sequence_allowed);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Tell transport we have more acks!\n");
GNUNET_TRANSPORT_communicator_mq_update (ch,
receiver->d_qh,
(allowed
- ss->sequence_allowed),
- 1);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "%u acks made available.\n",
- receiver->acks_available);
+ 1);*/
ss->sequence_allowed = allowed;
/* move ss to head to avoid discarding it anytime soon! */
GNUNET_CONTAINER_DLL_remove (receiver->ss_head, receiver->ss_tail, ss);
GNUNET_CONTAINER_DLL_insert (receiver->ss_head, receiver->ss_tail, ss);
}
+
+ // Uncomment this for alternativ 2 of backchannel functionality
+ if (receiver->acks_available != ack->acks_available)
+ {
+ receiver->acks_available = ack->acks_available;
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Tell transport we have different number of acks!\n");
+ GNUNET_TRANSPORT_communicator_mq_update (ch,
+ receiver->d_qh,
+ receiver->acks_available,
+ 1);
+ }
+ // Until here for alternativ 2
return GNUNET_NO;
}
}
@@ -1390,12 +1425,29 @@ kce_generate_cb (void *cls)
{
struct SharedSecret *ss = cls;
- for (int i = 0; i < GENERATE_AT_ONCE; i++)
- kce_generate (ss, ++ss->sequence_allowed);
- /*GNUNET_SCHEDULER_add_delayed (WORKING_QUEUE_INTERVALL,
- kce_generate_cb,
- ss);*/
+
+ if (ss->sender->acks_available < KCN_TARGET)
+ {
+
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Precomputing keys\n");
+
+ for (int i = 0; i < GENERATE_AT_ONCE; i++)
+ kce_generate (ss, ++ss->sequence_allowed);
+
+ kce_task = GNUNET_SCHEDULER_add_delayed (WORKING_QUEUE_INTERVALL,
+ kce_generate_cb,
+ ss);
+ }
+ else
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "We have enough keys.\n");
+ ss_finished = ss;
+ kce_task_finished = GNUNET_YES;
+ }
+
}
@@ -1406,26 +1458,69 @@ kce_generate_cb (void *cls)
* recently).
*
* @param ss shared secret to generate ACKs for
+ * @param intial The SharedSecret came with initial KX.
*/
static void
-consider_ss_ack (struct SharedSecret *ss)
+consider_ss_ack (struct SharedSecret *ss, int initial)
{
GNUNET_assert (NULL != ss->sender);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Considering SS UDPAck %s\n",
GNUNET_i2s_full (&ss->sender->target));
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "We have %u acks available.\n",
+ ss->sender->acks_available);
/* drop ancient KeyCacheEntries */
while ((NULL != ss->kce_head) &&
(MAX_SQN_DELTA <
ss->kce_head->sequence_number - ss->kce_tail->sequence_number))
kce_destroy (ss->kce_tail);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "%u active count and %u acks available\n",
- ss->active_kce_count,
- ss->sender->acks_available);
- if ((ss->active_kce_count < KCN_THRESHOLD) && (ss->sender->acks_available <
- KCN_TARGET) )
+
+
+ if (GNUNET_NO == initial)
+ kce_generate (ss, ++ss->sequence_allowed);
+
+ /*if (0 == ss->sender->acks_available)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Generating keys\n");
+ while (ss->active_kce_count < KCN_TARGET)
+ kce_generate (ss, ++ss->sequence_allowed);
+ }*/
+
+ if (((NULL != kce_task) && kce_task_finished) || (GNUNET_NO == initial))
+ {
+ struct UDPAck ack;
+
+ ack.header.type = htons (GNUNET_MESSAGE_TYPE_COMMUNICATOR_UDP_ACK);
+ ack.header.size = htons (sizeof(ack));
+ ack.sequence_max = htonl (ss_finished->sequence_allowed);
+ ack.acks_available = ss->sender->acks_available;
+ ack.cmac = ss_finished->cmac;
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Notifying transport of UDPAck %s with intial %u\n",
+ GNUNET_i2s_full (&ss_finished->sender->target),
+ initial);
+ GNUNET_TRANSPORT_communicator_notify (ch,
+ &ss_finished->sender->target,
+ COMMUNICATOR_ADDRESS_PREFIX,
+ &ack.header);
+ kce_task = NULL;
+ }
+ else if ((NULL == kce_task) && (KCN_THRESHOLD > ss->sender->acks_available))
+ {
+
+ // kce_generate (ss, ++ss->sequence_allowed);
+ // kce_generate (ss, ++ss->sequence_allowed);
+ kce_task = GNUNET_SCHEDULER_add_delayed (WORKING_QUEUE_INTERVALL,
+ kce_generate_cb,
+ ss);
+
+ }
+
+
+ /*if (ss->active_kce_count < KCN_THRESHOLD)
{
struct UDPAck ack;
@@ -1435,20 +1530,18 @@ consider_ss_ack (struct SharedSecret *ss)
* For the initial KX (active_kce_count==0),
* we only generate a single KCE to prevent
* unnecessary overhead.
- */
- GNUNET_SCHEDULER_add_now (kce_generate_cb, ss);
- /*if (0 < ss->sequence_allowed)
+
+ if (0 < ss->active_kce_count)
{
while (ss->active_kce_count < KCN_TARGET)
kce_generate (ss, ++ss->sequence_allowed);
}
- else {*/
- /*kce_generate (ss, ++ss->sequence_allowed);
- kce_generate (ss, ++ss->sequence_allowed);*/
- // }
+ else {
+ kce_generate (ss, ++ss->sequence_allowed);
+ }
ack.header.type = htons (GNUNET_MESSAGE_TYPE_COMMUNICATOR_UDP_ACK);
ack.header.size = htons (sizeof(ack));
- ack.sequence_max = htonl (ss->sequence_allowed + GENERATE_AT_ONCE);
+ ack.sequence_max = htonl (ss->sequence_allowed);
ack.cmac = ss->cmac;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Notifying transport of UDPAck %s\n",
@@ -1457,7 +1550,7 @@ consider_ss_ack (struct SharedSecret *ss)
&ss->sender->target,
COMMUNICATOR_ADDRESS_PREFIX,
&ack.header);
- }
+ }*/
}
@@ -1489,10 +1582,6 @@ decrypt_box (const struct UDPBox *box,
1,
GNUNET_NO);
kce_destroy (kce);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "decrypting of UDPBox with kid %s and cmac %s failed\n",
- GNUNET_sh2s (&box->kid),
- GNUNET_h2s (&ss->cmac));
return;
}
kce_destroy (kce);
@@ -1504,7 +1593,7 @@ decrypt_box (const struct UDPBox *box,
"decrypted UDPBox with kid %s\n",
GNUNET_sh2s (&box->kid));
try_handle_plaintext (ss->sender, out_buf, sizeof(out_buf));
- consider_ss_ack (ss);
+ consider_ss_ack (ss, GNUNET_NO);
}
@@ -1561,7 +1650,7 @@ find_sender_by_address (void *cls,
* might already have one, so a fresh one is only allocated
* if one does not yet exist for @a address.
*
- * @param target peer to generate address for (can be NULL, if we already have one).
+ * @param target peer to generate address for
* @param address target address
* @param address_len number of bytes in @a address
* @return data structure to keep track of key material for
@@ -1581,7 +1670,7 @@ setup_sender (const struct GNUNET_PeerIdentity *target,
target,
&find_sender_by_address,
&sc);
- if ((NULL != sc.sender)||(NULL == target))
+ if (NULL != sc.sender)
{
reschedule_sender_timeout (sc.sender);
return sc.sender;
@@ -1704,8 +1793,7 @@ sock_read (void *cls)
return;
}
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Read %lu bytes.\n",
- rcvd);
+ "Read %lu bytes\n", rcvd);
/* first, see if it is a UDPBox */
if (rcvd > sizeof(struct UDPBox))
{
@@ -1719,9 +1807,6 @@ sock_read (void *cls)
decrypt_box (box, (size_t) rcvd, kce);
return;
}
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "No kid %s.\n",
- GNUNET_sh2s (&box->kid));
}
/* next, check if it is a broadcast */
@@ -1779,8 +1864,7 @@ sock_read (void *cls)
kx = (const struct InitialKX *) buf;
ss = setup_shared_secret_dec (&kx->ephemeral);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Before DEC with ephemeral %s\n",
- GNUNET_e2s (&kx->ephemeral));
+ "Before DEC\n");
if (GNUNET_OK != try_decrypt (ss,
kx->gcm_tag,
@@ -1817,10 +1901,6 @@ sock_read (void *cls)
"Before SETUP_SENDER\n");
calculate_cmac (ss);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Got cmac %s for secret %p.\n",
- GNUNET_h2s (&ss->cmac),
- ss);
sender = setup_sender (&uc->sender, (const struct sockaddr *) &sa, salen);
ss->sender = sender;
GNUNET_CONTAINER_DLL_insert (sender->ss_head, sender->ss_tail, ss);
@@ -1831,12 +1911,9 @@ sock_read (void *cls)
1,
GNUNET_NO);
try_handle_plaintext (sender, &uc[1], sizeof(pbuf) - sizeof(*uc));
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "We have %u secrets\n",
- sender->num_secrets);
+ consider_ss_ack (ss, GNUNET_YES);
/*if (sender->num_secrets > MAX_SECRETS)
secret_destroy (sender->ss_tail);*/
- consider_ss_ack (ss);
}
}
@@ -2038,8 +2115,6 @@ mq_send_kx (struct GNUNET_MQ_Handle *mq,
GNUNET_CRYPTO_ecdhe_key_create (&epriv);
ss = setup_shared_secret_enc (&epriv, receiver);
- /*if (receiver->num_secrets > MAX_SECRETS)
- secret_destroy (receiver->ss_tail);*/
setup_cipher (&ss->master, 0, &out_cipher);
/* compute 'uc' */
uc.sender = my_identity;
@@ -2081,10 +2156,8 @@ mq_send_kx (struct GNUNET_MQ_Handle *mq,
receiver->address_len))
GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "send");
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Sending KX to %s with ephemeral %s\n",
- GNUNET_a2s (receiver->address,
- receiver->address_len),
- GNUNET_e2s (&kx.ephemeral));
+ "Sending KX to %s\n", GNUNET_a2s (receiver->address,
+ receiver->address_len));
GNUNET_MQ_impl_send_continue (mq);
}
@@ -2105,11 +2178,6 @@ mq_send_d (struct GNUNET_MQ_Handle *mq,
struct ReceiverAddress *receiver = impl_state;
uint16_t msize = ntohs (msg->size);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "sending to receiver %s with %u acks available.\n",
- receiver->foreign_addr,
- receiver->acks_available);
-
GNUNET_assert (mq == receiver->d_mq);
if ((msize > receiver->d_mtu) ||
(0 == receiver->acks_available))
@@ -2123,7 +2191,16 @@ mq_send_d (struct GNUNET_MQ_Handle *mq,
/* begin "BOX" encryption method, scan for ACKs from tail! */
for (struct SharedSecret *ss = receiver->ss_tail; NULL != ss; ss = ss->prev)
{
- if (ss->sequence_used >= ss->sequence_allowed)
+ if (0 < ss->sequence_used)
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Trying to send UDPBox with shared secrect %s sequence_used %u and ss->sequence_allowed %u\n",
+ GNUNET_h2s (&ss->master),
+ ss->sequence_used,
+ ss->sequence_allowed);
+ // Uncomment this for alternativ 1 of backchannel functionality
+ // if (ss->sequence_used >= ss->sequence_allowed)
+ // Uncomment this for alternativ 2 of backchannel functionality
+ if (0 == ss->sequence_allowed)
{
continue;
}
@@ -2134,10 +2211,6 @@ mq_send_d (struct GNUNET_MQ_Handle *mq,
box = (struct UDPBox *) dgram;
ss->sequence_used++;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "get kid with sequence number %u and cmac %s.\n",
- ss->sequence_used,
- GNUNET_h2s (&ss->cmac));
get_kid (&ss->master, ss->sequence_used, &box->kid);
setup_cipher (&ss->master, ss->sequence_used, &out_cipher);
/* Append encrypted payload to dgram */
@@ -2157,18 +2230,10 @@ mq_send_d (struct GNUNET_MQ_Handle *mq,
receiver->address_len))
GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "send");
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Sending UDPBox to %s with shared secrect %p and kid %s\n",
- GNUNET_a2s (
- receiver->address,
- receiver
- ->address_len),
- ss,
- GNUNET_sh2s (&box->kid));
+ "Sending UDPBox to %s\n", GNUNET_a2s (receiver->address,
+ receiver->address_len));
GNUNET_MQ_impl_send_continue (mq);
- receiver->acks_available--;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "%u acks available after sending.\n",
- receiver->acks_available);
+ // receiver->acks_available--;
if (0 == receiver->acks_available)
{
/* We have no more ACKs */
diff --git a/src/transport/test_communicator_basic.c b/src/transport/test_communicator_basic.c
index 2d550dc16..43c98a401 100644
--- a/src/transport/test_communicator_basic.c
+++ b/src/transport/test_communicator_basic.c
@@ -68,6 +68,8 @@ 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 */
@@ -82,9 +84,6 @@ static struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *my_tc;
static unsigned int iterations_left = TOTAL_ITERATIONS;
-#define DELAY \
- GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MICROSECONDS,1000)
-
#define SHORT_BURST_WINDOW \
GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS,2)
@@ -100,21 +99,13 @@ enum TestPhase
};
-static size_t num_sent_short = 0;
-
-static size_t num_sent_long = 0;
-
-static size_t num_sent_size = 0;
+static size_t num_sent = 0;
static uint32_t ack = 0;
static enum TestPhase phase;
-static size_t num_received_short = 0;
-
-static size_t num_received_long = 0;
-
-static size_t num_received_size = 0;
+static size_t num_received = 0;
static uint64_t avg_latency = 0;
@@ -241,34 +232,17 @@ 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);
@@ -276,8 +250,6 @@ latency_timeout (void *cls)
GNUNET_SCHEDULER_shutdown ();
}
-/*static void
- size_test (void *cls);*/
static void
size_test (void *cls)
@@ -285,9 +257,6 @@ 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;
@@ -295,7 +264,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_size++;
+ num_sent++;
GNUNET_TRANSPORT_TESTING_transport_communicator_send (my_tc,
(ack < max_size)
? &size_test
@@ -307,34 +276,17 @@ size_test (void *cls)
timeout = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_SECONDS);
}
-/*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_cb (void *cls)
+long_test (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_long++;
+ num_sent++;
GNUNET_TRANSPORT_TESTING_transport_communicator_send (my_tc,
- ((BURST_PACKETS
- * 0.91 ==
- num_received_long) ||
- (BURST_PACKETS ==
- num_sent_long))
+ (BURST_PACKETS ==
+ num_sent)
? NULL
: &long_test,
NULL,
@@ -344,37 +296,17 @@ long_test_cb (void *cls)
timeout = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_SECONDS);
}
-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);
-
-static void
-short_test_cb (void *cls)
+short_test (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_short++;
+ num_sent++;
GNUNET_TRANSPORT_TESTING_transport_communicator_send (my_tc,
- ((BURST_PACKETS
- * 0.91 ==
- num_received_short) ||
- (BURST_PACKETS ==
- num_sent_short))
+ (BURST_PACKETS ==
+ num_sent)
? NULL
: &short_test,
NULL,
@@ -384,14 +316,6 @@ short_test_cb (void *cls)
timeout = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_SECONDS);
}
-static void
-short_test (void *cls)
-{
- GNUNET_SCHEDULER_add_delayed (DELAY,
- &short_test_cb,
- NULL);
-}
-
static int test_prepared = GNUNET_NO;
@@ -453,12 +377,15 @@ add_queue_cb (void *cls,
else
long_message_size = LONG_MESSAGE_SIZE;
phase = TP_BURST_SHORT;
- timeout = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_MINUTES);
+ timeout = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_relative_multiply (
+ GNUNET_TIME_UNIT_SECONDS, 2));
GNUNET_assert (NULL == to_task);
- to_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES,
+ to_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (
+ GNUNET_TIME_UNIT_SECONDS, 2),
&latency_timeout,
NULL);
- prepare_test (NULL);
+ // prepare_test (NULL);
+ short_test (NULL);
}
@@ -468,23 +395,10 @@ 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);
- 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
@@ -493,6 +407,7 @@ update_avg_latency (const char*payload)
}
+
/**
* @brief Handle an incoming message
*
@@ -504,8 +419,7 @@ 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)
@@ -516,6 +430,8 @@ 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);
switch (phase)
@@ -526,31 +442,30 @@ incoming_message_cb (void *cls,
case TP_BURST_SHORT:
{
GNUNET_assert (SHORT_MESSAGE_SIZE == payload_len);
- num_received_short++;
+ num_received++;
duration = GNUNET_TIME_absolute_get_duration (start_short);
update_avg_latency (payload);
- if (num_received_short == BURST_PACKETS * 0.91)
+ if (num_received == BURST_PACKETS * DROP_RATIO)
{
LOG (GNUNET_ERROR_TYPE_MESSAGE,
"Short size packet test done.\n");
char *goodput = GNUNET_STRINGS_byte_size_fancy ((SHORT_MESSAGE_SIZE
- * num_received_short
- * 1000
+ * num_received * 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_short,
- (unsigned long) num_sent_short,
+ (unsigned long) num_received,
+ (unsigned long) num_sent,
(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_short = 0;
+ num_sent = 0;
avg_latency = 0;
- // num_received = 0;
+ num_received = 0;
long_test (NULL);
}
break;
@@ -561,34 +476,32 @@ incoming_message_cb (void *cls,
{
LOG (GNUNET_ERROR_TYPE_WARNING,
"Ignoring packet with wrong length\n");
- return; // Ignore
+ return; // Ignore
}
- num_received_long++;
+ num_received++;
duration = GNUNET_TIME_absolute_get_duration (start_long);
update_avg_latency (payload);
- if (num_received_long == BURST_PACKETS * 0.91)
+ if (num_received == BURST_PACKETS * DROP_RATIO)
{
LOG (GNUNET_ERROR_TYPE_MESSAGE,
"Long size packet test done.\n");
char *goodput = GNUNET_STRINGS_byte_size_fancy ((long_message_size
- * num_received_long
- * 1000
+ * num_received * 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_long,
- (unsigned long) num_sent_long,
+ (unsigned long) num_received,
+ (unsigned long) num_sent,
(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_long = 0;
+ num_received = 0;
+ num_sent = 0;
avg_latency = 0;
size_test (NULL);
}
@@ -601,29 +514,25 @@ 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_size++;
+ num_received++;
update_avg_latency (payload);
- if (num_received_size >= (max_size) / 10)
+ if (num_received >= (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_size,
- (unsigned long) num_sent_size,
+ (unsigned long) num_received,
+ (unsigned long) num_sent,
(unsigned long long) avg_latency);
- num_received_size = 0;
- num_sent_size = 0;
+ num_received = 0;
+ num_sent = 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;
}
@@ -661,8 +570,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 98cfd5e29..baafff249 100644
--- a/src/transport/transport-testing2.c
+++ b/src/transport/transport-testing2.c
@@ -553,7 +553,10 @@ handle_update_queue_message (void *cls,
tc_queue->mtu = ntohl (msg->mtu);
tc_queue->cs = msg->cs;
tc_queue->priority = ntohl (msg->priority);
- tc_queue->q_len += GNUNET_ntohll (msg->q_len);
+ // Uncomment this for alternativ 1 of backchannel functionality
+ // 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);
GNUNET_SERVICE_client_continue (client->client);
}
@@ -1130,8 +1133,9 @@ GNUNET_TRANSPORT_TESTING_transport_communicator_send
}
}
GNUNET_assert (NULL != tc_queue);
- if (tc_queue->q_len != GNUNET_TRANSPORT_QUEUE_LENGTH_UNLIMITED)
- tc_queue->q_len--;
+ // Uncomment this for alternativ 1 of backchannel functionality
+ /*if (tc_queue->q_len != GNUNET_TRANSPORT_QUEUE_LENGTH_UNLIMITED)
+ tc_queue->q_len--;*/
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Sending message\n");
inbox_size = sizeof (struct GNUNET_MessageHeader) + payload_size;