summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2019-01-21 14:14:42 +0100
committerChristian Grothoff <christian@grothoff.org>2019-01-21 14:14:42 +0100
commit634aea297cc983c3d70f65a004f698f215abe590 (patch)
treec337abee0cf6e15b14785efcfc6cec49883a92b7
parent7ed02994541af600b0d080829e944ab414445dcc (diff)
more work on tng
-rw-r--r--src/hello/hello-ng.c20
-rw-r--r--src/include/gnunet_hello_lib.h10
-rw-r--r--src/include/gnunet_transport_communication_service.h2
-rw-r--r--src/transport/gnunet-communicator-unix.c1
-rw-r--r--src/transport/gnunet-service-tng.c87
-rw-r--r--src/transport/transport.h5
-rw-r--r--src/transport/transport_api2_communication.c9
7 files changed, 104 insertions, 30 deletions
diff --git a/src/hello/hello-ng.c b/src/hello/hello-ng.c
index c088abf35..2d60b04f3 100644
--- a/src/hello/hello-ng.c
+++ b/src/hello/hello-ng.c
@@ -194,3 +194,23 @@ GNUNET_HELLO_extract_address (const void *raw,
*nt = (enum GNUNET_NetworkType) raw_nt;
return GNUNET_strdup (raw_addr);
}
+
+
+/**
+ * Given an address as a string, extract the prefix that identifies
+ * the communicator offering transmissions to that address.
+ *
+ * @param address a peer's address
+ * @return NULL if the address is mal-formed, otherwise the prefix
+ */
+char *
+GNUNET_HELLO_address_to_prefix (const char *address)
+{
+ const char *dash;
+
+ dash = strchr (address, '-');
+ if (NULL == dash)
+ return NULL;
+ return GNUNET_strndup (address,
+ dash - address);
+}
diff --git a/src/include/gnunet_hello_lib.h b/src/include/gnunet_hello_lib.h
index a1b97809e..c2256fd0a 100644
--- a/src/include/gnunet_hello_lib.h
+++ b/src/include/gnunet_hello_lib.h
@@ -520,6 +520,16 @@ GNUNET_HELLO_extract_address (const void *raw,
struct GNUNET_TIME_Absolute *expiration);
+/**
+ * Given an address as a string, extract the prefix that identifies
+ * the communicator offering transmissions to that address.
+ *
+ * @param address a peer's address
+ * @return NULL if the address is mal-formed, otherwise the prefix
+ */
+char *
+GNUNET_HELLO_address_to_prefix (const char *address);
+
#if 0 /* keep Emacsens' auto-indent happy */
{
diff --git a/src/include/gnunet_transport_communication_service.h b/src/include/gnunet_transport_communication_service.h
index 2997c1860..307f6688a 100644
--- a/src/include/gnunet_transport_communication_service.h
+++ b/src/include/gnunet_transport_communication_service.h
@@ -243,7 +243,6 @@ enum GNUNET_TRANSPORT_ConnectionStatus {
* @param mtu maximum message size supported by queue, 0 if
* sending is not supported, SIZE_MAX for no MTU
* @param nt which network type does the @a address belong to?
- * @param distance how many hops does this queue use (DV-only)?
* @param cs what is the connection status of the queue?
* @param mq message queue of the @a peer
* @return API handle identifying the new MQ
@@ -254,7 +253,6 @@ GNUNET_TRANSPORT_communicator_mq_add (struct GNUNET_TRANSPORT_CommunicatorHandle
const char *address,
uint32_t mtu,
enum GNUNET_NetworkType nt,
- uint32_t distance,
enum GNUNET_TRANSPORT_ConnectionStatus cs,
struct GNUNET_MQ_Handle *mq);
diff --git a/src/transport/gnunet-communicator-unix.c b/src/transport/gnunet-communicator-unix.c
index 5d4032834..08f02b66d 100644
--- a/src/transport/gnunet-communicator-unix.c
+++ b/src/transport/gnunet-communicator-unix.c
@@ -685,7 +685,6 @@ setup_queue (const struct GNUNET_PeerIdentity *target,
foreign_addr,
UNIX_MTU,
GNUNET_NT_LOOPBACK,
- 0 /* distance */,
cs,
queue->mq);
GNUNET_free (foreign_addr);
diff --git a/src/transport/gnunet-service-tng.c b/src/transport/gnunet-service-tng.c
index 5a335f447..0a129af80 100644
--- a/src/transport/gnunet-service-tng.c
+++ b/src/transport/gnunet-service-tng.c
@@ -39,7 +39,7 @@
* - use ATS bandwidth allocation callback and schedule transmissions!
*
* Plan:
- * - inform ATS about RTT, goodput/loss, overheads, etc.
+ * - inform ATS about RTT, goodput/loss, overheads, etc. (GNUNET_ATS_session_update())
*
* Later:
* - change transport-core API to provide proper flow control in both
@@ -333,6 +333,11 @@ struct GNUNET_ATS_Session
const char *address;
/**
+ * Handle by which we inform ATS about this queue.
+ */
+ struct GNUNET_ATS_SessionRecord *sr;
+
+ /**
* Our current RTT estimate for this ATS session.
*/
struct GNUNET_TIME_Relative rtt;
@@ -996,20 +1001,20 @@ free_queue (struct GNUNET_ATS_Session *queue)
GNUNET_CONTAINER_MDLL_remove (client,
tc->details.communicator.session_head,
tc->details.communicator.session_tail,
- queue);
-
+ queue);
notify_monitors (&neighbour->pid,
queue->address,
queue->nt,
&me);
+ GNUNET_ATS_session_del (queue->sr);
GNUNET_BANDWIDTH_tracker_notification_stop (&queue->tracker_in);
GNUNET_BANDWIDTH_tracker_notification_stop (&queue->tracker_out);
GNUNET_free (queue);
if (NULL == neighbour->session_head)
- {
- cores_send_disconnect_info (&neighbour->pid);
- free_neighbour (neighbour);
- }
+ {
+ cores_send_disconnect_info (&neighbour->pid);
+ free_neighbour (neighbour);
+ }
}
@@ -1650,7 +1655,6 @@ handle_add_queue_message (void *cls,
GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
cores_send_connect_info (&neighbour->pid,
GNUNET_BANDWIDTH_ZERO);
- // FIXME: notify ATS!
}
addr_len = ntohs (aqm->header.size) - sizeof (*aqm);
addr = (const char *) &aqm[1];
@@ -1661,7 +1665,6 @@ handle_add_queue_message (void *cls,
queue->rtt = GNUNET_TIME_UNIT_FOREVER_REL;
queue->qid = aqm->qid;
queue->mtu = ntohl (aqm->mtu);
- queue->distance = ntohl (aqm->distance);
queue->nt = (enum GNUNET_NetworkType) ntohl (aqm->nt);
queue->cs = (enum GNUNET_TRANSPORT_ConnectionStatus) ntohl (aqm->cs);
queue->neighbour = neighbour;
@@ -1682,6 +1685,38 @@ handle_add_queue_message (void *cls,
memcpy (&queue[1],
addr,
addr_len);
+ /* notify ATS about new queue */
+ {
+ struct GNUNET_ATS_Properties prop = {
+ .delay = GNUNET_TIME_UNIT_FOREVER_REL,
+ .mtu = queue->mtu,
+ .nt = queue->nt,
+ .cc = tc->details.communicator.cc
+ };
+
+ queue->sr = GNUNET_ATS_session_add (ats,
+ &neighbour->pid,
+ queue->address,
+ queue,
+ &prop);
+ if (NULL == queue->sr)
+ {
+ /* This can only happen if the 'address' was way too long for ATS
+ (approaching 64k in strlen()!). In this case, the communicator
+ must be buggy and we drop it. */
+ GNUNET_break (0);
+ GNUNET_BANDWIDTH_tracker_notification_stop (&queue->tracker_in);
+ GNUNET_BANDWIDTH_tracker_notification_stop (&queue->tracker_out);
+ GNUNET_free (queue);
+ if (NULL == neighbour->session_head)
+ {
+ cores_send_disconnect_info (&neighbour->pid);
+ free_neighbour (neighbour);
+ }
+ GNUNET_SERVICE_client_drop (tc->client);
+ return;
+ }
+ }
/* notify monitors about new queue */
{
struct MonitorEvent me = {
@@ -1702,7 +1737,6 @@ handle_add_queue_message (void *cls,
tc->details.communicator.session_head,
tc->details.communicator.session_tail,
queue);
- // FIXME: possibly transmit queued messages?
GNUNET_SERVICE_client_continue (tc->client);
}
@@ -1763,6 +1797,12 @@ handle_send_message_ack (void *cls,
GNUNET_SERVICE_client_drop (tc->client);
return;
}
+ // FIXME: react to communicator status about transmission request. We got:
+ sma->status; // OK success, SYSERR failure
+ sma->mid; // message ID of original message
+ sma->receiver; // receiver of original message
+
+
GNUNET_SERVICE_client_continue (tc->client);
}
@@ -1870,7 +1910,19 @@ ats_allocation_cb (void *cls,
static struct TransportClient *
lookup_communicator (const char *prefix)
{
- GNUNET_break (0); // FIXME: implement
+ for (struct TransportClient *tc = clients_head;
+ NULL != tc;
+ tc = tc->next)
+ {
+ if (CT_COMMUNICATOR != tc->type)
+ continue;
+ if (0 == strcmp (prefix,
+ tc->details.communicator.address_prefix))
+ return tc;
+ }
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ "ATS suggested use of communicator for `%s', but we do not have such a communicator!\n",
+ prefix);
return NULL;
}
@@ -1892,11 +1944,20 @@ ats_suggestion_cb (void *cls,
char *prefix;
(void) cls;
- prefix = NULL; // FIXME
+ prefix = GNUNET_HELLO_address_to_prefix (address);
+ if (NULL == prefix)
+ {
+ GNUNET_break (0); /* ATS gave invalid address!? */
+ return;
+ }
tc = lookup_communicator (prefix);
if (NULL == tc)
{
- // STATS...
+ GNUNET_STATISTICS_update (GST_stats,
+ "# ATS suggestions ignored due to missing communicator",
+ 1,
+ GNUNET_NO);
+
return;
}
// FIXME: forward suggestion to tc
diff --git a/src/transport/transport.h b/src/transport/transport.h
index 670a8d32d..88656a012 100644
--- a/src/transport/transport.h
+++ b/src/transport/transport.h
@@ -817,11 +817,6 @@ struct GNUNET_TRANSPORT_AddQueueMessage
*/
uint32_t cs;
- /**
- * Hops to the target (DV-only), in NBO.
- */
- uint32_t distance;
-
/* followed by UTF-8 encoded, 0-terminated human-readable address */
};
diff --git a/src/transport/transport_api2_communication.c b/src/transport/transport_api2_communication.c
index 1a176e68f..a816ecb67 100644
--- a/src/transport/transport_api2_communication.c
+++ b/src/transport/transport_api2_communication.c
@@ -274,11 +274,6 @@ struct GNUNET_TRANSPORT_QueueHandle
enum GNUNET_TRANSPORT_ConnectionStatus cs;
/**
- * How many hops is the target away (DV-only)
- */
- uint32_t distance;
-
- /**
* ID for this queue when talking to the transport service.
*/
uint32_t queue_id;
@@ -418,7 +413,6 @@ send_add_queue (struct GNUNET_TRANSPORT_QueueHandle *qh)
aqm->nt = htonl ((uint32_t) qh->nt);
aqm->mtu = htonl (qh->mtu);
aqm->cs = htonl ((uint32_t) qh->cs);
- aqm->distance = htonl (qh->distance);
memcpy (&aqm[1],
qh->address,
strlen (qh->address) + 1);
@@ -956,7 +950,6 @@ GNUNET_TRANSPORT_communicator_receive (struct GNUNET_TRANSPORT_CommunicatorHandl
* sending is not supported, SIZE_MAX for no MTU
* @param nt which network type does the @a address belong to?
* @param cc what characteristics does the communicator have?
- * @param distance how many hops does this queue use (DV-only)?
* @param cs what is the connection status of the queue?
* @param mq message queue of the @a peer
* @return API handle identifying the new MQ
@@ -967,7 +960,6 @@ GNUNET_TRANSPORT_communicator_mq_add (struct GNUNET_TRANSPORT_CommunicatorHandle
const char *address,
uint32_t mtu,
enum GNUNET_NetworkType nt,
- uint32_t distance,
enum GNUNET_TRANSPORT_ConnectionStatus cs,
struct GNUNET_MQ_Handle *mq)
{
@@ -979,7 +971,6 @@ GNUNET_TRANSPORT_communicator_mq_add (struct GNUNET_TRANSPORT_CommunicatorHandle
qh->address = GNUNET_strdup (address);
qh->nt = nt;
qh->mtu = mtu;
- qh->distance = distance;
qh->cs = cs;
qh->mq = mq;
qh->queue_id = ch->queue_gen++;