aboutsummaryrefslogtreecommitdiff
path: root/src/fragmentation/defragmentation.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2015-03-25 14:31:03 +0000
committerChristian Grothoff <christian@grothoff.org>2015-03-25 14:31:03 +0000
commit00f87691363acaf94f533793654e610e46bf4e1d (patch)
tree7598432b2335d378d240dcba84aabea7e0f31a14 /src/fragmentation/defragmentation.c
parentf1ba43deea5e7a1fbc22b429196d1f9fb4e1a9f3 (diff)
downloadgnunet-00f87691363acaf94f533793654e610e46bf4e1d.tar.gz
gnunet-00f87691363acaf94f533793654e610e46bf4e1d.zip
-trying to fix AE's problem on Guix with more fancy retransmission logic
Diffstat (limited to 'src/fragmentation/defragmentation.c')
-rw-r--r--src/fragmentation/defragmentation.c27
1 files changed, 18 insertions, 9 deletions
diff --git a/src/fragmentation/defragmentation.c b/src/fragmentation/defragmentation.c
index 5c4a68416..a89084287 100644
--- a/src/fragmentation/defragmentation.c
+++ b/src/fragmentation/defragmentation.c
@@ -109,13 +109,13 @@ struct MessageContext
109 109
110 /** 110 /**
111 * For the current ACK round, which is the first relevant 111 * For the current ACK round, which is the first relevant
112 * offset in 'frag_times'? 112 * offset in @e frag_times?
113 */ 113 */
114 unsigned int frag_times_start_offset; 114 unsigned int frag_times_start_offset;
115 115
116 /** 116 /**
117 * Which offset whould we write the next frag value into 117 * Which offset whould we write the next frag value into
118 * in the 'frag_times' array? All smaller entries are valid. 118 * in the @e frag_times array? All smaller entries are valid.
119 */ 119 */
120 unsigned int frag_times_write_offset; 120 unsigned int frag_times_write_offset;
121 121
@@ -124,6 +124,11 @@ struct MessageContext
124 */ 124 */
125 uint16_t total_size; 125 uint16_t total_size;
126 126
127 /**
128 * Was the last fragment we got a duplicate?
129 */
130 int16_t last_duplicate;
131
127}; 132};
128 133
129 134
@@ -185,6 +190,7 @@ struct GNUNET_DEFRAGMENT_Context
185 * Maximum message size for each fragment. 190 * Maximum message size for each fragment.
186 */ 191 */
187 uint16_t mtu; 192 uint16_t mtu;
193
188}; 194};
189 195
190 196
@@ -271,6 +277,7 @@ send_ack (void *cls,
271 _("# acknowledgements sent for fragment"), 277 _("# acknowledgements sent for fragment"),
272 1, 278 1,
273 GNUNET_NO); 279 GNUNET_NO);
280 mc->last_duplicate = GNUNET_NO; /* clear flag */
274 dc->ackp (dc->cls, 281 dc->ackp (dc->cls,
275 mc->fragment_id, 282 mc->fragment_id,
276 &fa.header); 283 &fa.header);
@@ -535,11 +542,13 @@ GNUNET_DEFRAGMENT_process_fragment (struct GNUNET_DEFRAGMENT_Context *dc,
535 GNUNET_NO); 542 GNUNET_NO);
536 } 543 }
537 544
538 /* count number of missing fragments */ 545 /* count number of missing fragments after the current one */
539 bc = 0; 546 bc = 0;
540 for (b = 0; b < 64; b++) 547 for (b = bit; b < 64; b++)
541 if (0 != (mc->bits & (1LL << b))) 548 if (0 != (mc->bits & (1LL << b)))
542 bc++; 549 bc++;
550 else
551 bc = 0;
543 552
544 /* notify about complete message */ 553 /* notify about complete message */
545 if ( (GNUNET_NO == duplicate) && 554 if ( (GNUNET_NO == duplicate) &&
@@ -560,23 +569,23 @@ GNUNET_DEFRAGMENT_process_fragment (struct GNUNET_DEFRAGMENT_Context *dc,
560 delay = GNUNET_TIME_relative_multiply (dc->latency, 569 delay = GNUNET_TIME_relative_multiply (dc->latency,
561 bc + 1); 570 bc + 1);
562 if ( (last + fid == num_fragments) || 571 if ( (last + fid == num_fragments) ||
563 ( (0 == mc->bits) && 572 (0 == mc->bits) ||
564 (GNUNET_YES != duplicate)) ) 573 (GNUNET_YES == duplicate) )
565 { 574 {
566 /* message complete or duplicate or last missing fragment in 575 /* message complete or duplicate or last missing fragment in
567 linear sequence; ACK now! */ 576 linear sequence; ACK now! */
568 delay = GNUNET_TIME_UNIT_ZERO; 577 delay = GNUNET_TIME_UNIT_ZERO;
569 } 578 }
570 if (GNUNET_YES == duplicate)
571 delay = GNUNET_TIME_relative_multiply (delay,
572 2);
573 if (NULL != mc->ack_task) 579 if (NULL != mc->ack_task)
574 GNUNET_SCHEDULER_cancel (mc->ack_task); 580 GNUNET_SCHEDULER_cancel (mc->ack_task);
575 mc->ack_task = GNUNET_SCHEDULER_add_delayed (delay, 581 mc->ack_task = GNUNET_SCHEDULER_add_delayed (delay,
576 &send_ack, 582 &send_ack,
577 mc); 583 mc);
578 if (GNUNET_YES == duplicate) 584 if (GNUNET_YES == duplicate)
585 {
586 mc->last_duplicate = GNUNET_YES;
579 return GNUNET_NO; 587 return GNUNET_NO;
588 }
580 return GNUNET_YES; 589 return GNUNET_YES;
581} 590}
582 591