GNUnet  0.18.1
Bandwidth library

Functions related to bandwidth (unit) More...

Collaboration diagram for Bandwidth library:

Data Structures

struct  GNUNET_BANDWIDTH_Value32NBO
 32-bit bandwidth used for network exchange by GNUnet, in bytes per second. More...
 
struct  GNUNET_BANDWIDTH_Tracker
 Struct to track available bandwidth. More...
 

Macros

#define GNUNET_BANDWIDTH_ZERO   GNUNET_BANDWIDTH_value_init (0)
 Convenience definition to use for 0-bandwidth. More...
 
#define GNUNET_BANDWIDTH_VALUE_MAX   GNUNET_BANDWIDTH_value_init (UINT32_MAX)
 Maximum possible bandwidth value. More...
 

Typedefs

typedef void(* GNUNET_BANDWIDTH_TrackerUpdateCallback) (void *cls)
 Callback to be called by the bandwidth tracker if the tracker was updated and the client should update it's delay values. More...
 
typedef void(* GNUNET_BANDWIDTH_ExcessNotificationCallback) (void *cls)
 Callback to be called by the bandwidth tracker if the tracker was updated and the client should update it's delay values. More...
 

Functions

struct GNUNET_BANDWIDTH_Value32NBO GNUNET_BANDWIDTH_value_init (uint32_t bytes_per_second)
 Create a new bandwidth value. 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...
 
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...
 
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_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_notification_stop (struct GNUNET_BANDWIDTH_Tracker *av)
 Stop notifying about tracker updates and excess notifications. 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...
 

Detailed Description

Functions related to bandwidth (unit)

Macro Definition Documentation

◆ GNUNET_BANDWIDTH_ZERO

#define GNUNET_BANDWIDTH_ZERO   GNUNET_BANDWIDTH_value_init (0)

Convenience definition to use for 0-bandwidth.

Definition at line 147 of file gnunet_bandwidth_lib.h.

◆ GNUNET_BANDWIDTH_VALUE_MAX

#define GNUNET_BANDWIDTH_VALUE_MAX   GNUNET_BANDWIDTH_value_init (UINT32_MAX)

Maximum possible bandwidth value.

Definition at line 163 of file gnunet_bandwidth_lib.h.

Typedef Documentation

◆ GNUNET_BANDWIDTH_TrackerUpdateCallback

typedef void(* GNUNET_BANDWIDTH_TrackerUpdateCallback) (void *cls)

Callback to be called by the bandwidth tracker if the tracker was updated and the client should update it's delay values.

Parameters
clsa closure to pass

Definition at line 71 of file gnunet_bandwidth_lib.h.

◆ GNUNET_BANDWIDTH_ExcessNotificationCallback

typedef void(* GNUNET_BANDWIDTH_ExcessNotificationCallback) (void *cls)

Callback to be called by the bandwidth tracker if the tracker was updated and the client should update it's delay values.

Parameters
clsa closure to pass

Definition at line 80 of file gnunet_bandwidth_lib.h.

Function Documentation

◆ GNUNET_BANDWIDTH_value_init()

struct GNUNET_BANDWIDTH_Value32NBO GNUNET_BANDWIDTH_value_init ( uint32_t  bytes_per_second)

Create a new bandwidth value.

Parameters
bytes_per_secondvalue to create
Returns
the new bandwidth value

Definition at line 1 of file bandwidth.c.

40 {
42 
43  ret.value__ = htonl (bytes_per_second);
44  return ret;
45 }
static int ret
Return value of the commandline.
Definition: gnunet-abd.c:81
32-bit bandwidth used for network exchange by GNUnet, in bytes per second.

Referenced by bandwidth_changed_cb(), free_address(), GAS_addresses_add(), GAS_addresses_update(), GNUNET_BANDWIDTH_tracker_get_available(), GST_neighbours_handle_quota_message(), libgnunet_plugin_transport_udp_init(), peerinfo_it(), and unset_primary_address().

Here is the caller graph for this function:

◆ GNUNET_BANDWIDTH_value_get_available_until()

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.

Parameters
bpsbandwidth
deadlinewhen is the deadline
Returns
number of bytes available at bps until deadline

