33 #define MIN_ACK_DELAY GNUNET_TIME_relative_multiply ( \
34 GNUNET_TIME_UNIT_MILLISECONDS, 1)
149 static char buf[128];
154 return "<malformed ack>";
210 "Fragmentation logic delays transmission of next fragment by %s\n",
227 mbuf = (
const char *) &fc[1];
229 fh->header.size = htons (fsize);
239 _ (
"# fragments transmitted"),
244 _ (
"# fragments retransmitted"),
277 _ (
"# fragments wrap arounds"),
324 _ (
"# messages fragmented"),
330 _ (
"# total size of fragmented messages"),
399 unsigned int ack_cnt;
400 unsigned int snd_cnt;
424 for (i = 0; i < 64; i++)
429 if (0 == (abits & (1ULL << i)))
439 else if (snd_cnt > ack_cnt)
445 else if (snd_cnt == ack_cnt)
458 _ (
"# fragment acknowledgements received"),
461 if (abits != (fc->
acks & abits))
465 _ (
"# bits removed from fragmentation ACKs"), 1,
472 if (fc->
task != NULL)
489 _ (
"# fragmentation transmissions completed"),
492 if (NULL != fc->
task)
516 if (fc->
task != NULL)
518 if (NULL != ack_delay)
520 if (NULL != msg_delay)
struct GNUNET_MessageHeader * msg
static void transmit_next(void *cls)
Transmit the next fragment to the other peer.
#define MIN_ACK_DELAY
Absolute minimum delay we impose between sending and expecting ACK to arrive.
library to help fragment messages
static struct GNUNET_TIME_Relative delay
When should dkg communication start?
struct GNUNET_STATISTICS_Handle * stats
Handle to the statistics service.
static struct GNUNET_DISK_FileHandle * fh
File handle to STDIN, for reading restart/quit commands.
Constants for network protocols.
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.
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 g...
uint32_t GNUNET_CRYPTO_random_u32(enum GNUNET_CRYPTO_Quality mode, uint32_t i)
Produce a random value.
@ GNUNET_CRYPTO_QUALITY_WEAK
No good quality of the operation is needed (i.e., random numbers can be pseudo-random).
const char * GNUNET_FRAGMENT_print_ack(const struct GNUNET_MessageHeader *ack)
Convert an ACK message to a printable format suitable for logging.
void GNUNET_FRAGMENT_context_transmission_done(struct GNUNET_FRAGMENT_Context *fc)
Continuation to call from the 'proc' function after the fragment has been transmitted (and hence the ...
int GNUNET_FRAGMENT_process_ack(struct GNUNET_FRAGMENT_Context *fc, const struct GNUNET_MessageHeader *msg)
Process an acknowledgement message we got from the other side (to control re-transmits).
void(* GNUNET_FRAGMENT_MessageProcessor)(void *cls, const struct GNUNET_MessageHeader *msg)
Function that is called with messages created by the fragmentation module.
void GNUNET_FRAGMENT_context_destroy(struct GNUNET_FRAGMENT_Context *fc, struct GNUNET_TIME_Relative *msg_delay, struct GNUNET_TIME_Relative *ack_delay)
Destroy the given fragmentation context (stop calling 'proc', free resources).
struct GNUNET_FRAGMENT_Context * GNUNET_FRAGMENT_context_create(struct GNUNET_STATISTICS_Handle *stats, uint16_t mtu, struct GNUNET_BANDWIDTH_Tracker *tracker, struct GNUNET_TIME_Relative msg_delay, struct GNUNET_TIME_Relative ack_delay, const struct GNUNET_MessageHeader *msg, GNUNET_FRAGMENT_MessageProcessor proc, void *proc_cls)
Create a fragmentation context for the given message.
#define GNUNET_log(kind,...)
uint64_t GNUNET_ntohll(uint64_t n)
Convert unsigned 64-bit integer to host byte order.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
@ GNUNET_ERROR_TYPE_DEBUG
int GNUNET_snprintf(char *buf, size_t size, const char *format,...) __attribute__((format(printf
Like snprintf, just aborts if the buffer is of insufficient size.
#define GNUNET_malloc(size)
Wrapper around malloc.
#define GNUNET_free(ptr)
Wrapper around free.
#define GNUNET_MESSAGE_TYPE_FRAGMENT
FRAGMENT of a larger message.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_now(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run as soon as possible.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_at(struct GNUNET_TIME_Absolute at, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run at the specified time.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_delayed(struct GNUNET_TIME_Relative delay, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay.
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_TIME_Relative GNUNET_TIME_relative_min(struct GNUNET_TIME_Relative t1, struct GNUNET_TIME_Relative t2)
Return the minimum of two relative time values.
#define GNUNET_TIME_UNIT_FOREVER_REL
Constant used to specify "forever".
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...
struct GNUNET_TIME_Relative GNUNET_TIME_relative_saturating_multiply(struct GNUNET_TIME_Relative rel, unsigned long long factor)
Saturating multiply relative time by a given factor.
struct GNUNET_TIME_Relative GNUNET_TIME_relative_max(struct GNUNET_TIME_Relative t1, struct GNUNET_TIME_Relative t2)
Return the maximum of two relative time values.
#define GNUNET_TIME_UNIT_SECONDS
One second.
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
struct GNUNET_TIME_Absolute GNUNET_TIME_relative_to_absolute(struct GNUNET_TIME_Relative rel)
Convert relative time to an absolute time in the future.
#define GNUNET_TIME_UNIT_ZERO
Relative time zero.
const char * GNUNET_STRINGS_relative_time_to_string(struct GNUNET_TIME_Relative delta, int do_round)
Give relative time in human-readable fancy format.
static unsigned int size
Size of the "table".
Message fragment acknowledgement.
uint32_t fragment_id
Unique fragment ID.
uint64_t bits
Bits that are being acknowledged, in big-endian.
Struct to track available bandwidth.
struct GNUNET_TIME_Absolute last_round
Time we transmitted the last message of the last round.
uint32_t fragment_id
Our fragmentation ID.
int8_t wack
GNUNET_YES if we are waiting for an ACK.
struct GNUNET_TIME_Relative ack_delay
Current expected delay for ACKs.
unsigned int next_transmission
Round-robin selector for the next transmission.
GNUNET_FRAGMENT_MessageProcessor proc
Function to call for transmissions.
struct GNUNET_TIME_Relative msg_delay
Current expected delay between messages.
struct GNUNET_SCHEDULER_Task * task
Task performing work for the fragmenter.
const struct GNUNET_MessageHeader * msg
Message to fragment (allocated at the end of this struct).
unsigned int num_rounds
How many rounds of transmission have we completed so far?
int8_t proc_busy
GNUNET_YES if we called proc and are now waiting for GNUNET_FRAGMENT_context_transmission_done()
void * proc_cls
Closure for proc.
uint64_t acks_mask
Bitfield with all possible bits for acks (used to mask the ack we get back).
unsigned int num_transmissions
How many transmission have we completed in this round?
uint16_t mtu
Target fragment size.
struct GNUNET_TIME_Absolute delay_until
Next allowed transmission time.
uint64_t acks
Bitfield, set to 1 for each unacknowledged fragment.
struct GNUNET_STATISTICS_Handle * stats
Statistics to use.
struct GNUNET_BANDWIDTH_Tracker * tracker
Tracker for flow control.
Entry in list of pending tasks.
Time for absolute times used by GNUnet, in microseconds.
uint64_t abs_value_us
The actual value.
Time for relative time used by GNUnet, in microseconds.
uint64_t rel_value_us
The actual value.