diff options
author | Christian Grothoff <christian@grothoff.org> | 2015-03-07 19:35:26 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2015-03-07 19:35:26 +0000 |
commit | 5410702d6c31d4486766e111c6518d4c8814ddf3 (patch) | |
tree | 61f6e955454ce0f2ab5cf0ef33654b3ab44927c3 /src/include/gnunet_fragmentation_lib.h | |
parent | cd0ad4c559f9338eec2a152ded51d16e021eca06 (diff) | |
download | gnunet-5410702d6c31d4486766e111c6518d4c8814ddf3.tar.gz gnunet-5410702d6c31d4486766e111c6518d4c8814ddf3.zip |
trying to fix #3694: reduce duplicate ACKing
Diffstat (limited to 'src/include/gnunet_fragmentation_lib.h')
-rw-r--r-- | src/include/gnunet_fragmentation_lib.h | 54 |
1 files changed, 34 insertions, 20 deletions
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 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet | 2 | This file is part of GNUnet |
3 | Copyright (C) 2009, 2011 Christian Grothoff (and other contributing authors) | 3 | Copyright (C) 2009, 2011, 2015 Christian Grothoff (and other contributing authors) |
4 | 4 | ||
5 | GNUnet is free software; you can redistribute it and/or modify | 5 | GNUnet is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published | 6 | it under the terms of the GNU General Public License as published |
@@ -51,24 +51,24 @@ struct GNUNET_FRAGMENT_Context; | |||
51 | /** | 51 | /** |
52 | * Function that is called with messages created by the fragmentation | 52 | * Function that is called with messages created by the fragmentation |
53 | * module. In the case of the 'proc' callback of the | 53 | * module. In the case of the 'proc' callback of the |
54 | * GNUNET_FRAGMENT_context_create function, this function must | 54 | * #GNUNET_FRAGMENT_context_create() function, this function must |
55 | * eventually call 'GNUNET_FRAGMENT_context_transmission_done'. | 55 | * eventually call #GNUNET_FRAGMENT_context_transmission_done(). |
56 | * | 56 | * |
57 | * @param cls closure | 57 | * @param cls closure |
58 | * @param msg the message that was created | 58 | * @param msg the message that was created |
59 | */ | 59 | */ |
60 | typedef void (*GNUNET_FRAGMENT_MessageProcessor) (void *cls, | 60 | typedef void |
61 | const struct | 61 | (*GNUNET_FRAGMENT_MessageProcessor) (void *cls, |
62 | GNUNET_MessageHeader * msg); | 62 | const struct GNUNET_MessageHeader *msg); |
63 | 63 | ||
64 | 64 | ||
65 | /** | 65 | /** |
66 | * Create a fragmentation context for the given message. | 66 | * Create a fragmentation context for the given message. |
67 | * Fragments the message into fragments of size "mtu" or | 67 | * Fragments the message into fragments of size @a mtu or |
68 | * less. Calls 'proc' on each un-acknowledged fragment, | 68 | * less. Calls @a proc on each un-acknowledged fragment, |
69 | * using both the expected 'delay' between messages and | 69 | * using both the expected @a msg_delay between messages and |
70 | * acknowledgements and the given 'tracker' to guide the | 70 | * acknowledgements and the given @a tracker to guide the |
71 | * frequency of calls to 'proc'. | 71 | * frequency of calls to @a proc. |
72 | * | 72 | * |
73 | * @param stats statistics context | 73 | * @param stats statistics context |
74 | * @param mtu the maximum message size for each fragment | 74 | * @param mtu the maximum message size for each fragment |
@@ -110,10 +110,10 @@ GNUNET_FRAGMENT_context_transmission_done (struct GNUNET_FRAGMENT_Context *fc); | |||
110 | * | 110 | * |
111 | * @param fc fragmentation context | 111 | * @param fc fragmentation context |
112 | * @param msg acknowledgement message we received | 112 | * @param msg acknowledgement message we received |
113 | * @return GNUNET_OK if this ack completes the work of the 'fc' | 113 | * @return #GNUNET_OK if this ack completes the work of the 'fc' |
114 | * (all fragments have been received); | 114 | * (all fragments have been received); |
115 | * GNUNET_NO if more messages are pending | 115 | * #GNUNET_NO if more messages are pending |
116 | * GNUNET_SYSERR if this ack is not valid for this fc | 116 | * #GNUNET_SYSERR if this ack is not valid for this fc |
117 | */ | 117 | */ |
118 | int | 118 | int |
119 | GNUNET_FRAGMENT_process_ack (struct GNUNET_FRAGMENT_Context *fc, | 119 | GNUNET_FRAGMENT_process_ack (struct GNUNET_FRAGMENT_Context *fc, |
@@ -137,6 +137,16 @@ GNUNET_FRAGMENT_context_destroy (struct GNUNET_FRAGMENT_Context *fc, | |||
137 | 137 | ||
138 | 138 | ||
139 | /** | 139 | /** |
140 | * Convert an ACK message to a printable format suitable for logging. | ||
141 | * | ||
142 | * @param ack message to print | ||
143 | * @return ack in human-readable format | ||
144 | */ | ||
145 | const char * | ||
146 | GNUNET_FRAGMENT_print_ack (const struct GNUNET_MessageHeader *ack); | ||
147 | |||
148 | |||
149 | /** | ||
140 | * Defragmentation context (one per connection). | 150 | * Defragmentation context (one per connection). |
141 | */ | 151 | */ |
142 | struct GNUNET_DEFRAGMENT_Context; | 152 | struct GNUNET_DEFRAGMENT_Context; |
@@ -152,9 +162,10 @@ struct GNUNET_DEFRAGMENT_Context; | |||
152 | * @param id unique message ID (modulo collisions) | 162 | * @param id unique message ID (modulo collisions) |
153 | * @param msg the message that was created | 163 | * @param msg the message that was created |
154 | */ | 164 | */ |
155 | typedef void (*GNUNET_DEFRAGMENT_AckProcessor) (void *cls, uint32_t id, | 165 | typedef void |
156 | const struct | 166 | (*GNUNET_DEFRAGMENT_AckProcessor) (void *cls, |
157 | GNUNET_MessageHeader * msg); | 167 | uint32_t id, |
168 | const struct GNUNET_MessageHeader *msg); | ||
158 | 169 | ||
159 | 170 | ||
160 | /** | 171 | /** |
@@ -164,7 +175,7 @@ typedef void (*GNUNET_DEFRAGMENT_AckProcessor) (void *cls, uint32_t id, | |||
164 | * @param mtu the maximum message size for each fragment | 175 | * @param mtu the maximum message size for each fragment |
165 | * @param num_msgs how many fragmented messages | 176 | * @param num_msgs how many fragmented messages |
166 | * to we defragment at most at the same time? | 177 | * to we defragment at most at the same time? |
167 | * @param cls closure for proc and ackp | 178 | * @param cls closure for @a proc and @a ackp |
168 | * @param proc function to call with defragmented messages | 179 | * @param proc function to call with defragmented messages |
169 | * @param ackp function to call with acknowledgements (to send | 180 | * @param ackp function to call with acknowledgements (to send |
170 | * back to the other side) | 181 | * back to the other side) |
@@ -172,7 +183,8 @@ typedef void (*GNUNET_DEFRAGMENT_AckProcessor) (void *cls, uint32_t id, | |||
172 | */ | 183 | */ |
173 | struct GNUNET_DEFRAGMENT_Context * | 184 | struct GNUNET_DEFRAGMENT_Context * |
174 | GNUNET_DEFRAGMENT_context_create (struct GNUNET_STATISTICS_Handle *stats, | 185 | GNUNET_DEFRAGMENT_context_create (struct GNUNET_STATISTICS_Handle *stats, |
175 | uint16_t mtu, unsigned int num_msgs, | 186 | uint16_t mtu, |
187 | unsigned int num_msgs, | ||
176 | void *cls, | 188 | void *cls, |
177 | GNUNET_FRAGMENT_MessageProcessor proc, | 189 | GNUNET_FRAGMENT_MessageProcessor proc, |
178 | GNUNET_DEFRAGMENT_AckProcessor ackp); | 190 | GNUNET_DEFRAGMENT_AckProcessor ackp); |
@@ -192,7 +204,9 @@ GNUNET_DEFRAGMENT_context_destroy (struct GNUNET_DEFRAGMENT_Context *dc); | |||
192 | * | 204 | * |
193 | * @param dc the context | 205 | * @param dc the context |
194 | * @param msg the message that was received | 206 | * @param msg the message that was received |
195 | * @return GNUNET_OK on success, GNUNET_NO if this was a duplicate, GNUNET_SYSERR on error | 207 | * @return #GNUNET_OK on success, |
208 | * #GNUNET_NO if this was a duplicate, | ||
209 | * #GNUNET_SYSERR on error | ||
196 | */ | 210 | */ |
197 | int | 211 | int |
198 | GNUNET_DEFRAGMENT_process_fragment (struct GNUNET_DEFRAGMENT_Context *dc, | 212 | GNUNET_DEFRAGMENT_process_fragment (struct GNUNET_DEFRAGMENT_Context *dc, |