Definition at line 96 of file bandwidth.c.

99 {
100  uint64_t b;
101 
102  b = ntohl (bps.value__);
104  "Bandwidth has %llu bytes available until deadline in %s\n",
105  (unsigned long long) ((b * deadline.rel_value_us + 500000LL)
106  / 1000000LL),
108  return (b * deadline.rel_value_us + 500000LL) / 1000000LL;
109 }
#define LOG(kind,...)
Definition: bandwidth.c:30
static struct GNUNET_TIME_Absolute deadline
Deadline for all consensuses.
@ GNUNET_YES
@ GNUNET_ERROR_TYPE_DEBUG
const char * GNUNET_STRINGS_relative_time_to_string(struct GNUNET_TIME_Relative delta, int do_round)
Give relative time in human-readable fancy format.
Definition: strings.c:570
uint32_t value__
The actual value (bytes per second).

References deadline, GNUNET_ERROR_TYPE_DEBUG, GNUNET_STRINGS_relative_time_to_string(), GNUNET_YES, LOG, and GNUNET_BANDWIDTH_Value32NBO::value__.

Referenced by GNUNET_BANDWIDTH_tracker_get_available().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_BANDWIDTH_value_get_delay_for()

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.

Parameters
bpsbandwidth
sizenumber of bytes we want to have available
Returns
how long it would take

At the given bandwidth, calculate how long it would take for 'size' bytes to be transmitted.

Parameters
bpsbandwidth
sizenumber of bytes we want to have available
Returns
how long it would take

Definition at line 96 of file bandwidth.c.

123 {
124  uint64_t b;
125  struct GNUNET_TIME_Relative ret;
126 
127  b = ntohl (bps.value__);
128  if (0 == b)
129  {
131  "Bandwidth suggests delay of infinity (zero bandwidth)\n");
133  }
134  ret.rel_value_us = size * 1000LL * 1000LL / b;
136  "Bandwidth suggests delay of %s for %llu bytes of traffic\n",
138  (unsigned long long) size);
139  return ret;
140 }
#define GNUNET_TIME_UNIT_FOREVER_REL
Constant used to specify "forever".
static unsigned int size
Size of the "table".
Definition: peer.c:67
Time for relative time used by GNUnet, in microseconds.

◆ GNUNET_BANDWIDTH_value_min()

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.

Parameters
b1first value
b2second value
Returns
the min of b1 and b2

Definition at line 1 of file bandwidth.c.

58 {
60  GNUNET_MIN (ntohl (b1.value__), ntohl (b2.value__)));
61 }
struct GNUNET_BANDWIDTH_Value32NBO GNUNET_BANDWIDTH_value_init(uint32_t bytes_per_second)
Create a new bandwidth value.
Definition: bandwidth.c:39
#define GNUNET_MIN(a, b)

Referenced by neighbours_connect_notification(), and send_outbound_quota_to_clients().

Here is the caller graph for this function:

◆ GNUNET_BANDWIDTH_value_max()

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.

Parameters
b1first value
b2second value
Returns
the min of b1 and b2

Definition at line 1 of file bandwidth.c.

74 {
76  GNUNET_MAX (ntohl (b1.value__), ntohl (b2.value__)));
77 }
#define GNUNET_MAX(a, b)

Referenced by GST_neighbours_handle_quota_message().

Here is the caller graph for this function:

◆ GNUNET_BANDWIDTH_value_sum()

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.

Parameters
b1first value
b2second value
Returns
the sum of b1 and b2

Definition at line 1 of file bandwidth.c.

90 {
91  return GNUNET_BANDWIDTH_value_init (ntohl (b1.value__) + ntohl (b2.value__));
92 }

◆ GNUNET_BANDWIDTH_tracker_init()

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.

Note that in addition to the 'max_carry_s' limit, we also always allow at least GNUNET_MAX_MESSAGE_SIZE to accumulate. So if the bytes-per-second limit is so small that within 'max_carry_s' not even GNUNET_MAX_MESSAGE_SIZE is allowed to accumulate, it is ignored and replaced by GNUNET_MAX_MESSAGE_SIZE (which is in bytes).

