GNUnet  0.19.5
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 155 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 171 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 79 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 88 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.

41 {
43 
44  ret.value__ = htonl (bytes_per_second);
45  return ret;
46 }
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 97 of file bandwidth.c.

100 {
101  uint64_t b;
102 
103  b = ntohl (bps.value__);
105  "Bandwidth has %llu bytes available until deadline in %s\n",
106  (unsigned long long) ((b * deadline.rel_value_us + 500000LL)
107  / 1000000LL),
109  return (b * deadline.rel_value_us + 500000LL) / 1000000LL;
110 }
#define LOG(kind,...)
Definition: bandwidth.c:31
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:569
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 97 of file bandwidth.c.

124 {
125  uint64_t b;
126  struct GNUNET_TIME_Relative ret;
127 
128  b = ntohl (bps.value__);
129  if (0 == b)
130  {
132  "Bandwidth suggests delay of infinity (zero bandwidth)\n");
134  }
135  ret.rel_value_us = size * 1000LL * 1000LL / b;
137  "Bandwidth suggests delay of %s for %llu bytes of traffic\n",
139  (unsigned long long) size);
140  return ret;
141 }
#define GNUNET_TIME_UNIT_FOREVER_REL
Constant used to specify "forever".
static unsigned int size
Size of the "table".
Definition: peer.c:68
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.

59 {
61  GNUNET_MIN (ntohl (b1.value__), ntohl (b2.value__)));
62 }
struct GNUNET_BANDWIDTH_Value32NBO GNUNET_BANDWIDTH_value_init(uint32_t bytes_per_second)
Create a new bandwidth value.
Definition: bandwidth.c:40
#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.

75 {
77  GNUNET_MAX (ntohl (b1.value__), ntohl (b2.value__)));
78 }
#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.

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

◆ 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 279 of file bandwidth.c.

285 {
287  update_cb,
288  update_cb_cls,
289  bytes_per_second_limit,
290  max_carry_s,
291  NULL,
292  NULL);
293 }
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:252

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 252 of file bandwidth.c.

260 {
261  av->update_cb = update_cb;
262  av->update_cb_cls = update_cb_cls;
265  av->available_bytes_per_s__ = ntohl (bytes_per_second_limit.value__);
266  av->max_carry_s__ = max_carry_s;
267  av->excess_cb = excess_cb;
268  av->excess_cb_cls = excess_cb_cls;
270  "Tracker %p initialized with %u Bps and max carry %u\n",
271  av,
272  (unsigned int) av->available_bytes_per_s__,
273  (unsigned int) max_carry_s);
274  update_excess (av);
275 }
static void update_excess(struct GNUNET_BANDWIDTH_Tracker *av)
Recalculate when we might need to call the excess callback.
Definition: bandwidth.c:168
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
Definition: time.c:111
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 302 of file bandwidth.c.

303 {
304  if (NULL != av->excess_task)
306  av->excess_task = NULL;
307  av->excess_cb = NULL;
308  av->excess_cb_cls = NULL;
309  av->update_cb = NULL;
310  av->update_cb_cls = NULL;
311 }
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:975
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 368 of file bandwidth.c.

370 {
371  int64_t nc;
372 
374  "Tracker %p consumes %d bytes\n",
375  av,
376  (int) size);
377  if (size > 0)
378  {
380  if (nc < av->consumption_since_last_update__)
381  {
382  /* integer overflow, very bad */
383  GNUNET_break (0);
384  return GNUNET_SYSERR;
385  }
387  update_tracker (av);
388  update_excess (av);
390  {
392  "Tracker %p consumption %llu bytes above limit\n",
393  av,
394  (unsigned long long) av->consumption_since_last_update__);
395  return GNUNET_YES;
396  }
397  }
398  else
399  {
402  {
403  /* integer underflow, very bad */
404  GNUNET_break (0);
405  return GNUNET_SYSERR;
406  }
408  update_excess (av);
409  }
410  return GNUNET_NO;
411 }
static void update_tracker(struct GNUNET_BANDWIDTH_Tracker *av)
Update the tracker, looking at the current time and bandwidth consumption data.
Definition: bandwidth.c:321
static struct GNUNET_PEERINFO_NotifyContext * nc
Iterator context.
@ GNUNET_NO
@ GNUNET_SYSERR
#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 368 of file bandwidth.c.

426 {
427  struct GNUNET_TIME_Relative ret;
428  int64_t bytes_needed;
429 
430  if (0 == av->available_bytes_per_s__)
431  {
432  LOG (GNUNET_ERROR_TYPE_DEBUG, "Tracker %p delay is infinity\n", av);
434  }
435  update_tracker (av);
436  bytes_needed = size + av->consumption_since_last_update__;
437  if (bytes_needed <= 0)
438  {
440  "Tracker %p delay for %u bytes is zero\n",
441  av,
442  (unsigned int) size);
443  return GNUNET_TIME_UNIT_ZERO;
444  }
445  ret.rel_value_us = (1000LL * 1000LL * bytes_needed)
446  / (unsigned long long) av->available_bytes_per_s__;
448  "Tracker %p delay for %u bytes is %s\n",
449  av,
450  (unsigned int) size,
452  return ret;
453 }
#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 464 of file bandwidth.c.

465 {
466  struct GNUNET_BANDWIDTH_Value32NBO bps;
467  uint64_t avail;
468  int64_t used;
469 
470  update_tracker (av);
472  avail =
475  av->last_update__));
478  "Tracker %p available bandwidth is %lld bytes\n",
479  av,
480  (long long) (int64_t) (avail - used));
481  return (int64_t) (avail - used);
482 }
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:97
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:436

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 492 of file bandwidth.c.

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

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: