aboutsummaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2015-01-17 21:31:48 +0000
committerChristian Grothoff <christian@grothoff.org>2015-01-17 21:31:48 +0000
commitc76f29f898f6b1a73f33ce6d2578e06ce8e0a24e (patch)
tree4d9fbf87fa9d65b8b966b51739af96205943be8f /src/include
parentf6323d915af7494ecfeba39407d1c30dc06dc238 (diff)
downloadgnunet-c76f29f898f6b1a73f33ce6d2578e06ce8e0a24e.tar.gz
gnunet-c76f29f898f6b1a73f33ce6d2578e06ce8e0a24e.zip
use ATS functions to convert quality network type to string, instead of using string API
Diffstat (limited to 'src/include')
-rw-r--r--src/include/gnunet_ats_service.h304
1 files changed, 43 insertions, 261 deletions
diff --git a/src/include/gnunet_ats_service.h b/src/include/gnunet_ats_service.h
index c19fa40b6..8b1aaf5c7 100644
--- a/src/include/gnunet_ats_service.h
+++ b/src/include/gnunet_ats_service.h
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 (C) 2010,2011 Christian Grothoff (and other contributing authors) 3 (C) 2010-2015 Christian Grothoff (and other contributing authors)
4 4
5 GNUnet is free software; you can redistribute it and/or modify 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 6 it under the terms of the GNU General Public License as published
@@ -38,30 +38,53 @@
38/** 38/**
39 * ATS network types as array initializer 39 * ATS network types as array initializer
40 */ 40 */
41#define GNUNET_ATS_NetworkType {GNUNET_ATS_NET_UNSPECIFIED, GNUNET_ATS_NET_LOOPBACK, GNUNET_ATS_NET_LAN, GNUNET_ATS_NET_WAN, GNUNET_ATS_NET_WLAN, GNUNET_ATS_NET_BT} 41#define GNUNET_ATS_NetworkType { GNUNET_ATS_NET_UNSPECIFIED, GNUNET_ATS_NET_LOOPBACK, GNUNET_ATS_NET_LAN, GNUNET_ATS_NET_WAN, GNUNET_ATS_NET_WLAN, GNUNET_ATS_NET_BT }
42
42 43
43/** 44/**
44 * ATS network types as string array initializer 45 * Types of networks (with separate quotas) we support.
45 */ 46 */
46#define GNUNET_ATS_NetworkTypeString {"UNSPECIFIED", "LOOPBACK", "LAN", "WAN", "WLAN", "BLUETOOTH"}
47
48enum GNUNET_ATS_Network_Type 47enum GNUNET_ATS_Network_Type
49{ 48{
49 /**
50 * Category of last resort.
51 */
50 GNUNET_ATS_NET_UNSPECIFIED = 0, 52 GNUNET_ATS_NET_UNSPECIFIED = 0,
53
54 /**
55 * Loopback (same host).
56 */
51 GNUNET_ATS_NET_LOOPBACK = 1, 57 GNUNET_ATS_NET_LOOPBACK = 1,
58
59 /**
60 * Local area network.
61 */
52 GNUNET_ATS_NET_LAN = 2, 62 GNUNET_ATS_NET_LAN = 2,
63
64 /**
65 * Wide area network (i.e. Internet)
66 */
53 GNUNET_ATS_NET_WAN = 3, 67 GNUNET_ATS_NET_WAN = 3,
68
69 /**
70 * Wireless LAN (i.e. 802.11abgn)
71 */
54 GNUNET_ATS_NET_WLAN = 4, 72 GNUNET_ATS_NET_WLAN = 4,
73
74 /**
75 * Bluetooth LAN
76 */
55 GNUNET_ATS_NET_BT = 5 77 GNUNET_ATS_NET_BT = 5
56}; 78};
57 79
80
58/** 81/**
59 * Default bandwidth assigned to a network : 64 KB/s 82 * Default bandwidth assigned to a network : 64 KB/s
60 */ 83 */
61#define GNUNET_ATS_DefaultBandwidth 65536 84#define GNUNET_ATS_DefaultBandwidth 65536
62 85
63/** 86/**
64 * Undefined value for a GNUNET_ATS_Property 87 * Undefined value for an `enum GNUNET_ATS_Property`
65 */ 88 */
66#define GNUNET_ATS_VALUE_UNDEFINED UINT32_MAX 89#define GNUNET_ATS_VALUE_UNDEFINED UINT32_MAX
67 90
@@ -85,10 +108,6 @@ enum GNUNET_ATS_Network_Type
85 */ 108 */
86#define GNUNET_ATS_PropertyCount 11 109#define GNUNET_ATS_PropertyCount 11
87 110
88/**
89 * ATS properties types as string array initializer
90 */
91#define GNUNET_ATS_PropertyStrings {"TERMINATOR", "UTILIZATION_UP", "UTILIZATION_DOWN", "UTILIZATION_PAYLOAD_UP", "UTILIZATION_PAYLOAD_DOWN", "NETWORK_TYPE", "DELAY", "DISTANCE", "COST_WAN", "COST_LAN", "COST_WLAN"}
92 111
93/** 112/**
94 * Enum defining all known property types for ATS Enum values are used 113 * Enum defining all known property types for ATS Enum values are used
@@ -98,7 +117,7 @@ enum GNUNET_ATS_Network_Type
98 * Cost are always stored in uint32_t, so all units used to define costs 117 * Cost are always stored in uint32_t, so all units used to define costs
99 * have to be normalized to fit in uint32_t [0 .. UINT32_MAX-1] 118 * have to be normalized to fit in uint32_t [0 .. UINT32_MAX-1]
100 * 119 *
101 * UINT32_MAX is reserved for uninitialized values GNUNET_ATS_VALUE_UNDEFINED 120 * UINT32_MAX is reserved for uninitialized values #GNUNET_ATS_VALUE_UNDEFINED
102 */ 121 */
103enum GNUNET_ATS_Property 122enum GNUNET_ATS_Property
104{ 123{
@@ -125,7 +144,6 @@ enum GNUNET_ATS_Property
125 */ 144 */
126 GNUNET_ATS_UTILIZATION_IN, 145 GNUNET_ATS_UTILIZATION_IN,
127 146
128
129 /** 147 /**
130 * Actual traffic on this connection from this peer to the other peer. 148 * Actual traffic on this connection from this peer to the other peer.
131 * Only payload from layers > transport 149 * Only payload from layers > transport
@@ -231,248 +249,10 @@ enum GNUNET_ATS_Property
231 * UDP/IPv6 over Ethernet: 1024 + 38 + 40 + 8 = 1110 [bytes/kb] 249 * UDP/IPv6 over Ethernet: 1024 + 38 + 40 + 8 = 1110 [bytes/kb]
232 */ 250 */
233 GNUNET_ATS_COST_WLAN 251 GNUNET_ATS_COST_WLAN
234/* Cost related values */ 252
235/* =================== */
236/**
237 * Volume based cost in financial units to transmit data
238 *
239 * Note: This value is not bound to a specific currency or unit and only
240 * used locally.
241 * "cent" just refers the smallest amount of money in the respective
242 * currency.
243 *
244 * Unit: [cent/MB]
245 *
246 * Interpretation: less is better
247 *
248 * Examples:
249 * LAN: 0 [cent/MB]
250 * 2G : 10 [cent/MB]
251 */
252// GNUNET_ATS_COST_FINANCIAL_PER_VOLUME = 1,
253/**
254 * Time based cost in financial units to transmit data
255 *
256 * Note: This value is not bound to a specific currency or unit and only
257 * used locally.
258 * "cent" just refers the smallest amount of money in the respective
259 * currency.
260 *
261 * Unit: [cent/h]
262 *
263 * Interpretation: less is better
264 *
265 * Examples:
266 * LAN : 0 [cent/h]
267 * Dialup: 10 [cent/h]
268 */
269// GNUNET_ATS_COST_FINANCIAL_PER_TIME = 2,
270/**
271 * Computational costs
272 *
273 * Effort of preparing data to be sent with this transport
274 * Includes encoding, encryption and conversion of data
275 * Partial values can be summed up: c_sum = c_enc + c_enc + c_conv
276 * Resulting values depend on local system properties, e.g. CPU
277 *
278 * Unit: [ms/GB]
279 *
280 * Interpretation: less is better
281 *
282 * Examples:
283 *
284 * HTTPS with AES CBC-256: 7,382
285 * HTTPS with AES CBC-128: 5,279
286 * HTTPS with RC4-1024: 2,652
287 */
288// GNUNET_ATS_COST_COMPUTATIONAL = 3,
289/**
290 * Energy consumption
291 *
292 * Energy consumption using this transport when sending with a certain
293 * power at a certain bitrate. This is only an approximation based on:
294 * Energy consumption E = P / D
295 *
296 * with:
297 * Power P in Watt (J/s)
298 * Datarate D in MBit/s
299 *
300 * Conversion between power P and dBm used by WLAN in radiotap's dBm TX power:
301 *
302 * Lp(dbm) = 10 log10 (P/ 1mW)
303 *
304 * => P = 1 mW * 10^(Lp(dbm)/10)
305 *
306 * Unit: [mJ/MB]
307 *
308 * Interpretation: less is better
309 *
310 * Examples:
311 *
312 * LAN: 0
313 * WLAN: 89 (600 mW @ 802.11g /w 54 MBit/s)
314 * Bluetooth: 267 (100 mW @ BT2.0 EDR /w 3 MBit/s)
315 */
316// GNUNET_ATS_COST_ENERGY_CONSUMPTION = 4,
317/**
318 * Connect cost
319 * How many bytes are transmitted to initiate a new connection using
320 * this transport?
321 *
322 * Unit: [bytes]
323 *
324 * Interpretation: less is better
325 *
326 * Examples:
327 *
328 * UDP (No connection) :
329 * 0 bytes
330 * TCP (TCP 3-Way handshake):
331 * 220 bytes Ethernet, 172 bytes TCP/IP, 122 bytes TCP
332 * HTTP (TCP + Header) :
333 * 477 bytes Ethernet, 429 bytes TCP/IP, 374 bytes TCP, 278 bytes HTTP
334 * HTTPS HTTP+TLS Handshake:
335 * 2129 bytes Ethernet, 1975 bytes TCP/IP, 1755 bytes TCP, 1403 bytes HTTPS
336 *
337 * */
338// GNUNET_ATS_COST_CONNECT = 5,
339/**
340 * Bandwidth cost
341 *
342 * How many bandwidth is available to consume?
343 * Used to calculate which impact sending data with this transport has
344 *
345 * Unit: [kB/s]
346 *
347 * Interpretation: more is better
348 *
349 * Examples:
350 * LAN: 12,800 (100 MBit/s)
351 * WLAN: 6,912 (54 MBit/s)
352 * Dial-up: 8 (64 Kbit/s)
353 *
354 */
355// GNUNET_ATS_COST_BANDWITH_AVAILABLE = 6,
356/**
357 * Network overhead
358 *
359 * How many bytes are sent over the wire when 1 kilobyte (1024 bytes)
360 * of application data is transmitted?
361 * A factor used with connect cost, bandwidth cost and energy cost
362 * to describe the overhead produced by the transport protocol
363 *
364 * Unit: [bytes/kb]
365 *
366 * Interpretation: less is better
367 *
368 * Examples:
369 *
370 * TCP/IPv4 over Ethernet: 1024 + 38 + 20 + 20 = 1102 [bytes/kb]
371 * TCP/IPv6 over Ethernet: 1024 + 38 + 20 + 40 = 1122 [bytes/kb]
372 * UDP/IPv4 over Ethernet: 1024 + 38 + 20 + 8 = 1090 [bytes/kb]
373 * UDP/IPv6 over Ethernet: 1024 + 38 + 40 + 8 = 1110 [bytes/kb]
374 */
375// GNUNET_ATS_COST_NETWORK_OVERHEAD = 7,
376/* Quality related values */
377/* ====================== */
378/* Physical layer quality properties */
379/**
380 * Signal strength on physical layer
381 *
382 * Unit: [dBm]
383 */
384// GNUNET_ATS_QUALITY_PHY_SIGNAL_STRENGTH = 1025,
385/**
386 * Collision rate on physical layer
387 *
388 * Unit: [B/s]
389 */
390// GNUNET_ATS_QUALITY_PHY_COLLISION_RATE = 1026,
391/**
392 * Error rate on physical layer
393 *
394 * Unit: [B/s]
395 */
396// GNUNET_ATS_QUALITY_PHY_ERROR_RATE = 1027,
397/**
398 * Jitter
399 * Time variations of the delay
400 * 1st derivative of a delay function
401 *
402 * Unit: [ms]
403 */
404// GNUNET_ATS_QUALITY_NET_JITTER = 1029,
405/**
406 * Error rate on network layer
407 *
408 * Unit: [B/s]
409 *
410 * Examples:
411 *
412 * LAN : 0
413 * WLAN : 400
414 * Bluetooth : 100
415 * Note: This numbers are just assumptions as an example, not
416 * measured or somehow determined
417 */
418// GNUNET_ATS_QUALITY_NET_ERRORRATE = 1030,
419/**
420 * Drop rate on network layer
421 * Bytes actively dismissed by a network component during transmission
422 * Reasons for dropped data can be full queues, congestion, quota violations...
423 *
424 * Unit: [B/s]
425 *
426 * Examples:
427 *
428 * LAN : 0
429 * WLAN : 400
430 * Bluetooth : 100
431 * Note: This numbers are just assumptions as an example, not
432 * measured or somehow determined
433 */
434// GNUNET_ATS_QUALITY_NET_DROPRATE = 1031,
435/**
436 * Loss rate on network layer
437 * Bytes lost during transmission
438 * Reasons can be collisions, ...
439 *
440 * Unit: [B/s]
441 *
442 * Examples:
443 *
444 * LAN : 0
445 * WLAN : 40
446 * Bluetooth : 10
447 * Note: This numbers are just assumptions as an example, not measured
448 * or somehow determined
449 */
450// GNUNET_ATS_QUALITY_NET_LOSSRATE = 1032,
451/**
452 * Throughput on network layer
453 *
454 * Unit: [kB/s]
455 *
456 * Examples:
457 *
458 * LAN : 3400
459 * WLAN : 1200
460 * Dialup: 4
461 *
462 */
463// GNUNET_ATS_QUALITY_NET_THROUGHPUT = 1033,
464/* Availability related values */
465/* =========================== */
466/**
467 * Is a peer reachable?
468 */
469// GNUNET_ATS_AVAILABILITY_REACHABLE = 2048,
470/**
471 * Is there a connection established to a peer using this transport
472 */
473// GNUNET_ATS_AVAILABILITY_CONNECTED = 2049
474}; 253};
475 254
255
476/** 256/**
477 * Number of ATS quality properties 257 * Number of ATS quality properties
478 */ 258 */
@@ -481,7 +261,7 @@ enum GNUNET_ATS_Property
481/** 261/**
482 * ATS quality properties as array initializer 262 * ATS quality properties as array initializer
483 */ 263 */
484#define GNUNET_ATS_QualityProperties {GNUNET_ATS_QUALITY_NET_DELAY, GNUNET_ATS_QUALITY_NET_DISTANCE} 264#define GNUNET_ATS_QualityProperties { GNUNET_ATS_QUALITY_NET_DELAY, GNUNET_ATS_QUALITY_NET_DISTANCE }
485 265
486/** 266/**
487 * ATS quality properties as string array initializer 267 * ATS quality properties as string array initializer
@@ -559,7 +339,8 @@ struct Session;
559typedef void 339typedef void
560(*GNUNET_ATS_AddressSuggestionCallback) (void *cls, 340(*GNUNET_ATS_AddressSuggestionCallback) (void *cls,
561 const struct GNUNET_PeerIdentity *peer, 341 const struct GNUNET_PeerIdentity *peer,
562 const struct GNUNET_HELLO_Address *address, struct Session *session, 342 const struct GNUNET_HELLO_Address *address,
343 struct Session *session,
563 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, 344 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out,
564 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, 345 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
565 const struct GNUNET_ATS_Information *ats, uint32_t ats_count); 346 const struct GNUNET_ATS_Information *ats, uint32_t ats_count);
@@ -589,7 +370,7 @@ GNUNET_ATS_scheduling_done (struct GNUNET_ATS_SchedulingHandle *sh);
589 370
590/** 371/**
591 * We would like to reset the address suggestion block time for this 372 * We would like to reset the address suggestion block time for this
592 * peer 373 * peer.
593 * 374 *
594 * @param sh handle 375 * @param sh handle
595 * @param peer identity of the peer we want to reset 376 * @param peer identity of the peer we want to reset
@@ -630,25 +411,26 @@ GNUNET_ATS_suggest_address_cancel (struct GNUNET_ATS_SchedulingHandle *sh,
630/** 411/**
631 * Convert a ATS property to a string 412 * Convert a ATS property to a string
632 * 413 *
633 * @param type the atsi type 414 * @param type the property type
634 * @return a string or NULL if invalid 415 * @return a string or NULL if invalid
635 */ 416 */
636const char * 417const char *
637GNUNET_ATS_print_property_type (uint32_t type); 418GNUNET_ATS_print_property_type (enum GNUNET_ATS_Property type);
638 419
639 420
640/** 421/**
641 * Convert a GNUNET_ATS_NetworkType to a string 422 * Convert a `enum GNUNET_ATS_Network_Type` to a string
642 * 423 *
643 * @param net the network type 424 * @param net the network type
644 * @return a string or NULL if invalid 425 * @return a string or NULL if invalid
645 */ 426 */
646const char * 427const char *
647GNUNET_ATS_print_network_type (uint32_t net); 428GNUNET_ATS_print_network_type (enum GNUNET_ATS_Network_Type net);
648 429
649 430
650/** 431/**
651 * Returns where the address is located: LAN or WAN or ... 432 * Returns where the address is located: LAN or WAN or ...
433 *
652 * @param sh the `struct GNUNET_ATS_SchedulingHandle` handle 434 * @param sh the `struct GNUNET_ATS_SchedulingHandle` handle
653 * @param addr address 435 * @param addr address
654 * @param addrlen address length 436 * @param addrlen address length
@@ -656,12 +438,12 @@ GNUNET_ATS_print_network_type (uint32_t net);
656 */ 438 */
657struct GNUNET_ATS_Information 439struct GNUNET_ATS_Information
658GNUNET_ATS_address_get_type (struct GNUNET_ATS_SchedulingHandle *sh, 440GNUNET_ATS_address_get_type (struct GNUNET_ATS_SchedulingHandle *sh,
659 const struct sockaddr * addr, 441 const struct sockaddr *addr,
660 socklen_t addrlen); 442 socklen_t addrlen);
661 443
662 444
663/** 445/**
664 * Test if a address and a session is known to ATS 446 * Test if a address and a session is known to ATS.
665 * 447 *
666 * @param sh the scheduling handle 448 * @param sh the scheduling handle
667 * @param address the address 449 * @param address the address