From 448a5370373e9dcef449c53aee6c078c7d3395d9 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Tue, 31 Jan 2017 17:54:48 +0100 Subject: [PATCH] use observed RTT as starting point for retransmissions --- src/cadet/TODO | 1 - src/cadet/gnunet-service-cadet-new_channel.c | 22 +++++++++--------- .../gnunet-service-cadet-new_connection.c | 23 ++++++++++++++----- .../gnunet-service-cadet-new_connection.h | 10 ++++++++ src/cadet/gnunet-service-cadet-new_core.c | 21 ++++++----------- 5 files changed, 45 insertions(+), 32 deletions(-) diff --git a/src/cadet/TODO b/src/cadet/TODO index f2aed163d..03bf6eae1 100644 --- a/src/cadet/TODO +++ b/src/cadet/TODO @@ -1,7 +1,6 @@ - URGENT: Congestion/flow control (CHANNEL): + estimate max bandwidth using bursts and use to for CONGESTION CONTROL! (and figure out how/where to use this!) - + get current RTT from connection; use that for initial retransmissions! + figure out flow control without ACKs (unreliable traffic!) - HIGH: revisit handling of 'unbuffered' traffic! (CHANNEL/TUNNEL) diff --git a/src/cadet/gnunet-service-cadet-new_channel.c b/src/cadet/gnunet-service-cadet-new_channel.c index 00866b3d5..da9eb3c75 100644 --- a/src/cadet/gnunet-service-cadet-new_channel.c +++ b/src/cadet/gnunet-service-cadet-new_channel.c @@ -25,8 +25,6 @@ * * TODO: * - Congestion/flow control: - * + calculate current RTT if possible, use that for initial retransmissions - * (NOTE: needs us to learn which connection the tunnel uses for the message!) * + estimate max bandwidth using bursts and use to for CONGESTION CONTROL! * (and figure out how/where to use this!) * + figure out flow control without ACKs (unreliable traffic!) @@ -306,11 +304,6 @@ struct CadetChannel */ struct GNUNET_TIME_Relative retry_time; - /** - * How long does it usually take to get an ACK. - */ - struct GNUNET_TIME_Relative expected_delay; - /** * Bitfield of already-received messages past @e mid_recv. */ @@ -1649,10 +1642,17 @@ data_sent_cb (void *cls, GCC_ack_expected (cid); } } - if (0 == crm->retry_delay.rel_value_us) - crm->retry_delay = ch->expected_delay; - else - crm->retry_delay = GNUNET_TIME_STD_BACKOFF (crm->retry_delay); + if ( (0 == crm->retry_delay.rel_value_us) && + (NULL != cid) ) + { + struct CadetConnection *cc = GCC_lookup (cid); + + if (NULL != cc) + crm->retry_delay = GCC_get_metrics (cc)->aged_latency; + else + crm->retry_delay = ch->retry_time; + } + crm->retry_delay = GNUNET_TIME_STD_BACKOFF (crm->retry_delay); crm->retry_delay = GNUNET_TIME_relative_max (crm->retry_delay, MIN_RTT_DELAY); crm->next_retry = GNUNET_TIME_relative_to_absolute (crm->retry_delay); diff --git a/src/cadet/gnunet-service-cadet-new_connection.c b/src/cadet/gnunet-service-cadet-new_connection.c index 0ccfe8b45..6976e66e4 100644 --- a/src/cadet/gnunet-service-cadet-new_connection.c +++ b/src/cadet/gnunet-service-cadet-new_connection.c @@ -168,6 +168,20 @@ struct CadetConnection }; +/** + * Lookup a connection by its identifier. + * + * @param cid identifier to resolve + * @return NULL if connection was not found + */ +struct CadetConnection * +GCC_lookup (const struct GNUNET_CADET_ConnectionTunnelIdentifier *cid) +{ + return GNUNET_CONTAINER_multishortmap_get (connections, + &cid->connection_of_tunnel); +} + + /** * Update the connection state. Also triggers the necessary * MQM notifications. @@ -405,8 +419,7 @@ GCC_ack_expected (const struct GNUNET_CADET_ConnectionTunnelIdentifier *cid) { struct CadetConnection *cc; - cc = GNUNET_CONTAINER_multishortmap_get (connections, - &cid->connection_of_tunnel); + cc = GCC_lookup (cid); if (NULL == cc) return; /* whopise, connection alredy down? */ cc->metrics.num_acked_transmissions++; @@ -426,8 +439,7 @@ GCC_ack_observed (const struct GNUNET_CADET_ConnectionTunnelIdentifier *cid) { struct CadetConnection *cc; - cc = GNUNET_CONTAINER_multishortmap_get (connections, - &cid->connection_of_tunnel); + cc = GCC_lookup (cid); if (NULL == cc) return; /* whopise, connection alredy down? */ cc->metrics.num_successes++; @@ -450,8 +462,7 @@ GCC_latency_observed (const struct GNUNET_CADET_ConnectionTunnelIdentifier *cid, double weight; double result; - cc = GNUNET_CONTAINER_multishortmap_get (connections, - &cid->connection_of_tunnel); + cc = GCC_lookup (cid); if (NULL == cc) return; /* whopise, connection alredy down? */ GNUNET_STATISTICS_update (stats, diff --git a/src/cadet/gnunet-service-cadet-new_connection.h b/src/cadet/gnunet-service-cadet-new_connection.h index 73388be7f..e48b208fd 100644 --- a/src/cadet/gnunet-service-cadet-new_connection.h +++ b/src/cadet/gnunet-service-cadet-new_connection.h @@ -72,6 +72,16 @@ void GCC_destroy_without_tunnel (struct CadetConnection *cc); +/** + * Lookup a connection by its identifier. + * + * @param cid identifier to resolve + * @return NULL if connection was not found + */ +struct CadetConnection * +GCC_lookup (const struct GNUNET_CADET_ConnectionTunnelIdentifier *cid); + + /** * Create a connection to @a destination via @a path and * notify @a cb whenever we are ready for more data. diff --git a/src/cadet/gnunet-service-cadet-new_core.c b/src/cadet/gnunet-service-cadet-new_core.c index ee05a2442..8886e7a61 100644 --- a/src/cadet/gnunet-service-cadet-new_core.c +++ b/src/cadet/gnunet-service-cadet-new_core.c @@ -804,8 +804,7 @@ handle_connection_create (void *cls, struct CadetPeerPath *path; struct CadetPeer *origin; - cc = GNUNET_CONTAINER_multishortmap_get (connections, - &msg->cid.connection_of_tunnel); + cc = GCC_lookup (&msg->cid); if (NULL != cc) { LOG (GNUNET_ERROR_TYPE_DEBUG, @@ -925,8 +924,7 @@ handle_connection_create_ack (void *cls, struct CadetConnection *cc; /* First, check if ACK belongs to a connection that ends here. */ - cc = GNUNET_CONTAINER_multishortmap_get (connections, - &msg->cid.connection_of_tunnel); + cc = GCC_lookup (&msg->cid); if (NULL != cc) { /* verify ACK came from the right direction */ @@ -970,8 +968,7 @@ handle_connection_broken (void *cls, struct CadetRoute *route; /* First, check if message belongs to a connection that ends here. */ - cc = GNUNET_CONTAINER_multishortmap_get (connections, - &msg->cid.connection_of_tunnel); + cc = GCC_lookup (&msg->cid); if (NULL != cc) { /* verify message came from the right direction */ @@ -1020,8 +1017,7 @@ handle_connection_destroy (void *cls, struct CadetRoute *route; /* First, check if message belongs to a connection that ends here. */ - cc = GNUNET_CONTAINER_multishortmap_get (connections, - &msg->cid.connection_of_tunnel); + cc = GCC_lookup (&msg->cid); if (NULL != cc) { /* verify message came from the right direction */ @@ -1070,8 +1066,7 @@ handle_tunnel_kx (void *cls, struct CadetConnection *cc; /* First, check if message belongs to a connection that ends here. */ - cc = GNUNET_CONTAINER_multishortmap_get (connections, - &msg->cid.connection_of_tunnel); + cc = GCC_lookup (&msg->cid); if (NULL != cc) { /* verify message came from the right direction */ @@ -1111,8 +1106,7 @@ handle_tunnel_kx_auth (void *cls, struct CadetConnection *cc; /* First, check if message belongs to a connection that ends here. */ - cc = GNUNET_CONTAINER_multishortmap_get (connections, - &msg->kx.cid.connection_of_tunnel); + cc = GCC_lookup (&msg->kx.cid); if (NULL != cc) { /* verify message came from the right direction */ @@ -1168,8 +1162,7 @@ handle_tunnel_encrypted (void *cls, struct CadetConnection *cc; /* First, check if message belongs to a connection that ends here. */ - cc = GNUNET_CONTAINER_multishortmap_get (connections, - &msg->cid.connection_of_tunnel); + cc = GCC_lookup (&msg->cid); if (NULL != cc) { /* verify message came from the right direction */ -- 2.25.1