GNUnet  0.10.x
Functions | Variables
gnunet-service-ats_performance.c File Reference

ats service, interaction with 'performance' API More...

#include "platform.h"
#include "gnunet-service-ats.h"
#include "gnunet-service-ats_addresses.h"
#include "gnunet-service-ats_performance.h"
#include "ats.h"
Include dependency graph for gnunet-service-ats_performance.c:

Go to the source code of this file.

Functions

static void notify_client (struct GNUNET_SERVICE_Client *client, const struct GNUNET_PeerIdentity *peer, const char *plugin_name, const void *plugin_addr, size_t plugin_addr_len, int active, const struct GNUNET_ATS_Properties *prop, enum GNUNET_HELLO_AddressInfo local_address_info, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in)
 Transmit the given performance information to all performance clients. More...
 
void GAS_performance_notify_all_clients (const struct GNUNET_PeerIdentity *peer, const char *plugin_name, const void *plugin_addr, size_t plugin_addr_len, int active, const struct GNUNET_ATS_Properties *prop, enum GNUNET_HELLO_AddressInfo local_address_info, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in)
 Transmit the given performance information to all performance clients. More...
 
static void peerinfo_it (void *cls, const struct GNUNET_PeerIdentity *id, const char *plugin_name, const void *plugin_addr, size_t plugin_addr_len, int active, const struct GNUNET_ATS_Properties *prop, enum GNUNET_HELLO_AddressInfo local_address_info, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in)
 Iterator for called from GAS_addresses_get_peer_info() More...
 
void GAS_performance_add_client (struct GNUNET_SERVICE_Client *client, enum StartFlag flag)
 Register a new performance client. More...
 
void GAS_performance_init ()
 Initialize performance subsystem. More...
 
void GAS_performance_done ()
 Shutdown performance subsystem. More...
 

Variables

static struct GNUNET_NotificationContextnc_no_pic
 Context for sending messages to performance clients without PIC. More...
 
static struct GNUNET_NotificationContextnc_pic
 Context for sending messages to performance clients with PIC. More...
 

Detailed Description

ats service, interaction with 'performance' API

Author
Matthias Wachs
Christian Grothoff

TODO:

Definition in file gnunet-service-ats_performance.c.

Function Documentation

◆ notify_client()

static void notify_client ( struct GNUNET_SERVICE_Client client,
const struct GNUNET_PeerIdentity peer,
const char *  plugin_name,
const void *  plugin_addr,
size_t  plugin_addr_len,
int  active,
const struct GNUNET_ATS_Properties prop,
enum GNUNET_HELLO_AddressInfo  local_address_info,
struct GNUNET_BANDWIDTH_Value32NBO  bandwidth_out,
struct GNUNET_BANDWIDTH_Value32NBO  bandwidth_in 
)
static

Transmit the given performance information to all performance clients.

Parameters
clientclient to send to, NULL for all
peerpeer for which this is an address suggestion
plugin_name0-termintated string specifying the transport plugin
plugin_addrbinary address for the plugin to use
plugin_addr_lennumber of bytes in plugin_addr
activeGNUNET_YES if this address is actively used to maintain a connection to a peer; GNUNET_NO if the address is not actively used; GNUNET_SYSERR if this address is no longer available for ATS
propperformance data for the address
local_address_infoinformation about the local flags for the address
bandwidth_outassigned outbound bandwidth
bandwidth_inassigned inbound bandwidth

Definition at line 66 of file gnunet-service-ats_performance.c.

References PeerInformationMessage::address_active, PeerInformationMessage::address_length, PeerInformationMessage::address_local_info, PeerInformationMessage::bandwidth_in, PeerInformationMessage::bandwidth_out, buf, env, GNUNET_ALIGN, GNUNET_assert, GNUNET_ATS_properties_hton(), GNUNET_break, GNUNET_MAX_MESSAGE_SIZE, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_ATS_PEER_INFORMATION, GNUNET_MQ_msg_copy(), GNUNET_MQ_send(), GNUNET_notification_context_broadcast(), GNUNET_NT_UNSPECIFIED, GNUNET_SERVICE_client_get_mq(), GNUNET_YES, PeerInformationMessage::header, PeerInformationMessage::id, msg, peer, PeerInformationMessage::peer, PeerInformationMessage::plugin_name_length, PeerInformationMessage::properties, GNUNET_ATS_Properties::scope, GNUNET_MessageHeader::size, and GNUNET_MessageHeader::type.

