aboutsummaryrefslogtreecommitdiff
path: root/src/transport/gnunet-service-tng.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/transport/gnunet-service-tng.c')
-rw-r--r--src/transport/gnunet-service-tng.c87
1 files changed, 74 insertions, 13 deletions
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 @@
39 * - use ATS bandwidth allocation callback and schedule transmissions! 39 * - use ATS bandwidth allocation callback and schedule transmissions!
40 * 40 *
41 * Plan: 41 * Plan:
42 * - inform ATS about RTT, goodput/loss, overheads, etc. 42 * - inform ATS about RTT, goodput/loss, overheads, etc. (GNUNET_ATS_session_update())
43 * 43 *
44 * Later: 44 * Later:
45 * - change transport-core API to provide proper flow control in both 45 * - change transport-core API to provide proper flow control in both
@@ -333,6 +333,11 @@ struct GNUNET_ATS_Session
333 const char *address; 333 const char *address;
334 334
335 /** 335 /**
336 * Handle by which we inform ATS about this queue.
337 */
338 struct GNUNET_ATS_SessionRecord *sr;
339
340 /**
336 * Our current RTT estimate for this ATS session. 341 * Our current RTT estimate for this ATS session.
337 */ 342 */
338 struct GNUNET_TIME_Relative rtt; 343 struct GNUNET_TIME_Relative rtt;
@@ -996,20 +1001,20 @@ free_queue (struct GNUNET_ATS_Session *queue)
996 GNUNET_CONTAINER_MDLL_remove (client, 1001 GNUNET_CONTAINER_MDLL_remove (client,
997 tc->details.communicator.session_head, 1002 tc->details.communicator.session_head,
998 tc->details.communicator.session_tail, 1003 tc->details.communicator.session_tail,
999 queue); 1004 queue);
1000
1001 notify_monitors (&neighbour->pid, 1005 notify_monitors (&neighbour->pid,
1002 queue->address, 1006 queue->address,
1003 queue->nt, 1007 queue->nt,
1004 &me); 1008 &me);
1009 GNUNET_ATS_session_del (queue->sr);
1005 GNUNET_BANDWIDTH_tracker_notification_stop (&queue->tracker_in); 1010 GNUNET_BANDWIDTH_tracker_notification_stop (&queue->tracker_in);
1006 GNUNET_BANDWIDTH_tracker_notification_stop (&queue->tracker_out); 1011 GNUNET_BANDWIDTH_tracker_notification_stop (&queue->tracker_out);
1007 GNUNET_free (queue); 1012 GNUNET_free (queue);
1008 if (NULL == neighbour->session_head) 1013 if (NULL == neighbour->session_head)
1009 { 1014 {
1010 cores_send_disconnect_info (&neighbour->pid); 1015 cores_send_disconnect_info (&neighbour->pid);
1011 free_neighbour (neighbour); 1016 free_neighbour (neighbour);
1012 } 1017 }
1013} 1018}
1014 1019
1015 1020
@@ -1650,7 +1655,6 @@ handle_add_queue_message (void *cls,
1650 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); 1655 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
1651 cores_send_connect_info (&neighbour->pid, 1656 cores_send_connect_info (&neighbour->pid,
1652 GNUNET_BANDWIDTH_ZERO); 1657 GNUNET_BANDWIDTH_ZERO);
1653 // FIXME: notify ATS!
1654 } 1658 }
1655 addr_len = ntohs (aqm->header.size) - sizeof (*aqm); 1659 addr_len = ntohs (aqm->header.size) - sizeof (*aqm);
1656 addr = (const char *) &aqm[1]; 1660 addr = (const char *) &aqm[1];
@@ -1661,7 +1665,6 @@ handle_add_queue_message (void *cls,
1661 queue->rtt = GNUNET_TIME_UNIT_FOREVER_REL; 1665 queue->rtt = GNUNET_TIME_UNIT_FOREVER_REL;
1662 queue->qid = aqm->qid; 1666 queue->qid = aqm->qid;
1663 queue->mtu = ntohl (aqm->mtu); 1667 queue->mtu = ntohl (aqm->mtu);
1664 queue->distance = ntohl (aqm->distance);
1665 queue->nt = (enum GNUNET_NetworkType) ntohl (aqm->nt); 1668 queue->nt = (enum GNUNET_NetworkType) ntohl (aqm->nt);
1666 queue->cs = (enum GNUNET_TRANSPORT_ConnectionStatus) ntohl (aqm->cs); 1669 queue->cs = (enum GNUNET_TRANSPORT_ConnectionStatus) ntohl (aqm->cs);
1667 queue->neighbour = neighbour; 1670 queue->neighbour = neighbour;
@@ -1682,6 +1685,38 @@ handle_add_queue_message (void *cls,
1682 memcpy (&queue[1], 1685 memcpy (&queue[1],
1683 addr, 1686 addr,
1684 addr_len); 1687 addr_len);
1688 /* notify ATS about new queue */
1689 {
1690 struct GNUNET_ATS_Properties prop = {
1691 .delay = GNUNET_TIME_UNIT_FOREVER_REL,
1692 .mtu = queue->mtu,
1693 .nt = queue->nt,
1694 .cc = tc->details.communicator.cc
1695 };
1696
1697 queue->sr = GNUNET_ATS_session_add (ats,
1698 &neighbour->pid,
1699 queue->address,
1700 queue,
1701 &prop);
1702 if (NULL == queue->sr)
1703 {
1704 /* This can only happen if the 'address' was way too long for ATS
1705 (approaching 64k in strlen()!). In this case, the communicator
1706 must be buggy and we drop it. */
1707 GNUNET_break (0);
1708 GNUNET_BANDWIDTH_tracker_notification_stop (&queue->tracker_in);
1709 GNUNET_BANDWIDTH_tracker_notification_stop (&queue->tracker_out);
1710 GNUNET_free (queue);
1711 if (NULL == neighbour->session_head)
1712 {
1713 cores_send_disconnect_info (&neighbour->pid);
1714 free_neighbour (neighbour);
1715 }
1716 GNUNET_SERVICE_client_drop (tc->client);
1717 return;
1718 }
1719 }
1685 /* notify monitors about new queue */ 1720 /* notify monitors about new queue */
1686 { 1721 {
1687 struct MonitorEvent me = { 1722 struct MonitorEvent me = {
@@ -1702,7 +1737,6 @@ handle_add_queue_message (void *cls,
1702 tc->details.communicator.session_head, 1737 tc->details.communicator.session_head,
1703 tc->details.communicator.session_tail, 1738 tc->details.communicator.session_tail,
1704 queue); 1739 queue);
1705 // FIXME: possibly transmit queued messages?
1706 GNUNET_SERVICE_client_continue (tc->client); 1740 GNUNET_SERVICE_client_continue (tc->client);
1707} 1741}
1708 1742
@@ -1763,6 +1797,12 @@ handle_send_message_ack (void *cls,
1763 GNUNET_SERVICE_client_drop (tc->client); 1797 GNUNET_SERVICE_client_drop (tc->client);
1764 return; 1798 return;
1765 } 1799 }
1800 // FIXME: react to communicator status about transmission request. We got:
1801 sma->status; // OK success, SYSERR failure
1802 sma->mid; // message ID of original message
1803 sma->receiver; // receiver of original message
1804
1805
1766 GNUNET_SERVICE_client_continue (tc->client); 1806 GNUNET_SERVICE_client_continue (tc->client);
1767} 1807}
1768 1808
@@ -1870,7 +1910,19 @@ ats_allocation_cb (void *cls,
1870static struct TransportClient * 1910static struct TransportClient *
1871lookup_communicator (const char *prefix) 1911lookup_communicator (const char *prefix)
1872{ 1912{
1873 GNUNET_break (0); // FIXME: implement 1913 for (struct TransportClient *tc = clients_head;
1914 NULL != tc;
1915 tc = tc->next)
1916 {
1917 if (CT_COMMUNICATOR != tc->type)
1918 continue;
1919 if (0 == strcmp (prefix,
1920 tc->details.communicator.address_prefix))
1921 return tc;
1922 }
1923 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
1924 "ATS suggested use of communicator for `%s', but we do not have such a communicator!\n",
1925 prefix);
1874 return NULL; 1926 return NULL;
1875} 1927}
1876 1928
@@ -1892,11 +1944,20 @@ ats_suggestion_cb (void *cls,
1892 char *prefix; 1944 char *prefix;
1893 1945
1894 (void) cls; 1946 (void) cls;
1895 prefix = NULL; // FIXME 1947 prefix = GNUNET_HELLO_address_to_prefix (address);
1948 if (NULL == prefix)
1949 {
1950 GNUNET_break (0); /* ATS gave invalid address!? */
1951 return;
1952 }
1896 tc = lookup_communicator (prefix); 1953 tc = lookup_communicator (prefix);
1897 if (NULL == tc) 1954 if (NULL == tc)
1898 { 1955 {
1899 // STATS... 1956 GNUNET_STATISTICS_update (GST_stats,
1957 "# ATS suggestions ignored due to missing communicator",
1958 1,
1959 GNUNET_NO);
1960
1900 return; 1961 return;
1901 } 1962 }
1902 // FIXME: forward suggestion to tc 1963 // FIXME: forward suggestion to tc