Parameters
avtracker to initialize
update_cbcallback to notify a client about the tracker being updated
update_cb_clscls for the update_cb callback
bytes_per_second_limitinitial limit to assume
max_carry_smaximum number of seconds unused bandwidth may accumulate before it expires

Definition at line 278 of file bandwidth.c.

284 {
286  update_cb,
287  update_cb_cls,
288  bytes_per_second_limit,
289  max_carry_s,
290  NULL,
291  NULL);
292 }
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.
Definition: bandwidth.c:251

References GNUNET_BANDWIDTH_tracker_init2().

Referenced by GAS_reservations_set_bandwidth(), libgnunet_plugin_transport_udp_init(), and setup_neighbour().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_BANDWIDTH_tracker_init2()

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.

Note that in addition to the 'max_carry_s' limit, we also always allow at least GNUNET_MAX_MESSAGE_SIZE to accumulate. So if the bytes-per-second limit is so small that within 'max_carry_s' not even GNUNET_MAX_MESSAGE_SIZE is allowed to accumulate, it is ignored and replaced by GNUNET_MAX_MESSAGE_SIZE (which is in bytes).

Parameters
avtracker to initialize
update_cbcallback to notify a client about the tracker being updated
update_cb_clscls for the update_cb callback
bytes_per_second_limitinitial limit to assume
max_carry_smaximum number of seconds unused bandwidth may accumulate before it expires
excess_cbcallback to notify if we have excess bandwidth
excess_cb_clsclosure for excess_cb

Note that in addition to the 'max_carry_s' limit, we also always allow at least GNUNET_MAX_MESSAGE_SIZE to accumulate. So if the bytes-per-second limit is so small that within 'max_carry_s' not even GNUNET_MAX_MESSAGE_SIZE is allowed to accumulate, it is ignored and replaced by GNUNET_MAX_MESSAGE_SIZE (which is in bytes).

To stop notifications about updates and excess callbacks use GNUNET_BANDWIDTH_tracker_notification_stop().

Parameters
avtracker to initialize
update_cbcallback to notify a client about the tracker being updated
update_cb_clscls for the callback
bytes_per_second_limitinitial limit to assume
max_carry_smaximum number of seconds unused bandwidth may accumulate before it expires
excess_cbcallback to notify if we have excess bandwidth
excess_cb_clsclosure for excess_cb

Definition at line 251 of file bandwidth.c.

259 {
260  av->update_cb = update_cb;
261  av->update_cb_cls = update_cb_cls;
264  av->available_bytes_per_s__ = ntohl (bytes_per_second_limit.value__);
265  av->max_carry_s__ = max_carry_s;
266  av->excess_cb = excess_cb;
267  av->excess_cb_cls = excess_cb_cls;
269  "Tracker %p initialized with %u Bps and max carry %u\n",
270  av,
271  (unsigned int) av->available_bytes_per_s__,
272  (unsigned int) max_carry_s);
273  update_excess (av);
274 }
static void update_excess(struct GNUNET_BANDWIDTH_Tracker *av)
Recalculate when we might need to call the excess callback.
Definition: bandwidth.c:167
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
Definition: time.c:110
int64_t consumption_since_last_update__
Number of bytes consumed since we last updated the tracker.
GNUNET_BANDWIDTH_ExcessNotificationCallback excess_cb
Function we call if the tracker is about to throw away bandwidth due to excess (max carry exceeded).
void * update_cb_cls
Closure for update_cb.
struct GNUNET_TIME_Absolute last_update__
Time when we last updated the tracker.
void * excess_cb_cls
Closure for excess_cb.
GNUNET_BANDWIDTH_TrackerUpdateCallback update_cb
Function we call if the tracker's bandwidth is increased and a previously returned timeout might now ...
uint32_t available_bytes_per_s__
Bandwidth limit to enforce in bytes per second.
uint32_t max_carry_s__
Maximum number of seconds over which bandwidth may "accumulate".

