From 5410702d6c31d4486766e111c6518d4c8814ddf3 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sat, 7 Mar 2015 19:35:26 +0000 Subject: trying to fix #3694: reduce duplicate ACKing --- src/include/gnunet_fragmentation_lib.h | 54 +++++++++++++++++++++------------- 1 file changed, 34 insertions(+), 20 deletions(-) (limited to 'src/include/gnunet_fragmentation_lib.h') diff --git a/src/include/gnunet_fragmentation_lib.h b/src/include/gnunet_fragmentation_lib.h index d8e50dcb0..2661fbe26 100644 --- a/src/include/gnunet_fragmentation_lib.h +++ b/src/include/gnunet_fragmentation_lib.h @@ -1,6 +1,6 @@ /* This file is part of GNUnet - Copyright (C) 2009, 2011 Christian Grothoff (and other contributing authors) + Copyright (C) 2009, 2011, 2015 Christian Grothoff (and other contributing authors) GNUnet is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published @@ -51,24 +51,24 @@ struct GNUNET_FRAGMENT_Context; /** * Function that is called with messages created by the fragmentation * module. In the case of the 'proc' callback of the - * GNUNET_FRAGMENT_context_create function, this function must - * eventually call 'GNUNET_FRAGMENT_context_transmission_done'. + * #GNUNET_FRAGMENT_context_create() function, this function must + * eventually call #GNUNET_FRAGMENT_context_transmission_done(). * * @param cls closure * @param msg the message that was created */ -typedef void (*GNUNET_FRAGMENT_MessageProcessor) (void *cls, - const struct - GNUNET_MessageHeader * msg); +typedef void +(*GNUNET_FRAGMENT_MessageProcessor) (void *cls, + const struct GNUNET_MessageHeader *msg); /** * Create a fragmentation context for the given message. - * Fragments the message into fragments of size "mtu" or - * less. Calls 'proc' on each un-acknowledged fragment, - * using both the expected 'delay' between messages and - * acknowledgements and the given 'tracker' to guide the - * frequency of calls to 'proc'. + * Fragments the message into fragments of size @a mtu or + * less. Calls @a proc on each un-acknowledged fragment, + * using both the expected @a msg_delay between messages and + * acknowledgements and the given @a tracker to guide the + * frequency of calls to @a proc. * * @param stats statistics context * @param mtu the maximum message size for each fragment @@ -110,10 +110,10 @@ GNUNET_FRAGMENT_context_transmission_done (struct GNUNET_FRAGMENT_Context *fc); * * @param fc fragmentation context * @param msg acknowledgement message we received - * @return GNUNET_OK if this ack completes the work of the 'fc' + * @return #GNUNET_OK if this ack completes the work of the 'fc' * (all fragments have been received); - * GNUNET_NO if more messages are pending - * GNUNET_SYSERR if this ack is not valid for this fc + * #GNUNET_NO if more messages are pending + * #GNUNET_SYSERR if this ack is not valid for this fc */ int GNUNET_FRAGMENT_process_ack (struct GNUNET_FRAGMENT_Context *fc, @@ -136,6 +136,16 @@ GNUNET_FRAGMENT_context_destroy (struct GNUNET_FRAGMENT_Context *fc, struct GNUNET_TIME_Relative *ack_delay); +/** + * Convert an ACK message to a printable format suitable for logging. + * + * @param ack message to print + * @return ack in human-readable format + */ +const char * +GNUNET_FRAGMENT_print_ack (const struct GNUNET_MessageHeader *ack); + + /** * Defragmentation context (one per connection). */ @@ -152,9 +162,10 @@ struct GNUNET_DEFRAGMENT_Context; * @param id unique message ID (modulo collisions) * @param msg the message that was created */ -typedef void (*GNUNET_DEFRAGMENT_AckProcessor) (void *cls, uint32_t id, - const struct - GNUNET_MessageHeader * msg); +typedef void +(*GNUNET_DEFRAGMENT_AckProcessor) (void *cls, + uint32_t id, + const struct GNUNET_MessageHeader *msg); /** @@ -164,7 +175,7 @@ typedef void (*GNUNET_DEFRAGMENT_AckProcessor) (void *cls, uint32_t id, * @param mtu the maximum message size for each fragment * @param num_msgs how many fragmented messages * to we defragment at most at the same time? - * @param cls closure for proc and ackp + * @param cls closure for @a proc and @a ackp * @param proc function to call with defragmented messages * @param ackp function to call with acknowledgements (to send * back to the other side) @@ -172,7 +183,8 @@ typedef void (*GNUNET_DEFRAGMENT_AckProcessor) (void *cls, uint32_t id, */ struct GNUNET_DEFRAGMENT_Context * GNUNET_DEFRAGMENT_context_create (struct GNUNET_STATISTICS_Handle *stats, - uint16_t mtu, unsigned int num_msgs, + uint16_t mtu, + unsigned int num_msgs, void *cls, GNUNET_FRAGMENT_MessageProcessor proc, GNUNET_DEFRAGMENT_AckProcessor ackp); @@ -192,7 +204,9 @@ GNUNET_DEFRAGMENT_context_destroy (struct GNUNET_DEFRAGMENT_Context *dc); * * @param dc the context * @param msg the message that was received - * @return GNUNET_OK on success, GNUNET_NO if this was a duplicate, GNUNET_SYSERR on error + * @return #GNUNET_OK on success, + * #GNUNET_NO if this was a duplicate, + * #GNUNET_SYSERR on error */ int GNUNET_DEFRAGMENT_process_fragment (struct GNUNET_DEFRAGMENT_Context *dc, -- cgit v1.2.3