aboutsummaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2018-11-22 22:46:43 +0100
committerChristian Grothoff <christian@grothoff.org>2018-11-22 22:46:43 +0100
commitfbc5f3876a2ed52f18e2a2810e3cdda497cc99ea (patch)
treed01a9a8f202dd53a6ff6901c190d4d7031da1baa /src/include
parentc87f73a07df468eccedbe1fdfa82bdd5b633a0d5 (diff)
downloadgnunet-fbc5f3876a2ed52f18e2a2810e3cdda497cc99ea.tar.gz
gnunet-fbc5f3876a2ed52f18e2a2810e3cdda497cc99ea.zip
add design sketch for new ATS API
Diffstat (limited to 'src/include')
-rw-r--r--src/include/Makefile.am2
-rw-r--r--src/include/gnunet_ats_application_service.h99
-rw-r--r--src/include/gnunet_ats_transport_service.h238
-rw-r--r--src/include/gnunet_transport_communication_service.h32
4 files changed, 370 insertions, 1 deletions
diff --git a/src/include/Makefile.am b/src/include/Makefile.am
index 185f649ac..9d0c4f8ea 100644
--- a/src/include/Makefile.am
+++ b/src/include/Makefile.am
@@ -29,6 +29,8 @@ gnunetinclude_HEADERS = \
29 gnunet_applications.h \ 29 gnunet_applications.h \
30 gnunet_arm_service.h \ 30 gnunet_arm_service.h \
31 gnunet_ats_service.h \ 31 gnunet_ats_service.h \
32 gnunet_ats_application_service.h \
33 gnunet_ats_transport_service.h \
32 gnunet_ats_plugin.h \ 34 gnunet_ats_plugin.h \
33 gnunet_bandwidth_lib.h \ 35 gnunet_bandwidth_lib.h \
34 gnunet_bio_lib.h \ 36 gnunet_bio_lib.h \
diff --git a/src/include/gnunet_ats_application_service.h b/src/include/gnunet_ats_application_service.h
new file mode 100644
index 000000000..af92d5639
--- /dev/null
+++ b/src/include/gnunet_ats_application_service.h
@@ -0,0 +1,99 @@
1/*
2 This file is part of GNUnet.
3 Copyright (C) 2010-2015, 2018 GNUnet e.V.
4
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.
9
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.
14
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/>.
17 */
18/**
19 * @file
20 * Bandwidth allocation API for applications to interact with
21 *
22 * @author Christian Grothoff
23 * @author Matthias Wachs
24 *
25 * @defgroup ats ATS service
26 * Bandwidth allocation
27 *
28 * @see [Documentation](https://gnunet.org/ats-subsystem)
29 *
30 * @{
31 */
32#ifndef GNUNET_ATS_APPLICATION_SERVICE_H
33#define GNUNET_ATS_APPLICATION_SERVICE_H
34
35#include "gnunet_constants.h"
36#include "gnunet_util_lib.h"
37
38/**
39 * Handle to the ATS subsystem for making suggestions about
40 * connections the peer would like to have.
41 */
42struct GNUNET_ATS_ConnectivityHandle;
43
44
45/**
46 * Initialize the ATS connectivity suggestion client handle.
47 *
48 * @param cfg configuration to use
49 * @return ats connectivity handle, NULL on error
50 */
51struct GNUNET_ATS_ConnectivityHandle *
52GNUNET_ATS_connectivity_init (const struct GNUNET_CONFIGURATION_Handle *cfg);
53
54
55/**
56 * Shutdown ATS connectivity suggestion client.
57 *
58 * @param ch handle to destroy
59 */
60void
61GNUNET_ATS_connectivity_done (struct GNUNET_ATS_ConnectivityHandle *ch);
62
63
64/**
65 * Handle for address suggestion requests.
66 */
67struct GNUNET_ATS_ConnectivitySuggestHandle;
68
69
70/**
71 * An application would like to communicate with a peer. ATS should
72 * allocate bandwith using a suitable address for requiremetns @a pk
73 * to transport.
74 *
75 * @param ch handle
76 * @param peer identity of the peer we need an address for
77 * @param pk what kind of connectivity will the application require (can be
78 * #GNUNET_MQ_PREFERENCE_NONE, we will still try to connect)
79 * @param bw desired bandwith, can be zero (we will still try to connect)
80 * @return suggestion handle, NULL if request is already pending
81 */
82struct GNUNET_ATS_ConnectivitySuggestHandle *
83GNUNET_ATS_connectivity_suggest (struct GNUNET_ATS_ConnectivityHandle *ch,
84 const struct GNUNET_PeerIdentity *peer,
85 enum GNUNET_MQ_PreferenceKind pk,
86 struct GNUNET_BANDWIDTH_Value32NBO bw);
87
88
89/**
90 * We no longer care about communicating with a peer.
91 *
92 * @param sh handle
93 */
94void
95GNUNET_ATS_connectivity_suggest_cancel (struct GNUNET_ATS_ConnectivitySuggestHandle *sh);
96
97/** @} */ /* end of group */
98
99/* end of file gnunet_ats_application_service.h */
diff --git a/src/include/gnunet_ats_transport_service.h b/src/include/gnunet_ats_transport_service.h
new file mode 100644
index 000000000..b069f8b24
--- /dev/null
+++ b/src/include/gnunet_ats_transport_service.h
@@ -0,0 +1,238 @@
1/*
2 This file is part of GNUnet.
3 Copyright (C) 2010-2015, 2018 GNUnet e.V.
4
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.
9
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.
14
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/>.
17 */
18/**
19 * @file
20 * Bandwidth allocation API for the transport service
21 *
22 * @author Christian Grothoff
23 * @author Matthias Wachs
24 *
25 * @defgroup ats ATS service
26 * Bandwidth allocation for transport service
27 *
28 * @see [Documentation](https://gnunet.org/ats-subsystem)
29 *
30 * @{
31 */
32#ifndef GNUNET_ATS_TRANSPORT_SERVICE_H
33#define GNUNET_ATS_TRANSPORT_SERVICE_H
34
35#include "gnunet_constants.h"
36#include "gnunet_util_lib.h"
37#include "gnunet_nt_lib.h"
38#include "gnunet_transport_communication_service.h"
39
40
41/**
42 * ATS performance characteristics for an address.
43 */
44struct GNUNET_ATS_Properties
45{
46
47 /**
48 * Delay. Time between when the time packet is sent and the packet
49 * arrives. FOREVER if we did not (successfully) measure yet.
50 */
51 struct GNUNET_TIME_Relative delay;
52
53 /**
54 * Confirmed successful payload on this connection from this peer to
55 * the other peer.
56 *
57 * Unit: [bytes/second]
58 */
59 uint32_t goodput_out;
60
61 /**
62 * Confirmed useful payload on this connection to this peer from
63 * the other peer.
64 *
65 * Unit: [bytes/second]
66 */
67 uint32_t goodput_in;
68
69 /**
70 * Actual traffic on this connection from this peer to the other peer.
71 * Includes transport overhead.
72 *
73 * Unit: [bytes/second]
74 */
75 uint32_t utilization_out;
76
77 /**
78 * Actual traffic on this connection from the other peer to this peer.
79 * Includes transport overhead.
80 *
81 * Unit: [bytes/second]
82 */
83 uint32_t utilization_in;
84
85 /**
86 * Distance on network layer (required for distance-vector routing)
87 * in hops. Zero for direct connections (i.e. plain TCP/UDP).
88 */
89 uint32_t distance;
90
91 /**
92 * MTU of the network layer, UINT32_MAX for no MTU (stream).
93 *
94 * Unit: [bytes]
95 */
96 uint32_t mtu;
97
98 /**
99 * Which network scope does the respective address belong to?
100 */
101 enum GNUNET_NetworkType nt;
102
103 /**
104 * What characteristics does this communicator have?
105 */
106 enum GNUNET_TRANSPORT_CommunicatorCharacteristics cc;
107
108};
109
110
111/* ******************************** Scheduling API ***************************** */
112
113/**
114 * Handle to the ATS subsystem for bandwidth/transport scheduling information.
115 */
116struct GNUNET_ATS_SchedulingHandle;
117
118/**
119 * Opaque session handle, to be defined by transport. Contents not known to ATS.
120 */
121struct GNUNET_ATS_Session;
122
123
124/**
125 * Signature of a function called by ATS with the current bandwidth
126 * allocation to be used as determined by ATS.
127 *
128 * @param cls closure
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
134 */
135typedef void
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);
140
141
142/**
143 * Signature of a function called by ATS suggesting transport to
144 * try connecting with a particular address.
145 *
146 * @param cls closure
147 * @param pid target peer
148 * @param address the address to try
149 */
150typedef void
151(*GNUNET_ATS_SuggestionCallback) (void *cls,
152 const struct GNUNET_PeerIdentity *pid,
153 const char *address);
154
155
156/**
157 * Initialize the ATS scheduling subsystem.
158 *
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
165 */
166struct GNUNET_ATS_SchedulingHandle *
167GNUNET_ATS_scheduling_init (const struct GNUNET_CONFIGURATION_Handle *cfg,
168 GNUNET_ATS_AllocationCallback alloc_cb,
169 void *alloc_cb_cls);
170 GNUNET_ATS_SuggestionCallback suggest_cb,
171 void *suggest_cb_cls);
172
173
174/**
175 * Client is done with ATS scheduling, release resources.
176 *
177 * @param sh handle to release
178 */
179void
180GNUNET_ATS_scheduling_done (struct GNUNET_ATS_SchedulingHandle *sh);
181
182
183/**
184 * Handle used within ATS to track an address.
185 */
186struct GNUNET_ATS_AddressRecord;
187
188
189/**
190 * We have a new address ATS should know. Addresses have to be added with this
191 * function before they can be: updated, set in use and destroyed
192 *
193 * @param sh handle
194 * @param pid peer we connected to
195 * @param address the address (human readable version), NULL if
196 * the session is inbound-only
197 * @param session transport-internal handle for the address/queue
198 * @param prop performance data for the address
199 * @return handle to the address representation inside ATS, NULL
200 * on error (i.e. ATS knows this exact address already, or
201 * address is invalid)
202 */
203struct GNUNET_ATS_AddressRecord *
204GNUNET_ATS_address_add (struct GNUNET_ATS_SchedulingHandle *sh,
205 const struct GNUNET_PeerIdentity *pid,
206 const char *address,
207 struct GNUNET_ATS_Session *session,
208 const struct GNUNET_ATS_Properties *prop);
209
210
211/**
212 * We have updated performance statistics for a given address. Based
213 * on the information provided, ATS may update bandwidth assignments.
214 *
215 * @param ar address record to update information for
216 * @param prop performance data for the address
217 */
218void
219GNUNET_ATS_address_update (struct GNUNET_ATS_AddressRecord *ar,
220 const struct GNUNET_ATS_Properties *prop);
221
222
223/**
224 * A session was destroyed, ATS should now schedule and
225 * allocate under the assumption that this @a ar is no
226 * longer in use.
227 *
228 * @param ar address record to drop
229 */
230void
231GNUNET_ATS_address_del (struct GNUNET_ATS_AddressRecord *ar);
232
233
234#endif
235
236/** @} */ /* end of group */
237
238/* end of file gnunet-service-transport_ats.h */
diff --git a/src/include/gnunet_transport_communication_service.h b/src/include/gnunet_transport_communication_service.h
index fed681f0f..e80ba85cf 100644
--- a/src/include/gnunet_transport_communication_service.h
+++ b/src/include/gnunet_transport_communication_service.h
@@ -11,7 +11,7 @@
11 WITHOUT ANY WARRANTY; without even the implied warranty of 11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details. 13 Affero General Public License for more details.
14 14
15 You should have received a copy of the GNU Affero General Public License 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/>. 16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17*/ 17*/
@@ -80,12 +80,36 @@ struct GNUNET_TRANSPORT_CommunicatorHandle;
80 80
81 81
82/** 82/**
83 * What characteristics does this communicator have?
84 */
85enum GNUNET_TRANSPORT_CommunicatorCharacteristics {
86
87 /**
88 * Characteristics are unknown (i.e. DV).
89 */
90 GNUNET_TRANSPORT_CC_UNKNOWN = 0,
91
92 /**
93 * Transmission is reliabile (with ACKs), i.e. TCP/HTTP/HTTPS.
94 */
95 GNUNET_TRANSPORT_CC_RELIABLE = 1,
96
97 /**
98 * Transmission is unreliable (i.e. UDP)
99 */
100 GNUNET_TRANSPORT_CC_UNRELIABILE = 2
101
102};
103
104
105/**
83 * Connect to the transport service. 106 * Connect to the transport service.
84 * 107 *
85 * @param cfg configuration to use 108 * @param cfg configuration to use
86 * @param config_section section of the configuration to use for options 109 * @param config_section section of the configuration to use for options
87 * @param addr_prefix address prefix for addresses supported by this 110 * @param addr_prefix address prefix for addresses supported by this
88 * communicator, could be NULL for incoming-only communicators 111 * communicator, could be NULL for incoming-only communicators
112 * @param cc what characteristics does the communicator have?
89 * @param mq_init function to call to initialize a message queue given 113 * @param mq_init function to call to initialize a message queue given
90 * the address of another peer, can be NULL if the 114 * the address of another peer, can be NULL if the
91 * communicator only supports receiving messages 115 * communicator only supports receiving messages
@@ -96,6 +120,7 @@ struct GNUNET_TRANSPORT_CommunicatorHandle *
96GNUNET_TRANSPORT_communicator_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, 120GNUNET_TRANSPORT_communicator_connect (const struct GNUNET_CONFIGURATION_Handle *cfg,
97 const char *config_section_name, 121 const char *config_section_name,
98 const char *addr_prefix, 122 const char *addr_prefix,
123 enum GNUNET_TRANSPORT_CommunicatorCharacteristics cc,
99 GNUNET_TRANSPORT_CommunicatorMqInit mq_init, 124 GNUNET_TRANSPORT_CommunicatorMqInit mq_init,
100 void *mq_init_cls); 125 void *mq_init_cls);
101 126
@@ -162,14 +187,17 @@ struct GNUNET_TRANSPORT_QueueHandle;
162 * Possible states of a connection. 187 * Possible states of a connection.
163 */ 188 */
164enum GNUNET_TRANSPORT_ConnectionStatus { 189enum GNUNET_TRANSPORT_ConnectionStatus {
190
165 /** 191 /**
166 * Connection is down. 192 * Connection is down.
167 */ 193 */
168 GNUNET_TRANSPORT_CS_DOWN = -1, 194 GNUNET_TRANSPORT_CS_DOWN = -1,
195
169 /** 196 /**
170 * this is an outbound connection (transport initiated) 197 * this is an outbound connection (transport initiated)
171 */ 198 */
172 GNUNET_TRANSPORT_CS_OUTBOUND = 0, 199 GNUNET_TRANSPORT_CS_OUTBOUND = 0,
200
173 /** 201 /**
174 * this is an inbound connection (communicator initiated) 202 * this is an inbound connection (communicator initiated)
175 */ 203 */
@@ -188,6 +216,7 @@ enum GNUNET_TRANSPORT_ConnectionStatus {
188 * @param mtu maximum message size supported by queue, 0 if 216 * @param mtu maximum message size supported by queue, 0 if
189 * sending is not supported, SIZE_MAX for no MTU 217 * sending is not supported, SIZE_MAX for no MTU
190 * @param nt which network type does the @a address belong to? 218 * @param nt which network type does the @a address belong to?
219 * @param distance how many hops does this queue use (DV-only)?
191 * @param cs what is the connection status of the queue? 220 * @param cs what is the connection status of the queue?
192 * @param mq message queue of the @a peer 221 * @param mq message queue of the @a peer
193 * @return API handle identifying the new MQ 222 * @return API handle identifying the new MQ
@@ -198,6 +227,7 @@ GNUNET_TRANSPORT_communicator_mq_add (struct GNUNET_TRANSPORT_CommunicatorHandle
198 const char *address, 227 const char *address,
199 uint32_t mtu, 228 uint32_t mtu,
200 enum GNUNET_ATS_Network_Type nt, 229 enum GNUNET_ATS_Network_Type nt,
230 uint32_t distance,
201 enum GNUNET_TRANSPORT_ConnectionStatus cs, 231 enum GNUNET_TRANSPORT_ConnectionStatus cs,
202 struct GNUNET_MQ_Handle *mq); 232 struct GNUNET_MQ_Handle *mq);
203 233