References GNUNET_BANDWIDTH_Tracker::available_bytes_per_s__, GNUNET_BANDWIDTH_Tracker::consumption_since_last_update__, GNUNET_BANDWIDTH_Tracker::excess_cb, GNUNET_BANDWIDTH_Tracker::excess_cb_cls, GNUNET_ERROR_TYPE_DEBUG, GNUNET_TIME_absolute_get(), GNUNET_BANDWIDTH_Tracker::last_update__, LOG, GNUNET_BANDWIDTH_Tracker::max_carry_s__, GNUNET_BANDWIDTH_Tracker::update_cb, GNUNET_BANDWIDTH_Tracker::update_cb_cls, update_excess(), and GNUNET_BANDWIDTH_Value32NBO::value__.

Referenced by GNUNET_BANDWIDTH_tracker_init(), and handle_connect().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_BANDWIDTH_tracker_notification_stop()

void GNUNET_BANDWIDTH_tracker_notification_stop ( struct GNUNET_BANDWIDTH_Tracker av)

Stop notifying about tracker updates and excess notifications.

Parameters
avthe respective trackers

Definition at line 301 of file bandwidth.c.

302 {
303  if (NULL != av->excess_task)
305  av->excess_task = NULL;
306  av->excess_cb = NULL;
307  av->excess_cb_cls = NULL;
308  av->update_cb = NULL;
309  av->update_cb_cls = NULL;
310 }
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:943
struct GNUNET_SCHEDULER_Task * excess_task
Task scheduled to call the excess_cb once we have reached the maximum bandwidth the tracker can hold.

References GNUNET_BANDWIDTH_Tracker::excess_cb, GNUNET_BANDWIDTH_Tracker::excess_cb_cls, GNUNET_BANDWIDTH_Tracker::excess_task, GNUNET_SCHEDULER_cancel(), GNUNET_BANDWIDTH_Tracker::update_cb, and GNUNET_BANDWIDTH_Tracker::update_cb_cls.

Referenced by neighbour_delete().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_BANDWIDTH_tracker_consume()

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.

Note that it is legal to consume bytes even if not enough bandwidth is available (in that case, GNUNET_BANDWIDTH_tracker_get_delay() may return non-zero delay values even for a size of zero for a while).

Parameters
avtracker to update
sizenumber of bytes consumed
Returns
GNUNET_YES if this consumption is above the limit

Definition at line 367 of file bandwidth.c.

369 {
370  int64_t nc;
371 
373  "Tracker %p consumes %d bytes\n",
374  av,
375  (int) size);
376  if (size > 0)
377  {
379  if (nc < av->consumption_since_last_update__)
380  {
381  /* integer overflow, very bad */
382  GNUNET_break (0);
383  return GNUNET_SYSERR;
384  }
386  update_tracker (av);
387  update_excess (av);
389  {
391  "Tracker %p consumption %llu bytes above limit\n",
392  av,
393  (unsigned long long) av->consumption_since_last_update__);
394  return GNUNET_YES;
395  }
396  }
397  else
398  {
401  {
402  /* integer underflow, very bad */
403  GNUNET_break (0);
404  return GNUNET_SYSERR;
405  }
407  update_excess (av);
408  }
409  return GNUNET_NO;
410 }
static void update_tracker(struct GNUNET_BANDWIDTH_Tracker *av)
Update the tracker, looking at the current time and bandwidth consumption data.
Definition: bandwidth.c:320
static struct GNUNET_PEERINFO_NotifyContext * nc
Iterator context.
@ GNUNET_NO
Definition: gnunet_common.h:98
@ GNUNET_SYSERR
Definition: gnunet_common.h:97
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.

References GNUNET_BANDWIDTH_Tracker::consumption_since_last_update__, GNUNET_break, GNUNET_ERROR_TYPE_DEBUG, GNUNET_NO, GNUNET_SYSERR, GNUNET_YES, LOG, nc, size, update_excess(), and update_tracker().

Referenced by notify_send_done(), reservations_reserve(), and transmit_next().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_BANDWIDTH_tracker_get_delay()

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.

Parameters
avtracker to query
sizenumber of bytes we would like to consume
Returns
time to wait for consumption to be OK

Compute how long we should wait until consuming size bytes of bandwidth in order to stay within the given quota.

Parameters
avtracker to query
sizenumber of bytes we would like to consume
Returns
time in ms to wait for consumption to be OK

Definition at line 367 of file bandwidth.c.

