(no commit message)
[oweals/gnunet.git] / src / transport / transport_selection.h
1 /*
2      This file is part of GNUnet.
3      (C) 2009 Christian Grothoff (and other contributing authors)
4
5      GNUnet is free software; you can redistribute it and/or modify
6      it under the terms of the GNU General Public License as published
7      by the Free Software Foundation; either version 3, or (at your
8      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      General Public License for more details.
14
15      You should have received a copy of the GNU General Public License
16      along with GNUnet; see the file COPYING.  If not, write to the
17      Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18      Boston, MA 02111-1307, USA.
19 */
20
21 /**
22  * @file transport/transport_selection.h
23  * @brief structure definition for automatic transport selection (ATS)
24  * @author Matthias Wachs
25  */
26
27 /**
28  *  The structs defined here are used by the transport plugin to tell ATS about the transport's properties like cost and quality
29  *  and on the other side the structs are used by highlevel components to communicate the constraints they have for a transport to ATS
30  *
31  *                             +---+
32  *  +-----------+ Constraints  |   |  Plugin properties +---------+
33  *  | Highlevel |------------> |ATS| <------------------|Transport|
34  *  | Component | ATS struct   |   |    ATS struct      | Plugin  |
35  *  +-----------+              |   |                    +---------+
36  *                             +---+
37  *
38  */
39
40 #define GNUNET_ATS_ARRAY_TERMINATOR 0
41
42 /**
43  * Enum defining all known property types for ATS
44  * Enum values are used in the GNUNET_ATS_Information struct as (key,value)-pair
45  * Cost are always stored in uint32_t, so all units used to define costs have to be normalized to fit in uint32_t [0 .. 4.294.967.295]
46  * To keep the elements ordered
47  *    1..1024 : Values with a relation to cost
48  * 1025..2048 : Values with a relation to quality
49  *
50  */
51 enum GNUNET_ATS_Property
52 {
53
54         /* Cost related values */
55         /* =================== */
56
57         /**
58          * Volume based cost in financial units to transmit data
59          *
60          * Note: This value is not bound to a specific currency or unit and only used locally
61          * "cent" just refers the smallest amount of money in the respective currency
62          *
63          * Unit: [cent/MB]
64          *
65          * Interpretation: less is better
66          *
67          * Examples:
68          * LAN:  0 [cent/MB]
69          * 2G : 10 [cent/MB]
70          */
71         GNUNET_ATS_COST_FINANCIAL_PER_VOLUME = 1,
72
73         /**
74          * Time based cost in financial units to transmit data
75          *
76          * Note: This value is not bound to a specific currency or unit and only used locally
77          * "cent" just refers the smallest amount of money in the respective currency
78          *
79          * Unit: [cent/h]
80          *
81          * Interpretation: less is better
82          *
83          * Examples:
84          * LAN   :  0 [cent/h]
85          * Dialup: 10 [cent/h]
86          */
87         GNUNET_ATS_COST_FINANCIAL_PER_TIME = 2,
88
89         /**
90          * Computational costs
91          *
92          * Effort of preparing data to be sent with this transport
93          * Includes encoding, encryption and conversion of data
94          * Partial values can be summed up: c_sum = c_enc + c_enc + c_conv
95          * Resulting values depend on local system properties, e.g. CPU
96          *
97          * Unit: [ms/GB]
98          *
99          * Interpretation: less is better
100          *
101          * Examples:
102          *
103          * HTTPS with AES CBC-256:      7,382
104          * HTTPS with AES CBC-128:      5,279
105          * HTTPS with RC4-1024:         2,652
106          */
107         GNUNET_ATS_COST_COMPUTATIONAL = 3,
108
109         /**
110          * Energy consumption
111          *
112          * Energy consumption using this transport when sending with a certain power at a certain bitrate
113          * This is only an approximation based on:
114          * Energy consumption E = P / D
115          *
116          * with:
117          * Power P in Watt (J/s)
118          * Datarate D in MBit/s
119          *
120          * Conversion between power P and dBm used by WLAN in radiotap's dBm TX power:
121          *
122          * Lp(dbm) = 10 log10 (P/ 1mW)
123          *
124          * => P = 1 mW  * 10^(Lp(dbm)/10)
125          *
126          * Unit: [mJ/MB]
127          *
128          * Interpretation: less is better
129          *
130          * Examples:
131          *
132          * LAN:       0
133          * WLAN:      89 (600 mW @ 802.11g /w 54 MBit/s)
134          * Bluetooth: 267 (100 mW @ BT2.0 EDR /w 3 MBit/s)
135          */
136         GNUNET_ATS_COST_ENERGY_CONSUMPTION = 4,
137
138         /* Connect cost
139          * How many bytes are transmitted to initiate a new connection using this transport?
140          *
141          * Unit: [bytes]
142          *
143          * Interpretation: less is better
144          *
145          * Examples:
146          *
147          * UDP (No connection)      :    0 bytes
148          * TCP (TCP 3-Way handshake):  220 bytes Ethernet,  172 bytes TCP/IP,  122 bytes TCP
149          * HTTP (TCP + Header)      :  477 bytes Ethernet,  429 bytes TCP/IP,  374 bytes TCP,  278 bytes HTTP
150          * HTTPS  HTTP+TLS Handshake: 2129 bytes Ethernet, 1975 bytes TCP/IP, 1755 bytes TCP, 1403 bytes HTTPS
151          *
152          * */
153         GNUNET_ATS_COST_CONNECT = 5,
154
155         /* Bandwidth cost
156          * How many bandwidth is available to consume?
157          * Used to calculate which impact sending data with this transport has
158          *
159          * Unit: [kB/s]
160          *
161          * Interpretation: more is better
162          *
163          * Examples:
164          * LAN:     12,800  (100 MBit/s)
165          * WLAN:    6,912   (54 MBit/s)
166          * Dial-up: 8       (64 Kbit/s)
167          *
168          */
169         GNUNET_ATS_COST_BANDWITH_AVAILABLE = 6,
170
171         /* Network overhead
172          * How many bytes are sent over the wire when 1 kilobyte (1024 bytes) of application data is transmitted?
173          * A factor used with connect cost, bandwidth cost and energy cost to describe the overhead produced by the transport protocol
174          *
175          * Unit: [bytes/kb]
176          *
177          * Interpretation: less is better
178          *
179          * Examples:
180          *
181          * TCP/IPv4 over Ethernet: 1024 + 38 + 20 + 20 = 1102 [bytes/kb]
182          * TCP/IPv6 over Ethernet: 1024 + 38 + 20 + 40 = 1122 [bytes/kb]
183          * UDP/IPv4 over Ethernet: 1024 + 38 + 20 + 8  = 1090 [bytes/kb]
184          * UDP/IPv6 over Ethernet: 1024 + 38 + 40 + 8  = 1110 [bytes/kb]
185          */
186         GNUNET_ATS_COST_NETWORK_OVERHEAD = 7,
187
188
189         /* Quality related values */
190         /* ====================== */
191
192     /* Physical layer quality properties */
193
194         GNUNET_ATS_PHY_SIGNAL_STRENGTH = 1025,
195
196         GNUNET_ATS_PHY_COLLISION_RATE = 1026,
197
198         GNUNET_ATS_PHY_ERROR_RATE = 1027,
199
200     /* Network layer quality properties */
201
202         GNUNET_ATS_NET_DELAY = 1028,
203
204         GNUNET_ATS_NET_LOSSRATE = 1029,
205
206         GNUNET_ATS_NET_ERRORRATE = 1030,
207
208         GNUNET_ATS_NET_DROPRATE = 1031,
209
210         GNUNET_ATS_NET_JITTER = 1032,
211
212         GNUNET_ATS_NET_THROUGHPUT = 1033
213 };
214
215 /**
216  * This structure will be used by plugins to communicate costs to ATS or by higher level components to tell ATS their constraints
217  * Always a pair of (GNUNET_ATS_Property, uint32_t value)
218  * Value is always uint32_t, so all units used to define costs have to be normalized to fit uint32_t
219  */
220 struct GNUNET_ATS_Information
221 {
222         /**
223          * ATS property type
224          */
225         uint32_t type;
226
227         /**
228          * ATS property value
229          */
230         uint32_t value;
231 };
232
233