Referenced by GAS_performance_notify_all_clients(), and peerinfo_it().

76 {
78  size_t plugin_name_length = strlen (plugin_name) + 1;
79  size_t msize =
80  sizeof (struct PeerInformationMessage) +
81  plugin_addr_len +
82  plugin_name_length;
83  char buf[msize] GNUNET_ALIGN;
84  char *addrp;
85 
86  if (NULL != prop)
89  msg = (struct PeerInformationMessage *) buf;
90  msg->header.size = htons (msize);
92  msg->id = htonl (0);
93  msg->peer = *peer;
94  msg->address_length = htons (plugin_addr_len);
95  msg->address_active = ntohl ((uint32_t) active);
96  msg->plugin_name_length = htons (plugin_name_length);
99  if (NULL != prop)
101  prop);
102  else
103  memset (&msg->properties,
104  0,
105  sizeof (struct GNUNET_ATS_Properties));
106  msg->address_local_info = htonl (local_address_info);
107  addrp = (char *) &msg[1];
108  GNUNET_memcpy (addrp, plugin_addr, plugin_addr_len);
109  strcpy (&addrp[plugin_addr_len], plugin_name);
110  if (NULL == client)
111  {
113  &msg->header,
114  GNUNET_YES);
115  }
116  else
117  {
118  struct GNUNET_MQ_Envelope *env;
119 
120  env = GNUNET_MQ_msg_copy (&msg->header);
122  env);
123  }
124 }
struct GNUNET_MQ_Envelope * GNUNET_MQ_msg_copy(const struct GNUNET_MessageHeader *hdr)
Create a new envelope by copying an existing message.
Definition: mq.c:653
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
uint16_t address_length
Definition: ats.h:294
struct GNUNET_MQ_Handle * GNUNET_SERVICE_client_get_mq(struct GNUNET_SERVICE_Client *c)
Obtain the message queue of c.
Definition: service.c:2734
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in
Definition: ats.h:324
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.
uint16_t plugin_name_length
Definition: ats.h:299
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_ATS_PEER_INFORMATION.
Definition: ats.h:289
uint32_t address_local_info
Local-only information of the address, see enum GNUNET_HELLO_AddressInfo.
Definition: ats.h:335
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
#define GNUNET_MESSAGE_TYPE_ATS_PEER_INFORMATION
Type of the 'struct PeerInformationMessage' sent by ATS to clients to inform about QoS for a particul...
ATS performance characteristics for an address.
struct GNUNET_ATS_PropertiesNBO properties
Performance properties of the address.
Definition: ats.h:329
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
struct GNUNET_PeerIdentity peer
Definition: ats.h:304
uint16_t type
The type of the message (GNUNET_MESSAGE_TYPE_XXXX), in big-endian format.
#define GNUNET_memcpy(dst, src, n)
struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out
Definition: ats.h:319
static char buf[2048]
static char * plugin_name
Solver plugin name as string.
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
#define GNUNET_MAX_MESSAGE_SIZE
Largest supported message (to be precise, one byte more than the largest possible message...
enum GNUNET_NetworkType scope
Which network scope does the respective address belong to? This property does not change...
void GNUNET_notification_context_broadcast(struct GNUNET_NotificationContext *nc, const struct GNUNET_MessageHeader *msg, int can_drop)
Send a message to all subscribers of this context.
Definition: nc.c:192
#define GNUNET_ALIGN
gcc-ism to force alignment; we use this to align char-arrays that may then be cast to 'struct's...
#define GNUNET_YES
Definition: gnunet_common.h:80
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
Definition: mq.c:353
static struct GNUNET_NotificationContext * nc_pic
Context for sending messages to performance clients with PIC.
uint32_t address_active
Definition: ats.h:309
Category of last resort.
Definition: gnunet_nt_lib.h:40
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GAS_performance_notify_all_clients()

void GAS_performance_notify_all_clients ( const struct GNUNET_PeerIdentity peer,
const char *  plugin_name,
const void *  plugin_addr,
size_t  plugin_addr_len,
int  active,
const struct GNUNET_ATS_Properties prop,
enum GNUNET_HELLO_AddressInfo  local_address_info,
struct GNUNET_BANDWIDTH_Value32NBO  bandwidth_out,
struct GNUNET_BANDWIDTH_Value32NBO  bandwidth_in 
)

Transmit the given performance information to all performance clients.

Parameters
peerpeer for which this is an address suggestion
plugin_name0-termintated string specifying the transport plugin
plugin_addrbinary address for the plugin to use
plugin_addr_lennumber of bytes in plugin_addr
activeGNUNET_YES if this address is actively used to maintain a connection to a peer; GNUNET_NO if the address is not actively used; GNUNET_SYSERR if this address is no longer available for ATS
propperformance data for the address
local_address_infoinformation about the local flags for the address
bandwidth_outassigned outbound bandwidth
bandwidth_inassigned inbound bandwidth

Definition at line 145 of file gnunet-service-ats_performance.c.

References GNUNET_break, GNUNET_NO, GNUNET_NT_UNSPECIFIED, GNUNET_STATISTICS_update(), GSA_stats, notify_client(), and GNUNET_ATS_Properties::scope.

Referenced by bandwidth_changed_cb(), free_address(), GAS_addresses_add(), and GAS_addresses_update().

154 {
155  GNUNET_break ( (NULL == prop) ||
156  (GNUNET_NT_UNSPECIFIED != prop->scope) );
157  notify_client (NULL,
158  peer,
159  plugin_name,
160  plugin_addr,
161  plugin_addr_len,
162  active,
163  prop,
164  local_address_info,
165  bandwidth_out,
166  bandwidth_in);
168  "# performance updates given to clients",
169  1,
170  GNUNET_NO);
171 }
#define GNUNET_NO
Definition: gnunet_common.h:81
static void notify_client(struct GNUNET_SERVICE_Client *client, const struct GNUNET_PeerIdentity *peer, const char *plugin_name, const void *plugin_addr, size_t plugin_addr_len, int active, const struct GNUNET_ATS_Properties *prop, enum GNUNET_HELLO_AddressInfo local_address_info, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in)
Transmit the given performance information to all performance clients.
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
struct GNUNET_STATISTICS_Handle * GSA_stats
Handle for statistics.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
static char * plugin_name
Solver plugin name as string.
enum GNUNET_NetworkType scope
Which network scope does the respective address belong to? This property does not change...
Category of last resort.
Definition: gnunet_nt_lib.h:40
Here is the call graph for this function:
Here is the caller graph for this function:

◆ peerinfo_it()

static void peerinfo_it ( void *  cls,
const struct GNUNET_PeerIdentity id,
const char *  plugin_name,
const void *  plugin_addr,
size_t  plugin_addr_len,
int  active,
const struct GNUNET_ATS_Properties prop,
enum GNUNET_HELLO_AddressInfo  local_address_info,
struct GNUNET_BANDWIDTH_Value32NBO  bandwidth_out,
struct GNUNET_BANDWIDTH_Value32NBO  bandwidth_in 
)
static

Iterator for called from GAS_addresses_get_peer_info()

Parameters
clsclosure with the struct GNUNET_SERVICE_Client * to inform.
idthe peer id
plugin_nameplugin name
plugin_addraddress
plugin_addr_lenlength of plugin_addr
activeis address actively used
propperformance information
local_address_infoinformation about the local flags for the address
bandwidth_outcurrent outbound bandwidth assigned to address
bandwidth_incurrent inbound bandwidth assigned to address

Definition at line 189 of file gnunet-service-ats_performance.c.

References GNUNET_break, GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GNUNET_log, GNUNET_NT_UNSPECIFIED, notify_client(), GNUNET_ATS_Properties::scope, and GNUNET_BANDWIDTH_Value32NBO::value__.

Referenced by GAS_performance_add_client().

199 {
200  struct GNUNET_SERVICE_Client *client = cls;
201 
202  if (NULL == id)
203  return;
205  "Callback for peer `%s' plugin `%s' BW out %u, BW in %u \n",
206  GNUNET_i2s (id),
207  plugin_name,
208  (unsigned int) ntohl (bandwidth_out.value__),
209  (unsigned int) ntohl (bandwidth_in.value__));
211  notify_client (client,
212  id,
213  plugin_name,
214  plugin_addr,
215  plugin_addr_len,
216  active,
217  prop,
218  local_address_info,
219  bandwidth_out,
220  bandwidth_in);
221 }
static void notify_client(struct GNUNET_SERVICE_Client *client, const struct GNUNET_PeerIdentity *peer, const char *plugin_name, const void *plugin_addr, size_t plugin_addr_len, int active, const struct GNUNET_ATS_Properties *prop, enum GNUNET_HELLO_AddressInfo local_address_info, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in)
Transmit the given performance information to all performance clients.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
uint32_t value__
The actual value (bytes per second).
Handle to a client that is connected to a service.
Definition: service.c:249
static char * plugin_name
Solver plugin name as string.
enum GNUNET_NetworkType scope
Which network scope does the respective address belong to? This property does not change...
#define GNUNET_log(kind,...)
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
Category of last resort.
Definition: gnunet_nt_lib.h:40
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GAS_performance_add_client()