425 {
426  struct GNUNET_TIME_Relative ret;
427  int64_t bytes_needed;
428 
429  if (0 == av->available_bytes_per_s__)
430  {
431  LOG (GNUNET_ERROR_TYPE_DEBUG, "Tracker %p delay is infinity\n", av);
433  }
434  update_tracker (av);
435  bytes_needed = size + av->consumption_since_last_update__;
436  if (bytes_needed <= 0)
437  {
439  "Tracker %p delay for %u bytes is zero\n",
440  av,
441  (unsigned int) size);
442  return GNUNET_TIME_UNIT_ZERO;
443  }
444  ret.rel_value_us = (1000LL * 1000LL * bytes_needed)
445  / (unsigned long long) av->available_bytes_per_s__;
447  "Tracker %p delay for %u bytes is %s\n",
448  av,
449  (unsigned int) size,
451  return ret;
452 }
#define GNUNET_TIME_UNIT_ZERO
Relative time zero.

Referenced by notify_send_done(), outbound_bw_tracker_update(), reservations_reserve(), and transmit_next().

Here is the caller graph for this function:

◆ GNUNET_BANDWIDTH_tracker_get_available()

int64_t GNUNET_BANDWIDTH_tracker_get_available ( struct GNUNET_BANDWIDTH_Tracker av)

Compute how many bytes are available for consumption right now.

quota.

Parameters
avtracker to query
Returns
number of bytes available for consumption right now

Definition at line 463 of file bandwidth.c.

464 {
465  struct GNUNET_BANDWIDTH_Value32NBO bps;
466  uint64_t avail;
467  int64_t used;
468 
469  update_tracker (av);
471  avail =
474  av->last_update__));
477  "Tracker %p available bandwidth is %lld bytes\n",
478  av,
479  (long long) (int64_t) (avail - used));
480  return (int64_t) (avail - used);
481 }
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.
Definition: bandwidth.c:96
struct GNUNET_TIME_Relative GNUNET_TIME_absolute_get_duration(struct GNUNET_TIME_Absolute whence)
Get the duration of an operation as the difference of the current time and the given start time "henc...
Definition: time.c:435

References GNUNET_BANDWIDTH_Tracker::available_bytes_per_s__, GNUNET_BANDWIDTH_Tracker::consumption_since_last_update__, GNUNET_BANDWIDTH_value_get_available_until(), GNUNET_BANDWIDTH_value_init(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_TIME_absolute_get_duration(), GNUNET_BANDWIDTH_Tracker::last_update__, LOG, and update_tracker().

Here is the call graph for this function:

◆ GNUNET_BANDWIDTH_tracker_update_quota()

void GNUNET_BANDWIDTH_tracker_update_quota ( struct GNUNET_BANDWIDTH_Tracker av,
struct GNUNET_BANDWIDTH_Value32NBO  bytes_per_second_limit 
)

Update quota of bandwidth tracker.

Parameters
avtracker to initialize
bytes_per_second_limitnew limit to assume

Definition at line 491 of file bandwidth.c.

494 {
495  uint32_t old_limit;
496  uint32_t new_limit;
497 
498  new_limit = ntohl (bytes_per_second_limit.value__);
500  "Tracker %p bandwidth changed to %u Bps\n",
501  av,
502  (unsigned int) new_limit);
503  update_tracker (av);
504  old_limit = av->available_bytes_per_s__;
505  av->available_bytes_per_s__ = new_limit;
506  if (NULL != av->update_cb)
507  av->update_cb (av->update_cb_cls);
508  if (old_limit > new_limit)
509  update_tracker (av); /* maximum excess might be less now */
510  update_excess (av);
511 }

References GNUNET_BANDWIDTH_Tracker::available_bytes_per_s__, GNUNET_ERROR_TYPE_DEBUG, LOG, GNUNET_BANDWIDTH_Tracker::update_cb, GNUNET_BANDWIDTH_Tracker::update_cb_cls, update_excess(), update_tracker(), and GNUNET_BANDWIDTH_Value32NBO::value__.

Referenced by GAS_reservations_set_bandwidth(), handle_connect(), handle_set_quota(), and set_incoming_quota().

Here is the call graph for this function:
Here is the caller graph for this function: