functions related to bandwidth (unit) More...
Go to the source code of this file.
Macros | |
#define | LOG(kind, ...) GNUNET_log_from (kind, "util-bandwidth", __VA_ARGS__) |
Functions | |
struct GNUNET_BANDWIDTH_Value32NBO | GNUNET_BANDWIDTH_value_init (uint32_t bytes_per_second) |
Create a new bandwidth value. More... | |
struct GNUNET_BANDWIDTH_Value32NBO | GNUNET_BANDWIDTH_value_min (struct GNUNET_BANDWIDTH_Value32NBO b1, struct GNUNET_BANDWIDTH_Value32NBO b2) |
Compute the MIN of two bandwidth values. More... | |
struct GNUNET_BANDWIDTH_Value32NBO | GNUNET_BANDWIDTH_value_max (struct GNUNET_BANDWIDTH_Value32NBO b1, struct GNUNET_BANDWIDTH_Value32NBO b2) |
Compute the MAX of two bandwidth values. More... | |
struct GNUNET_BANDWIDTH_Value32NBO | GNUNET_BANDWIDTH_value_sum (struct GNUNET_BANDWIDTH_Value32NBO b1, struct GNUNET_BANDWIDTH_Value32NBO b2) |
Compute the SUM of two bandwidth values. More... | |
uint64_t | GNUNET_BANDWIDTH_value_get_available_until (struct GNUNET_BANDWIDTH_Value32NBO bps, struct GNUNET_TIME_Relative deadline) |
At the given bandwidth, calculate how much traffic will be available until the given deadline. More... | |
struct GNUNET_TIME_Relative | GNUNET_BANDWIDTH_value_get_delay_for (struct GNUNET_BANDWIDTH_Value32NBO bps, uint64_t size) |
At the given bandwidth, calculate how long it would take for size bytes to be transmitted. More... | |
static void | excess_trigger (void *cls) |
Task run whenever we hit the bandwidth limit for a tracker. More... | |
static void | update_excess (struct GNUNET_BANDWIDTH_Tracker *av) |
Recalculate when we might need to call the excess callback. More... | |
void | GNUNET_BANDWIDTH_tracker_init2 (struct GNUNET_BANDWIDTH_Tracker *av, GNUNET_BANDWIDTH_TrackerUpdateCallback update_cb, void *update_cb_cls, struct GNUNET_BANDWIDTH_Value32NBO bytes_per_second_limit, uint32_t max_carry_s, GNUNET_BANDWIDTH_ExcessNotificationCallback excess_cb, void *excess_cb_cls) |
Initialize bandwidth tracker. More... | |
void | GNUNET_BANDWIDTH_tracker_init (struct GNUNET_BANDWIDTH_Tracker *av, GNUNET_BANDWIDTH_TrackerUpdateCallback update_cb, void *update_cb_cls, struct GNUNET_BANDWIDTH_Value32NBO bytes_per_second_limit, uint32_t max_carry_s) |
Initialize bandwidth tracker. More... | |
void | GNUNET_BANDWIDTH_tracker_notification_stop (struct GNUNET_BANDWIDTH_Tracker *av) |
Stop notifying about tracker updates and excess notifications. More... | |
static void | update_tracker (struct GNUNET_BANDWIDTH_Tracker *av) |
Update the tracker, looking at the current time and bandwidth consumption data. More... | |
int | GNUNET_BANDWIDTH_tracker_consume (struct GNUNET_BANDWIDTH_Tracker *av, ssize_t size) |
Notify the tracker that a certain number of bytes of bandwidth have been consumed. More... | |
struct GNUNET_TIME_Relative | GNUNET_BANDWIDTH_tracker_get_delay (struct GNUNET_BANDWIDTH_Tracker *av, size_t size) |
Compute how long we should wait until consuming 'size' bytes of bandwidth in order to stay within the given quota. More... | |
int64_t | GNUNET_BANDWIDTH_tracker_get_available (struct GNUNET_BANDWIDTH_Tracker *av) |
Compute how many bytes are available for consumption right now. More... | |
void | GNUNET_BANDWIDTH_tracker_update_quota (struct GNUNET_BANDWIDTH_Tracker *av, struct GNUNET_BANDWIDTH_Value32NBO bytes_per_second_limit) |
Update quota of bandwidth tracker. More... | |
functions related to bandwidth (unit)
Definition in file bandwidth.c.
#define LOG | ( | kind, | |
... | |||
) | GNUNET_log_from (kind, "util-bandwidth", __VA_ARGS__) |
Definition at line 31 of file bandwidth.c.
|
static |
Task run whenever we hit the bandwidth limit for a tracker.
cls | the struct GNUNET_BANDWIDTH_Tracker |
Definition at line 150 of file bandwidth.c.
References GNUNET_BANDWIDTH_Tracker::excess_cb, GNUNET_BANDWIDTH_Tracker::excess_cb_cls, GNUNET_BANDWIDTH_Tracker::excess_task, GNUNET_ERROR_TYPE_DEBUG, and GNUNET_log.
Referenced by update_excess().
|
static |
Recalculate when we might need to call the excess callback.
Definition at line 168 of file bandwidth.c.
References GNUNET_TIME_Absolute::abs_value_us, GNUNET_BANDWIDTH_Tracker::available_bytes_per_s__, GNUNET_BANDWIDTH_Tracker::consumption_since_last_update__, GNUNET_BANDWIDTH_Tracker::excess_cb, GNUNET_BANDWIDTH_Tracker::excess_task, excess_trigger(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_MAX_MESSAGE_SIZE, GNUNET_NO, GNUNET_SCHEDULER_add_delayed(), GNUNET_SCHEDULER_cancel(), GNUNET_STRINGS_relative_time_to_string(), GNUNET_TIME_absolute_get(), GNUNET_TIME_relative_saturating_multiply(), GNUNET_TIME_UNIT_SECONDS, GNUNET_TIME_UNIT_ZERO, GNUNET_BANDWIDTH_Tracker::last_update__, and GNUNET_BANDWIDTH_Tracker::max_carry_s__.
Referenced by GNUNET_BANDWIDTH_tracker_consume(), GNUNET_BANDWIDTH_tracker_init2(), and GNUNET_BANDWIDTH_tracker_update_quota().
|
static |
Update the tracker, looking at the current time and bandwidth consumption data.
av | tracker to update |
Definition at line 321 of file bandwidth.c.
References GNUNET_TIME_Absolute::abs_value_us, GNUNET_BANDWIDTH_Tracker::available_bytes_per_s__, GNUNET_BANDWIDTH_Tracker::consumption_since_last_update__, delta, GNUNET_ERROR_TYPE_DEBUG, GNUNET_MAX_MESSAGE_SIZE, GNUNET_STRINGS_relative_time_to_string(), GNUNET_TIME_absolute_get(), GNUNET_YES, GNUNET_BANDWIDTH_Tracker::last_update__, LOG, GNUNET_BANDWIDTH_Tracker::max_carry_s__, and GNUNET_TIME_Relative::rel_value_us.
Referenced by GNUNET_BANDWIDTH_tracker_consume(), GNUNET_BANDWIDTH_tracker_get_available(), GNUNET_BANDWIDTH_tracker_get_delay(), and GNUNET_BANDWIDTH_tracker_update_quota().