ats service, inbound bandwidth reservation management More...
#include "platform.h"
#include "gnunet-service-ats_reservations.h"
#include "gnunet-service-ats.h"
#include "ats.h"
Go to the source code of this file.
Macros | |
#define | MAX_BANDWIDTH_CARRY_S 5 |
Number of seconds that available bandwidth carries over (can accumulate). More... | |
Functions | |
static struct GNUNET_TIME_Relative | reservations_reserve (const struct GNUNET_PeerIdentity *peer, int32_t amount) |
Reserve the given amount of incoming bandwidth (in bytes) from the given peer. More... | |
void | GAS_reservations_set_bandwidth (const struct GNUNET_PeerIdentity *peer, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in) |
Set the amount of bandwidth the other peer could currently transmit to us (as far as we know) to the given value. More... | |
void | GAS_handle_reservation_request (struct GNUNET_SERVICE_Client *client, const struct ReservationRequestMessage *msg) |
Handle 'reservation request' messages from clients. More... | |
void | GAS_reservations_init () |
Initialize reservations subsystem. More... | |
static int | free_tracker (void *cls, const struct GNUNET_PeerIdentity *key, void *value) |
Free memory of bandwidth tracker. More... | |
void | GAS_reservations_done () |
Shutdown reservations subsystem. More... | |
Variables | |
static struct GNUNET_CONTAINER_MultiPeerMap * | trackers |
Map of peer identities to struct GNUNET_BANDWIDTH_Tracker * s. More... | |
ats service, inbound bandwidth reservation management
Definition in file gnunet-service-ats_reservations.c.
#define MAX_BANDWIDTH_CARRY_S 5 |
Number of seconds that available bandwidth carries over (can accumulate).
Note that the test_ats_reservation_api test depends on this value!
Definition at line 35 of file gnunet-service-ats_reservations.c.
|
static |
Reserve the given amount of incoming bandwidth (in bytes) from the given peer.
If a reservation is not possible right now, return how long the client should wait before trying again.
peer | peer to reserve bandwidth from |
amount | number of bytes to reserve |
Definition at line 41 of file gnunet-service-ats_reservations.c.
References GNUNET_BANDWIDTH_tracker_consume(), GNUNET_BANDWIDTH_tracker_get_delay(), GNUNET_CONTAINER_multipeermap_get(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_STRINGS_relative_time_to_string(), GNUNET_TIME_UNIT_ZERO, GNUNET_YES, peer, ret, and trackers.
Referenced by GAS_handle_reservation_request().
void GAS_reservations_set_bandwidth | ( | const struct GNUNET_PeerIdentity * | peer, |
struct GNUNET_BANDWIDTH_Value32NBO | bandwidth_in | ||
) |
Set the amount of bandwidth the other peer could currently transmit to us (as far as we know) to the given value.
peer | identity of the peer |
bandwidth_in | currently available bandwidth from that peer to this peer (estimate) |
Definition at line 101 of file gnunet-service-ats_reservations.c.
References GNUNET_assert, GNUNET_BANDWIDTH_tracker_init(), GNUNET_BANDWIDTH_tracker_update_quota(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY, GNUNET_CONTAINER_multipeermap_get(), GNUNET_CONTAINER_multipeermap_put(), GNUNET_CONTAINER_multipeermap_remove(), GNUNET_free, GNUNET_new, GNUNET_OK, GNUNET_YES, MAX_BANDWIDTH_CARRY_S, peer, trackers, and GNUNET_BANDWIDTH_Value32NBO::value__.
Referenced by bandwidth_changed_cb().
void GAS_handle_reservation_request | ( | struct GNUNET_SERVICE_Client * | client, |
const struct ReservationRequestMessage * | message | ||
) |
Handle 'reservation request' messages from clients.
client | client that sent the request |
message | the request message |
Definition at line 139 of file gnunet-service-ats_reservations.c.
References ReservationResultMessage::amount, env, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_MESSAGE_TYPE_ATS_RESERVATION_RESULT, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_NO, GNUNET_SERVICE_client_get_mq(), GNUNET_STATISTICS_update(), GNUNET_TIME_relative_hton(), GSA_stats, msg, GNUNET_TIME_Relative::rel_value_us, reservations_reserve(), and result.
Referenced by handle_reservation_request().
void GAS_reservations_init | ( | void | ) |
Initialize reservations subsystem.
Definition at line 171 of file gnunet-service-ats_reservations.c.
References GNUNET_CONTAINER_multipeermap_create(), GNUNET_NO, and trackers.
Referenced by run().
|
static |
Free memory of bandwidth tracker.
cls | NULL |
key | peer identity (unused) |
value | the struct GNUNET_BANDWIDTH_Tracker to free |
Definition at line 187 of file gnunet-service-ats_reservations.c.
References GNUNET_free, GNUNET_OK, and value.
Referenced by GAS_reservations_done().
void GAS_reservations_done | ( | void | ) |
Shutdown reservations subsystem.
Definition at line 202 of file gnunet-service-ats_reservations.c.
References free_tracker(), GNUNET_CONTAINER_multipeermap_destroy(), GNUNET_CONTAINER_multipeermap_iterate(), and trackers.
Referenced by cleanup_task(), and run().
|
static |
Map of peer identities to struct GNUNET_BANDWIDTH_Tracker *
s.
Definition at line 41 of file gnunet-service-ats_reservations.c.
Referenced by GAS_reservations_done(), GAS_reservations_init(), GAS_reservations_set_bandwidth(), and reservations_reserve().