41 #define INTERFACE_PROCESSING_INTERVAL GNUNET_TIME_relative_multiply ( \ 42 GNUNET_TIME_UNIT_MINUTES, 2) 44 #define LOG(kind, ...) GNUNET_log_from (kind, "ats-scheduling-api", __VA_ARGS__) 257 (i < sh->session_array_size))
403 "ATS suggests disconnect from peer `%s' with BW %u/%u\n",
425 "ATS suggests address slot %u for peer `%s' using plugin %s\n",
452 "ATS connection died (code %d), reconnecting\n",
489 "Adding address for peer `%s', plugin `%s', session %p slot %u\n",
603 if (NULL != sh->
task)
752 "Updating address for peer `%s', plugin `%s', session %p slot %u\n",
784 "Deleting address for peer `%s', plugin `%s', slot %u session %p\n",
#define GNUNET_MESSAGE_TYPE_ATS_ADDRESS_DESTROYED
Type of the 'struct AddressDestroyedMessage' sent by clients to ATS to inform ATS about an address be...
static struct GNUNET_ATS_AddressRecord * find_session(struct GNUNET_ATS_SchedulingHandle *sh, uint32_t session_id, const struct GNUNET_PeerIdentity *peer)
Find the session object corresponding to the given session ID.
size_t address_length
Number of bytes in address.
struct GNUNET_SCHEDULER_Task * task
Task to trigger reconnect.
uint16_t address_length
Number of bytes in the address that follows this struct.
enum GNUNET_HELLO_AddressInfo local_info
Extended information about address.
#define GNUNET_MESSAGE_TYPE_ATS_START
Type of the 'struct ClientStartMessage' sent by clients to ATS to identify the type of the client...
static void send_add_address_message(struct GNUNET_ATS_SchedulingHandle *sh, const struct GNUNET_ATS_AddressRecord *ar)
Generate and transmit the struct AddressAddMessage for the given address record.
struct GNUNET_PeerIdentity peer
Which peer is this about? (Technically redundant, as the session_id should be sufficient, but enables ATS service to find the session faster).
struct GNUNET_ATS_AddressRecord ** session_array
Array of session objects (we need to translate them to numbers and back for the protocol; the offset ...
static const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we are using.
const void * address
Binary representation of the address (plugin-specific).
static struct GNUNET_TIME_Relative backoff
How long should we wait to reconnect?
struct GNUNET_PeerIdentity peer
Identity of the peer that this address is for.
struct GNUNET_ATS_PropertiesNBO properties
Performance properties of the address.
struct GNUNET_MQ_Handle * GNUNET_CLIENT_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *service_name, const struct GNUNET_MQ_MessageHandler *handlers, GNUNET_MQ_ErrorHandler error_handler, void *error_handler_cls)
Create a message queue to connect to a GNUnet service.
Handle to the ATS subsystem for bandwidth/transport scheduling information.
const struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
uint32_t start_flag
NBO value of an enum StartFlag.
GNUNET_ATS_AddressSuggestionCallback suggest_cb
Callback to invoke on suggestions.
GNUNET_MQ_Error
Error codes for the queue.
struct GNUNET_PeerIdentity peer
Which peer is this about? (Technically redundant, as the session_id should be sufficient, but enables ATS service to find the session faster).
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_MESSAGE_TYPE_ATS_ADDRESS_SUGGESTION
Type of the 'struct AddressSuggestionMessage' sent by ATS to clients to suggest switching to a differ...
void GNUNET_ATS_properties_hton(struct GNUNET_ATS_PropertiesNBO *nbo, const struct GNUNET_ATS_Properties *hbo)
Convert ATS properties from host to network byte order.
struct GNUNET_ATS_SchedulingHandle * GNUNET_ATS_scheduling_init(const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_ATS_AddressSuggestionCallback suggest_cb, void *suggest_cb_cls)
Initialize the ATS subsystem.
void GNUNET_ATS_scheduling_done(struct GNUNET_ATS_SchedulingHandle *sh)
Client is done with ATS scheduling, release resources.
uint32_t session_id
Number the client used to identify the session.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
#define GNUNET_MQ_hd_fixed_size(name, code, str, ctx)
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
static struct GNUNET_HashCode session_id
struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in
How much bandwidth we are allowed for receiving.
uint32_t scope
Which network scope does the respective address belong to? This property does not change...
struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out
How much bandwidth we are allowed for sending.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
uint32_t session_id
Internal number this client uses to refer to this address.
ATS performance characteristics for an address.
uint32_t session_id
Internal number this client uses to refer to the address this suggestion is about.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
void(* GNUNET_ATS_AddressSuggestionCallback)(void *cls, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_HELLO_Address *address, struct GNUNET_ATS_Session *session, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in)
Signature of a function called by ATS with the current bandwidth and address preferences as determine...
Message used to notify ATS that the performance characteristics for an address have changed...
uint32_t value__
The actual value (bytes per second).
struct GNUNET_ATS_Session * session
Session handle.
int GNUNET_HELLO_address_check_option(const struct GNUNET_HELLO_Address *address, enum GNUNET_HELLO_AddressInfo option)
Check if an address has a local option set.
static uint32_t find_empty_session_slot(struct GNUNET_ATS_SchedulingHandle *sh)
Get an available session ID.
static struct GNUNET_ARM_MonitorHandle * m
Monitor connection with ARM.
#define GNUNET_MESSAGE_TYPE_ATS_SESSION_RELEASE
Type of the 'struct SessionReleaseMessage' sent by ATS to client to confirm that a session ID was des...
int GNUNET_HELLO_address_cmp(const struct GNUNET_HELLO_Address *a1, const struct GNUNET_HELLO_Address *a2)
Compare two addresses.
#define GNUNET_MQ_msg_extra(mvar, esize, type)
Allocate an envelope, with extra space allocated after the space needed by the message struct...
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_delayed(struct GNUNET_TIME_Relative delay, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay.
#define NOT_FOUND
Session ID we use if there is no session / slot.
#define GNUNET_array_grow(arr, size, tsize)
Grow a well-typed (!) array.
void * suggest_cb_cls
Closure for suggest_cb.
This is a scheduling client (aka transport service)
Session handle for connections.
This is an inbound address and cannot be used to initiate an outbound connection to another peer...
void GNUNET_ATS_address_update(struct GNUNET_ATS_AddressRecord *ar, const struct GNUNET_ATS_Properties *prop)
We have updated performance statistics for a given address.
unsigned int session_array_size
Size of the session_array.
const char * transport_name
Name of the transport plugin enabling the communication using this address.
Information we track per address, incoming or outgoing.
struct GNUNET_ATS_AddressRecord * GNUNET_ATS_address_add(struct GNUNET_ATS_SchedulingHandle *sh, const struct GNUNET_HELLO_Address *address, struct GNUNET_ATS_Session *session, const struct GNUNET_ATS_Properties *prop)
We have a new address ATS should know.
static void error_handler(void *cls, enum GNUNET_MQ_Error error)
We encountered an error handling the MQ to the ATS service.
Message handler for a specific message type.
uint16_t plugin_name_length
Number of bytes in the plugin name that follows this struct.
int GNUNET_ATS_address_del_session(struct GNUNET_ATS_AddressRecord *ar, struct GNUNET_ATS_Session *session)
A session was destroyed, disassociate it from the given address record.
struct GNUNET_ATS_PropertiesNBO properties
Performance data about the address.
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
static void handle_ats_session_release(void *cls, const struct GNUNET_ATS_SessionReleaseMessage *srm)
Type of a function to call when we receive a session release message from the service.
static char * init
Set to the name of a service to start.
#define GNUNET_TIME_STD_BACKOFF(r)
Perform our standard exponential back-off calculation, starting at 1 ms and then going by a factor of...
struct GNUNET_PeerIdentity peer
For which peer is this an address?
struct GNUNET_ATS_SchedulingHandle * sh
Scheduling handle this address record belongs to.
#define GNUNET_TIME_UNIT_ZERO
Relative time zero.
#define GNUNET_memcmp(a, b)
Compare memory in a and b, where both must be of the same pointer type.
#define GNUNET_MAX_MESSAGE_SIZE
Largest supported message (to be precise, one byte more than the largest possible message...
ATS Service suggests to the transport service to use the address identified by the given session_id f...
enum GNUNET_NetworkType scope
Which network scope does the respective address belong to? This property does not change...
struct GNUNET_TIME_Relative backoff
Reconnect backoff delay.
Handle to a message queue.
The identity of the host (wraps the signing key of the peer).
uint32_t address_local_info
Local-only information of the address, see enum GNUNET_HELLO_AddressInfo.
#define GNUNET_BANDWIDTH_ZERO
Convenience definition to use for 0-bandwidth.
struct GNUNET_MQ_Handle * mq
Message queue for sending requests to the ATS service.
static void reconnect_task(void *cls)
Re-establish the connection to the ATS service.
struct GNUNET_HELLO_Address * address
Address data.
static void reconnect(struct GNUNET_ATS_SchedulingHandle *sh)
Re-establish the connection to the ATS service.
An address for communicating with a peer.
struct GNUNET_HELLO_Address * GNUNET_HELLO_address_copy(const struct GNUNET_HELLO_Address *address)
Copy an address struct.
Automatic transport selection and outbound bandwidth determination.
static uint32_t find_session_id(struct GNUNET_ATS_SchedulingHandle *sh, struct GNUNET_ATS_Session *session, const struct GNUNET_HELLO_Address *address)
Get the ID for the given session object.
Entry in list of pending tasks.
void GNUNET_ATS_address_destroy(struct GNUNET_ATS_AddressRecord *ar)
An address got destroyed, stop using it as a valid address.
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
struct GNUNET_ATS_PropertiesNBO properties
Performance properties of the address.
struct GNUNET_PeerIdentity peer
Which peer is this about? (Technically redundant, as the session_id should be sufficient, but may enable client to find the session faster and/or check consistency).
int in_destroy
We're about to destroy this address record, just ATS does not know this yet.
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
#define GNUNET_MESSAGE_TYPE_ATS_ADDRESS_ADD
Type of the 'struct AddressUpdateMessage' sent by client to ATS to add a new address.
Message sent by ATS client to ATS service when an address was destroyed and must thus henceforth no l...
static void handle_ats_address_suggestion(void *cls, const struct AddressSuggestionMessage *m)
Type of a function to call when we receive a address suggestion message from the service.
void GNUNET_ATS_address_add_session(struct GNUNET_ATS_AddressRecord *ar, struct GNUNET_ATS_Session *session)
An address was used to initiate a session.
uint32_t session_id
Internal number this client will henceforth use to refer to this address.
Message sent by ATS service to client to confirm that it is done using the given session ID...
ATS performance characteristics for an address in network byte order (for IPC).
static void release_session(struct GNUNET_ATS_SchedulingHandle *sh, uint32_t session_id)
Release the session slot from the session table (ATS service is also done using it).
uint32_t slot
Which slot (index) in the session array does this record correspond to? FIXME: a linear search on thi...
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
#define GNUNET_HELLO_address_free(addr)
Free an address.
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
uint32_t session_id
Internal number this client uses to refer to this address.
automatic transport selection messages
#define GNUNET_MESSAGE_TYPE_ATS_ADDRESS_UPDATE
Type of the 'struct AddressUpdateMessage' sent by clients to ATS to inform ATS about performance chan...
First message any client sends to ATS, used to self-identify (what type of client this is)...
#define GNUNET_free(ptr)
Wrapper around free.
static void force_reconnect(struct GNUNET_ATS_SchedulingHandle *sh)
Disconnect from ATS and then reconnect.
Time for relative time used by GNUnet, in microseconds.
static struct GNUNET_TRANSPORT_PluginMonitor * pm
Handle if we are monitoring plugin session activity.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Scheduling client to ATS service: here is another address you can use.