2 This file is part of GNUnet.
3 Copyright (C) 2010-2015, 2018 GNUnet e.V.
5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version.
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details.
15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
20 * Bandwidth allocation API for the transport service
22 * @author Christian Grothoff
23 * @author Matthias Wachs
25 * @defgroup ats ATS service
26 * Bandwidth allocation for transport service
28 * @see [Documentation](https://gnunet.org/ats-subsystem)
32 #ifndef GNUNET_ATS_TRANSPORT_SERVICE_H
33 #define GNUNET_ATS_TRANSPORT_SERVICE_H
35 #include "gnunet_constants.h"
36 #include "gnunet_util_lib.h"
37 #include "gnunet_nt_lib.h"
38 #include "gnunet_transport_communication_service.h"
42 * ATS performance characteristics for an address.
44 struct GNUNET_ATS_Properties
48 * Delay. Time between when the time packet is sent and the packet
49 * arrives. FOREVER if we did not (successfully) measure yet.
51 struct GNUNET_TIME_Relative delay;
54 * Confirmed successful payload on this connection from this peer to
57 * Unit: [bytes/second]
62 * Confirmed useful payload on this connection to this peer from
65 * Unit: [bytes/second]
70 * Actual traffic on this connection from this peer to the other peer.
71 * Includes transport overhead.
73 * Unit: [bytes/second]
75 uint32_t utilization_out;
78 * Actual traffic on this connection from the other peer to this peer.
79 * Includes transport overhead.
81 * Unit: [bytes/second]
83 uint32_t utilization_in;
86 * Distance on network layer (required for distance-vector routing)
87 * in hops. Zero for direct connections (i.e. plain TCP/UDP).
92 * MTU of the network layer, UINT32_MAX for no MTU (stream).
99 * Which network scope does the respective address belong to?
101 enum GNUNET_NetworkType nt;
104 * What characteristics does this communicator have?
106 enum GNUNET_TRANSPORT_CommunicatorCharacteristics cc;
111 /* ******************************** Transport API ***************************** */
114 * Handle to the ATS subsystem for bandwidth/transport transport information.
116 struct GNUNET_ATS_TransportHandle;
119 * Opaque session handle, to be defined by transport. Contents not known to ATS.
121 struct GNUNET_ATS_Session;
125 * Signature of a function called by ATS with the current bandwidth
126 * allocation to be used as determined by ATS.
129 * @param session session this is about
130 * @param bandwidth_out assigned outbound bandwidth for the connection,
131 * 0 to signal disconnect
132 * @param bandwidth_in assigned inbound bandwidth for the connection,
133 * 0 to signal disconnect
136 (*GNUNET_ATS_AllocationCallback) (void *cls,
137 struct GNUNET_ATS_Session *session,
138 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out,
139 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in);
143 * Signature of a function called by ATS suggesting transport to
144 * try connecting with a particular address.
147 * @param pid target peer
148 * @param address the address to try
151 (*GNUNET_ATS_SuggestionCallback) (void *cls,
152 const struct GNUNET_PeerIdentity *pid,
153 const char *address);
157 * Initialize the ATS transport subsystem.
159 * @param cfg configuration to use
160 * @param alloc_cb notification to call whenever the allocation changed
161 * @param alloc_cb_cls closure for @a alloc_cb
162 * @param suggest_cb notification to call whenever the suggestation is made
163 * @param suggest_cb_cls closure for @a suggest_cb
164 * @return ats context
166 struct GNUNET_ATS_TransportHandle *
167 GNUNET_ATS_transport_init (const struct GNUNET_CONFIGURATION_Handle *cfg,
168 GNUNET_ATS_AllocationCallback alloc_cb,
170 GNUNET_ATS_SuggestionCallback suggest_cb,
171 void *suggest_cb_cls);
175 * Client is done with ATS transport, release resources.
177 * @param ath handle to release
180 GNUNET_ATS_transport_done (struct GNUNET_ATS_TransportHandle *ath);
184 * Handle used within ATS to track an session.
186 struct GNUNET_ATS_SessionRecord;
190 * We have a new session ATS should know. Sessiones have to be added with this
191 * function before they can be: updated, set in use and destroyed
194 * @param pid peer we connected to
195 * @param address the address (human readable version),
196 * @param session transport-internal handle for the session/queue, NULL if
197 * the session is inbound-only
198 * @param prop performance data for the session
199 * @return handle to the session representation inside ATS, NULL
200 * on error (i.e. ATS knows this exact session already, or
201 * session is invalid)
203 struct GNUNET_ATS_SessionRecord *
204 GNUNET_ATS_session_add (struct GNUNET_ATS_TransportHandle *ath,
205 const struct GNUNET_PeerIdentity *pid,
207 struct GNUNET_ATS_Session *session,
208 const struct GNUNET_ATS_Properties *prop);
212 * We have updated performance statistics for a given session. Based
213 * on the information provided, ATS may update bandwidth assignments.
215 * @param ar session record to update information for
216 * @param prop performance data for the session
219 GNUNET_ATS_session_update (struct GNUNET_ATS_SessionRecord *ar,
220 const struct GNUNET_ATS_Properties *prop);
224 * A session was destroyed, ATS should now schedule and
225 * allocate under the assumption that this @a ar is no
228 * @param ar session record to drop
231 GNUNET_ATS_session_del (struct GNUNET_ATS_SessionRecord *ar);
236 /** @} */ /* end of group */
238 /* end of file gnunet-service-transport_ats.h */