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/fragmentation/fragmentation.c | |
parent | cd0ad4c559f9338eec2a152ded51d16e021eca06 (diff) | |
download | gnunet-5410702d6c31d4486766e111c6518d4c8814ddf3.tar.gz gnunet-5410702d6c31d4486766e111c6518d4c8814ddf3.zip |
trying to fix #3694: reduce duplicate ACKing
Diffstat (limited to 'src/fragmentation/fragmentation.c')
-rw-r--r-- | src/fragmentation/fragmentation.c | 56 |
1 files changed, 41 insertions, 15 deletions
diff --git a/src/fragmentation/fragmentation.c b/src/fragmentation/fragmentation.c index 930fffcc6..ca5ca2ac9 100644 --- a/src/fragmentation/fragmentation.c +++ b/src/fragmentation/fragmentation.c | |||
@@ -80,7 +80,7 @@ struct GNUNET_FRAGMENT_Context | |||
80 | GNUNET_FRAGMENT_MessageProcessor proc; | 80 | GNUNET_FRAGMENT_MessageProcessor proc; |
81 | 81 | ||
82 | /** | 82 | /** |
83 | * Closure for 'proc'. | 83 | * Closure for @e proc. |
84 | */ | 84 | */ |
85 | void *proc_cls; | 85 | void *proc_cls; |
86 | 86 | ||
@@ -98,7 +98,7 @@ struct GNUNET_FRAGMENT_Context | |||
98 | /** | 98 | /** |
99 | * Task performing work for the fragmenter. | 99 | * Task performing work for the fragmenter. |
100 | */ | 100 | */ |
101 | struct GNUNET_SCHEDULER_Task * task; | 101 | struct GNUNET_SCHEDULER_Task *task; |
102 | 102 | ||
103 | /** | 103 | /** |
104 | * Our fragmentation ID. (chosen at random) | 104 | * Our fragmentation ID. (chosen at random) |
@@ -121,12 +121,12 @@ struct GNUNET_FRAGMENT_Context | |||
121 | unsigned int num_transmissions; | 121 | unsigned int num_transmissions; |
122 | 122 | ||
123 | /** | 123 | /** |
124 | * GNUNET_YES if we called 'proc' and are now waiting for 'GNUNET_FRAGMENT_transmission_done' | 124 | * #GNUNET_YES if we called @e proc and are now waiting for #GNUNET_FRAGMENT_transmission_done() |
125 | */ | 125 | */ |
126 | int8_t proc_busy; | 126 | int8_t proc_busy; |
127 | 127 | ||
128 | /** | 128 | /** |
129 | * GNUNET_YES if we are waiting for an ACK. | 129 | * #GNUNET_YES if we are waiting for an ACK. |
130 | */ | 130 | */ |
131 | int8_t wack; | 131 | int8_t wack; |
132 | 132 | ||
@@ -139,13 +139,39 @@ struct GNUNET_FRAGMENT_Context | |||
139 | 139 | ||
140 | 140 | ||
141 | /** | 141 | /** |
142 | * Convert an ACK message to a printable format suitable for logging. | ||
143 | * | ||
144 | * @param ack message to print | ||
145 | * @return ack in human-readable format | ||
146 | */ | ||
147 | const char * | ||
148 | GNUNET_FRAGMENT_print_ack (const struct GNUNET_MessageHeader *ack) | ||
149 | { | ||
150 | static char buf[128]; | ||
151 | const struct FragmentAcknowledgement *fa; | ||
152 | |||
153 | if (sizeof (struct FragmentAcknowledgement) != | ||
154 | htons (ack->size)) | ||
155 | return "<malformed ack>"; | ||
156 | fa = (const struct FragmentAcknowledgement *) ack; | ||
157 | GNUNET_snprintf (buf, | ||
158 | sizeof (buf), | ||
159 | "%u-%llX", | ||
160 | ntohl (fa->fragment_id), | ||
161 | GNUNET_ntohll (fa->bits)); | ||
162 | return buf; | ||
163 | } | ||
164 | |||
165 | |||
166 | /** | ||
142 | * Transmit the next fragment to the other peer. | 167 | * Transmit the next fragment to the other peer. |
143 | * | 168 | * |
144 | * @param cls the 'struct GNUNET_FRAGMENT_Context' | 169 | * @param cls the `struct GNUNET_FRAGMENT_Context` |
145 | * @param tc scheduler context | 170 | * @param tc scheduler context |
146 | */ | 171 | */ |
147 | static void | 172 | static void |
148 | transmit_next (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 173 | transmit_next (void *cls, |
174 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
149 | { | 175 | { |
150 | struct GNUNET_FRAGMENT_Context *fc = cls; | 176 | struct GNUNET_FRAGMENT_Context *fc = cls; |
151 | char msg[fc->mtu]; | 177 | char msg[fc->mtu]; |
@@ -246,11 +272,11 @@ transmit_next (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
246 | 272 | ||
247 | /** | 273 | /** |
248 | * Create a fragmentation context for the given message. | 274 | * Create a fragmentation context for the given message. |
249 | * Fragments the message into fragments of size "mtu" or | 275 | * Fragments the message into fragments of size @a mtu or |
250 | * less. Calls 'proc' on each un-acknowledged fragment, | 276 | * less. Calls @a proc on each un-acknowledged fragment, |
251 | * using both the expected 'delay' between messages and | 277 | * using both the expected @a msg_delay between messages and |
252 | * acknowledgements and the given 'tracker' to guide the | 278 | * acknowledgements and the given @a tracker to guide the |
253 | * frequency of calls to 'proc'. | 279 | * frequency of calls to @a proc. |
254 | * | 280 | * |
255 | * @param stats statistics context | 281 | * @param stats statistics context |
256 | * @param mtu the maximum message size for each fragment | 282 | * @param mtu the maximum message size for each fragment |
@@ -261,7 +287,7 @@ transmit_next (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
261 | * and ACK based on previous messages | 287 | * and ACK based on previous messages |
262 | * @param msg the message to fragment | 288 | * @param msg the message to fragment |
263 | * @param proc function to call for each fragment to transmit | 289 | * @param proc function to call for each fragment to transmit |
264 | * @param proc_cls closure for proc | 290 | * @param proc_cls closure for @a proc |
265 | * @return the fragmentation context | 291 | * @return the fragmentation context |
266 | */ | 292 | */ |
267 | struct GNUNET_FRAGMENT_Context * | 293 | struct GNUNET_FRAGMENT_Context * |
@@ -336,10 +362,10 @@ GNUNET_FRAGMENT_context_transmission_done (struct GNUNET_FRAGMENT_Context *fc) | |||
336 | * | 362 | * |
337 | * @param fc fragmentation context | 363 | * @param fc fragmentation context |
338 | * @param msg acknowledgement message we received | 364 | * @param msg acknowledgement message we received |
339 | * @return GNUNET_OK if this ack completes the work of the 'fc' | 365 | * @return #GNUNET_OK if this ack completes the work of the 'fc' |
340 | * (all fragments have been received); | 366 | * (all fragments have been received); |
341 | * GNUNET_NO if more messages are pending | 367 | * #GNUNET_NO if more messages are pending |
342 | * GNUNET_SYSERR if this ack is not valid for this fc | 368 | * #GNUNET_SYSERR if this ack is not valid for this fc |
343 | */ | 369 | */ |
344 | int | 370 | int |
345 | GNUNET_FRAGMENT_process_ack (struct GNUNET_FRAGMENT_Context *fc, | 371 | GNUNET_FRAGMENT_process_ack (struct GNUNET_FRAGMENT_Context *fc, |