From e4c39d9e509d67f84093adbe879d96f0e0808d0b Mon Sep 17 00:00:00 2001 From: Matthias Wachs Date: Mon, 18 Feb 2013 15:39:20 +0000 Subject: [PATCH] docu --- src/ats/gnunet-service-ats_addresses.c | 251 +++++++++++++++---------- 1 file changed, 153 insertions(+), 98 deletions(-) diff --git a/src/ats/gnunet-service-ats_addresses.c b/src/ats/gnunet-service-ats_addresses.c index e52506dfe..3cb119278 100644 --- a/src/ats/gnunet-service-ats_addresses.c +++ b/src/ats/gnunet-service-ats_addresses.c @@ -41,136 +41,191 @@ * gnunet.org:/vcs/fsnsg/ats-paper.git/tech-doku/ats-tech-guide.tex * use build_txt.sh to generate plaintext output * - * ATS addresses : ATS address management + * 1 ATS addresses : ATS address management * - * - General + * This ATS addresses ("addresses") component manages the addresses known to + * ATS service and suggests addresses to transport service when it is + * interested in address suggestion for a peer. ATS addresses also + * instantiates the bandwidth assignment mechanism (solver), notifies it + * about changes to addresses and forwards changes to bandwidth assignments + * to transport, depending if transport is interested in this change. * - * This ATS addresses ("addresses") component manages the addresses known to ATS - * service and suggests addresses to transport service when it is interested in - * address suggestion for a peer. ATS addresses also instantiates the bandwidth assignment - * mechanism (solver), notifies it about changes to addresses and forwards changes - * to bandwidth assignments to transport, depending if transport is interested - * in this change. ATS calculates bandwidth assigned depending on the network - * address - * All addresses belong to one of the networks ATS defines. + * 1.1 Input data * - * - Input data - * Here a short description of the input data used for ATS + * 1.1.1 Addresses * - * -- Addresses - * Addresses are added by specifying peer ID, plugin, address, address length - * and session, if available. ATS information can be specified if available. + * Addresses are added by specifying peer ID, plugin, address, address length + * and session, if available. ATS information can be specified if available. * - * -- Networks + * 1.1.2 Networks * + * ATS specifies a fix set of networks an address can belong to. For each + * network an inbound and outbound quota will be specified. The available + * networks and addtional helper varaibles are defined in + * gnunet_ats_service.h. At the moment 5 networks are defined: + * * GNUNET_ATS_NET_UNSPECIFIED + * * GNUNET_ATS_NET_LOOPBACK + * * GNUNET_ATS_NET_LAN + * * GNUNET_ATS_NET_WAN + * * GNUNET_ATS_NET_WLAN * + * The total number of networks defined is stored in + * GNUNET_ATS_NetworkTypeCount GNUNET_ATS_NetworkType can be used array + * initializer for an int array, while GNUNET_ATS_NetworkType is an + * initializer for a char array containing a string description of all + * networks * - * -- Quotas + * 1.1.3 Quotas * - * -- Preference values + * An inbound and outbound quota for each of the networks mentioned in 1.1.2 + * is loaded from ats configuration during initialization. This quota defines + * to total amount of inbound and outbound traffic allowed for a specific + * network. The configuration values used are in section ats: + * * _QUOTA_IN = + * * _QUOTA_IN = * + * You can specify quotas by setting the to a: + * * unrestricted: unlimited + * * number of bytes: e.g. 10240 + * * fancy value: e.g. 64 Kib * - * - Initialization - * During initialization a hashmap to store addresses is created. The most - * important step is to load the configured solver using configuration - * "[ats]:MODE". Current solvers are MODE_SIMPLISTIC, MODE_MLP. Interaction - * is done using a solver API + * unlimited is defined as GNUNET_ATS_MaxBandwidthString and equivalent to + * the value GNUNET_ATS_MaxBandwidth Important predefined values for quotas + * are: + * * GNUNET_ATS_DefaultBandwidth: 65536 + * * GNUNET_ATS_MaxBandwidth: UINT32_MAX + * * GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT: 1024 * + * Details of loading quotas and default values will be described on * - * - Loading quotas - * FIXME + * 1.1.4 Preference values * + * 1.2 Data structures used * - * - Solver API + * Addresse uses struct ATS_Address for each address. The structs are stored + * in a linked list and provides a pointer void *solver_information for the + * solver to store address specific information. It provides the int values + * active which is set to GNUNET_YES if the address is select for transport + * use and used, representing that transport service is actively using this + * address. Address information are stored in peer, addr, addr_len, plugin. * - * Solver functions: - * s_init: init the solver with required information - * s_add: add a new address - * s_update: update ATS values or session for an address - * s_get: get prefered address for a peer - * s_del: delete an address - * s_pref: change preference value for a peer - * s_done: shutdown solver - * Callbacks: - * addresses provides a bandwidth_changed_cb callback to the solver which is - * called when bandwidth assigned to peer has changed + * 1.3 Initialization * - * - Shutdown - * During shutdown all addresses are freed and the solver told to shutdown + * During initialization a hashmap to store addresses is created. The quotas + * for all networks defined for ATS are loaded from configuration. For each + * network first the logic will check if the string + * GNUNET_ATS_MaxBandwidthString is configured, if not it will try to convert + * the configured value as a fancy size and if this fails it will try to use + * it as a value_number. If no configuration value is found it will assign + * GNUNET_ATS_DefaultBandwidth. The most important step is to load the + * configured solver using configuration "[ats]:MODE". Current solvers are + * MODE_SIMPLISTIC, MODE_MLP. Interaction is done using a solver API * - * - Address management: - * Transport service notifies ATS about changes to the addresses known to him. + * 1.4 Solver API * - * -- Addresses and sessions - * Addresses consist of the address itself and a numerical session. - * When a new address without a session is added it has no session, so it gets - * session 0 assigned. When an address with a session is added and an address - * object with session 0 is found, this object is updated with the - * session otherwise a new address object with this session assigned is created. + * Solver functions: + * * s_init: init the solver with required information + * * s_add: add a new address + * * s_update: update ATS values or session for an address + * * s_get: get prefered address for a peer + * * s_del: delete an address + * * s_pref: change preference value for a peer + * * s_done: shutdown solver * - * Terminology: - * Addresses a1,a2 with session s1, s2 are "exact" if: - * (a1 == a2) && (s1 == s2) - * Addresses a1,a2 with session s1, s2 are "equivalent" if: - * (a1 == a2) && ((s1 == s2) || (s1 == 0) || (s2 ==0) + * Callbacks: addresses provides a bandwidth_changed_cb callback to the + * solver which is called when bandwidth assigned to peer has changed * - * -- Adding an address: - - * When transport learns a new address it tells ATS and ATS is telling addresses - * about it using GAS_address_add. If not known to addresses it creates a new - * address object and calls solver's s_add. ATS information are deserialized - * and solver is notified about the session and ATS information using s_update. + * 1.5 Shutdown + * + * During shutdown all addresses are freed and the solver told to shutdown + * + * 1.6 Addresses and sessions + * + * Addresses consist of the address itself and a numerical session. When a + * new address without a session is added it has no session, so it gets + * session 0 assigned. When an address with a session is added and an address + * object with session 0 is found, this object is updated with the session + * otherwise a new address object with this session assigned is created. + * + * 1.6.1 Terminology + * + * Addresses a1,a2 with session s1, s2 are "exact" if: + * (a1 == a2)&&(s1 == s2) + * Addresses a1,a2 with session s1, s2 are "equivalent" if: + * (a1 == a2)&&((s1 == s2)||(s1 == 0)||(s2 == 0) + * + * 1.7 Address management + * + * Transport service notifies ATS about changes to the addresses known to + * him. + * + * 1.7.1 Adding an address * - * -- Updating an address - * Addresses does an lookup up for the existing address with the given session. - * If disassembles included ATS information and notifies the solver using - * s_update about the update. + * When transport learns a new address it tells ATS and ATS is telling + * addresses about it using GAS_address_add. If not known to addresses it + * creates a new address object and calls solver's s_add. ATS information are + * deserialized and solver is notified about the session and ATS information + * using s_update. * - * -- Deleting an address - * Addresses does an lookup for the exact address and session and if removes - * this address. If session != 0 the session is set to 0 and the address is - * kept. If session == 0, the addresses is removed. + * 1.7.2 Updating an address * - * -- Requesting an address suggestion - * The address client issues a request address message to be notified about - * address suggestions for a specific peer. Addresses asks the solver with s_get. - * If no address is available, it will not send a response, otherwise it will - * respond with the choosen address. + * Addresses does an lookup up for the existing address with the given + * session. If disassembles included ATS information and notifies the solver + * using s_update about the update. * - * -- Address suggestions - * Addresses will notify the client automatically on any bandwidth_changed_cb - * by the solver if a address suggestion request is pending. If no address is - * available it will not respond at all If the client is not interested anymore, - * it has to cancel the address suggestion request. + * 1.7.3 Deleting an address * - * -- Suggestions blocks and reset - * After suggesting an address it is blocked for ATS_BLOCKING_DELTA sec. to - * prevent the client from being thrashed. If the client requires immediately - * it can reset this block using GAS_addresses_handle_backoff_reset. + * Addresses does an lookup for the exact address and session and if removes + * this address. If session != 0 the session is set to 0 and the address is + * kept. If session == 0, the addresses is removed. * - * -- Address in use - * The client can notify addresses that it successfully uses an address and - * wants this address to be kept by calling GSA_address_in_use. Adresses - * will mark the address as used an notify the solver about the use. + * 1.7.4 Requesting an address suggestion * - * - Bandwidth assignment + * The address client issues a request address message to be notified about + * address suggestions for a specific peer. Addresses asks the solver with + * s_get. If no address is available, it will not send a response, otherwise + * it will respond with the choosen address. * - * The addresses are used to perform resource allocation operations. ATS - * addresses takes care of instantiating the solver configured and notifies the - * respective solver about address changes and receives changes to the bandwidth - * assignment from the solver. The current bandwidth assignment is sent to - * transport. The specific solvers will be described in the specific section. + * 1.7.5 Address suggestions * - * Address lifecycle: + * Addresses will notify the client automatically on any bandwidth_changed_cb + * by the solver if a address suggestion request is pending. If no address is + * available it will not respond at all If the client is not interested + * anymore, it has to cancel the address suggestion request. * - * - (add address) - * - (updated address) || (address in use) - * - (delete address) + * 1.7.6 Suggestions blocks and reset * - * - Changing peer preferences - * The bandwidth assigned to a peer can be influenced by setting a preference - * for a peer. The prefernce will be given to to the solver with s_pref which - * has to take care of the preference value + * After suggesting an address it is blocked for ATS_BLOCKING_DELTA sec. to + * prevent the client from being thrashed. If the client requires immediately + * it can reset this block using GAS_addresses_handle_backoff_reset. + * + * 1.7.7 Marking address in use + * + * The client can notify addresses that it successfully uses an address and + * wants this address to be kept by calling GSA_address_in_use. Adresses will + * mark the address as used an notify the solver about the use. + * + * 1.7.8 Address lifecycle + * + * * (add address) + * * (updated address) || (address in use) + * * (delete address) + * + * 1.8 Bandwidth assignment + * + * The addresses are used to perform resource allocation operations. ATS + * addresses takes care of instantiating the solver configured and notifies + * the respective solver about address changes and receives changes to the + * bandwidth assignment from the solver. The current bandwidth assignment is + * sent to transport. The specific solvers will be described in the specific + * section. + * + * 1.9 Changing peer preferences + * + * The bandwidth assigned to a peer can be influenced by setting a preference + * for a peer. The prefernce will be given to to the solver with s_pref which + * has to take care of the preference value + */ -- 2.25.1