redefinition of enum value broke compilation
[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 transprot 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  * Enum defining all known cost types for ATS
43  * Enum values are used in the GNUNET_ATS_Cost_Information struct as (key,value)-pair
44  * 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]
45  */
46 enum GNUNET_ATS_Cost_Type
47 {
48         /*
49          * Cost will be passed as struct GNUNET_ATS_Cost_Information[]
50          * array is 0-terminated:
51          * the last element in the array is the pair (GNUNET_ATS_ARRAY_TERMINATOR, 0)
52          */
53         //GNUNET_ATS_ARRAY_TERMINATOR= 0,
54
55         /* Volume based cost in financial units to transmit data
56          * Note: this value is not bound to a specific currency or unit and only used locally
57          *
58          * Unit: [1/MB]
59          *
60          * Interpretation: less is better
61          *
62          * Examples:
63          * LAN: 0
64          * 2G:  10
65          */
66         GNUNET_ATS_FINANCIAL_PER_VOLUME_COST = 1,
67
68         /* Time based cost in financial units to transmit data
69          * Note: this value is not bound to a specific currency or unit
70          *
71          * Unit: [1/h]
72          *
73          * Interpretation: less is better
74          *
75          * Examples:
76          * LAN: 0
77          * Dialup: 10
78          */
79         GNUNET_ATS_FINANCIAL_PER_TIME_COST = 2,
80
81         /* Computational costs
82          * Effort of preparing data to send with this transport
83          * Includes encoding, encryption and conversion of data
84          * Partial values can be summed: c_sum = c_enc + c_conv + c_enc
85          * Resulting value depends on local system properties, e.g. CPU
86          *
87          * Unit: [ms/GB]
88          *
89          * Interpretation: less is better
90          *
91          * Examples:
92          *
93          * HTTPS with AES CBC-256:      7,382
94          * HTTPS with AES CBC-128:      5,279
95          * HTTPS with RC4-1024:         2,652
96          */
97         GNUNET_ATS_COMPUTATIONAL_COST = 3,
98
99         /* Energy consumption
100          * Energy consumption using this transport when sending with a certain power at a certain bitrate
101          * This is only an approximation based on:
102          * Energy consumption E = P / D
103          *
104          * with:
105          * Power P in Watt (J/s)
106          * Datarate D in MBit/s
107          *
108          * Conversion between power P and dBm used by WLAN in radiotap's dBm TX power:
109          *
110          * Lp(dbm) = 10 log10 (P/ 1mW)
111          *
112          * => P = 1 mW  * 10^(Lp(dbm)/10)
113          *
114          * Unit: [mJ/MB]
115          *
116          * Interpretation: less is better
117          *
118          * Examples:
119          *
120          * LAN:       0
121          * WLAN:      89 (600 mW @ 802.11g /w 54 MBit/s)
122          * Bluetooth: 267 (100 mW @ BT2.0 EDR /w 3 MBit/s)
123          */
124         GNUNET_ATS_ENERGY_CONSUMPTION = 4,
125
126         /* Connect cost
127          * How expensive is it to initiate a new connection using this transport
128          *
129          * Unit: [bytes]
130          *
131          * Interpretation: less is better
132          *
133          * Examples:
134          *
135          * UDP (No connection)      :    0 bytes
136          * TCP (TCP 3-Way handshake):  220 bytes Ethernet,  172 bytes TCP/IP,  122 bytes TCP
137          * HTTP (TCP + Header)      :  477 bytes Ethernet,  429 bytes TCP/IP,  374 bytes TCP,  278 bytes HTTP
138          * HTTPS  HTTP+TLS Handshake: 2129 bytes Ethernet, 1975 bytes TCP/IP, 1755 bytes TCP, 1403 bytes HTTPS
139          *
140          * */
141         GNUNET_ATS_CONNECT_COST = 5,
142
143         /* Bandwidth cost
144          * How many bandwidth is available to consume
145          * Used to calculate which impact sending data with this transport has
146          *
147          * Unit: [kB/s]
148          *
149          * Interpretation: more is better
150          *
151          * Examples:
152          * LAN:     12,800  (100 MBit/s)
153          * WLAN:    6,912   (54 MBit/s)
154          * Dial-up: 8       (64 Kbit/s)
155          *
156          */
157         GNUNET_ATS_BANDWITH_COST = 6,
158
159         /* Network overhead
160          * a factor used with connect cost, bandwidth cost and energy cost to describe the overhead produced by the transport protocol
161          *
162          * Unit: [10,000 - (Efficiency in Percent * 100)]
163          *
164          * Interpretation: less is better
165          *
166          * Examples:
167          *
168          * TCP/IPv4 over Ethernet: 507 (Efficiency: 94,93 %)
169          * TCP/IPv6 over Ethernet: 646 (Efficiency: 93,64 %)
170          * UDP/IPv4 over Ethernet: 429 (Efficiency: 95,71 %)
171          * UDP/IPv6 over Ethernet: 559 (Efficiency: 94,41 %)
172          */
173         GNUNET_ATS_NETWORK_OVERHEAD_COST = 7,
174 };
175
176 /**
177  * This structure will be used by plugins to communicate costs to ATS or by higher level components to tell ATS their constraints
178  * Always a pair of (GNUNET_ATS_Cost_Types, uint32_t value)
179  * Value is always uint32_t, so all units used to define costs have to be normalized to fit uint32_t
180  */
181 struct GNUNET_ATS_Cost_Information
182 {
183         /**
184          * ATS Cost Type
185          */
186         uint32_t cost_type;
187
188         /**
189          * ATS Cost value
190          */
191         uint32_t cost_value;
192 };
193
194 /**
195  * Enum defining all known quality types for ATS
196  * Enum values are used in the GNUNET_ATS_Cost_Information struct as (key,value)-pair
197  * 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]
198  */
199
200 enum GNUNET_ATS_Quality_Type
201 {
202     /*
203      * Quality will be passed as struct GNUNET_ATS_Quality_Information[]
204      * array is 0-terminated:
205      * the last element in the array is the pair (GNUNET_ATS_ARRAY_TERMINATOR, 0)
206      */
207     //GNUNET_ATS_ARRAY_TERMINATOR = 0,
208
209     /* Physical layer quality properties */
210
211         GNUNET_ATS_PHY_SIGNAL_STRENGTH = 1,
212
213         GNUNET_ATS_PHY_COLLISION_RATE = 2,
214
215         GNUNET_ATS_PHY_ERROR_RATE = 3,
216
217     /* Network layer quality properties */
218
219         GNUNET_ATS_NET_DELAY = 4,
220
221         GNUNET_ATS_NET_LOSSRATE = 5,
222
223         GNUNET_ATS_NET_ERRORRATE = 6,
224
225         GNUNET_ATS_NET_DROPRATE = 6,
226
227         GNUNET_ATS_NET_JITTER = 6,
228
229         GNUNET_ATS_NET_THROUGHPUT = 7,
230 };
231
232 /**
233  * This structure will be used by plugins to communicate quality to ATS or by higher level components to tell ATS their
234  * quality constraints
235  *
236  * Always a pair of (GNUNET_ATS_Quality_Type, uint32_t value)
237  * Value is always uint32_t, so all units used to define quality values have to be normalized to fit uint32_t
238  */
239 struct GNUNET_ATS_Quality_Information
240 {
241         /**
242          * ATS Quality Type
243          */
244         uint32_t quality_type;
245
246         /**
247          * ATS Quality value
248          */
249         uint32_t quality_value;
250 };
251