void GAS_performance_add_client ( struct GNUNET_SERVICE_Client client,
enum StartFlag  flag 
)

Register a new performance client.

Parameters
clienthandle of the new client
flagflag specifying the type of the client

Definition at line 231 of file gnunet-service-ats_performance.c.

References GAS_addresses_get_peer_info(), GNUNET_notification_context_add(), GNUNET_SERVICE_client_get_mq(), mq, peerinfo_it(), and START_FLAG_PERFORMANCE_WITH_PIC.

Referenced by handle_ats_start().

233 {
234  struct GNUNET_MQ_Handle *mq;
235 
236  mq = GNUNET_SERVICE_client_get_mq (client);
238  {
240  mq);
242  &peerinfo_it,
243  client);
244  }
245  else
246  {
248  mq);
249  }
250 }
struct GNUNET_MQ_Handle * GNUNET_SERVICE_client_get_mq(struct GNUNET_SERVICE_Client *c)
Obtain the message queue of c.
Definition: service.c:2734
static struct GNUNET_NotificationContext * nc_no_pic
Context for sending messages to performance clients without PIC.
void GNUNET_notification_context_add(struct GNUNET_NotificationContext *nc, struct GNUNET_MQ_Handle *mq)
Add a subscriber to the notification context.
Definition: nc.c:164
void GAS_addresses_get_peer_info(const struct GNUNET_PeerIdentity *peer, GNUNET_ATS_PeerInfo_Iterator pi_it, void *pi_it_cls)
Return information all peers currently known to ATS.
static void peerinfo_it(void *cls, const struct GNUNET_PeerIdentity *id, const char *plugin_name, const void *plugin_addr, size_t plugin_addr_len, int active, const struct GNUNET_ATS_Properties *prop, enum GNUNET_HELLO_AddressInfo local_address_info, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in)
Iterator for called from GAS_addresses_get_peer_info()
Handle to a message queue.
Definition: mq.c:85
struct GNUNET_MQ_Handle * mq
Definition: 003.c:5
static struct GNUNET_NotificationContext * nc_pic
Context for sending messages to performance clients with PIC.
Performance monitoring client that wants to learn about changes in performance characteristics.
Definition: ats.h:49
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GAS_performance_init()

void GAS_performance_init ( void  )

Initialize performance subsystem.

Parameters
serverhandle to our server

Definition at line 259 of file gnunet-service-ats_performance.c.

References GNUNET_notification_context_create().

Referenced by run().

260 {
263 }
static struct GNUNET_NotificationContext * nc_no_pic
Context for sending messages to performance clients without PIC.
struct GNUNET_NotificationContext * GNUNET_notification_context_create(unsigned int queue_length)
Create a new notification context.
Definition: nc.c:125
static struct GNUNET_NotificationContext * nc_pic
Context for sending messages to performance clients with PIC.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GAS_performance_done()

void GAS_performance_done ( void  )

Shutdown performance subsystem.

Definition at line 270 of file gnunet-service-ats_performance.c.

References GNUNET_notification_context_destroy().

Referenced by cleanup_task().

271 {
273  nc_no_pic = NULL;
275  nc_pic = NULL;
276 }
static struct GNUNET_NotificationContext * nc_no_pic
Context for sending messages to performance clients without PIC.
void GNUNET_notification_context_destroy(struct GNUNET_NotificationContext *nc)
Destroy the context, force disconnect for all subscribers.
Definition: nc.c:141
static struct GNUNET_NotificationContext * nc_pic
Context for sending messages to performance clients with PIC.
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ nc_no_pic

struct GNUNET_NotificationContext* nc_no_pic
static

Context for sending messages to performance clients without PIC.

Definition at line 39 of file gnunet-service-ats_performance.c.

◆ nc_pic

struct GNUNET_NotificationContext* nc_pic
static

Context for sending messages to performance clients with PIC.

Definition at line 44 of file gnunet-service-ats_performance.c.