diff options
author | Christian Grothoff <christian@grothoff.org> | 2015-03-25 14:31:03 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2015-03-25 14:31:03 +0000 |
commit | 00f87691363acaf94f533793654e610e46bf4e1d (patch) | |
tree | 7598432b2335d378d240dcba84aabea7e0f31a14 /src/fragmentation/fragmentation.c | |
parent | f1ba43deea5e7a1fbc22b429196d1f9fb4e1a9f3 (diff) | |
download | gnunet-00f87691363acaf94f533793654e610e46bf4e1d.tar.gz gnunet-00f87691363acaf94f533793654e610e46bf4e1d.zip |
-trying to fix AE's problem on Guix with more fancy retransmission logic
Diffstat (limited to 'src/fragmentation/fragmentation.c')
-rw-r--r-- | src/fragmentation/fragmentation.c | 41 |
1 files changed, 28 insertions, 13 deletions
diff --git a/src/fragmentation/fragmentation.c b/src/fragmentation/fragmentation.c index 9f4a91447..9566444cb 100644 --- a/src/fragmentation/fragmentation.c +++ b/src/fragmentation/fragmentation.c | |||
@@ -231,10 +231,14 @@ transmit_next (void *cls, | |||
231 | fsize - sizeof (struct FragmentHeader)); | 231 | fsize - sizeof (struct FragmentHeader)); |
232 | if (NULL != fc->tracker) | 232 | if (NULL != fc->tracker) |
233 | GNUNET_BANDWIDTH_tracker_consume (fc->tracker, fsize); | 233 | GNUNET_BANDWIDTH_tracker_consume (fc->tracker, fsize); |
234 | GNUNET_STATISTICS_update (fc->stats, _("# fragments transmitted"), 1, | 234 | GNUNET_STATISTICS_update (fc->stats, |
235 | _("# fragments transmitted"), | ||
236 | 1, | ||
235 | GNUNET_NO); | 237 | GNUNET_NO); |
236 | if (0 != fc->last_round.abs_value_us) | 238 | if (0 != fc->last_round.abs_value_us) |
237 | GNUNET_STATISTICS_update (fc->stats, _("# fragments retransmitted"), 1, | 239 | GNUNET_STATISTICS_update (fc->stats, |
240 | _("# fragments retransmitted"), | ||
241 | 1, | ||
238 | GNUNET_NO); | 242 | GNUNET_NO); |
239 | 243 | ||
240 | /* select next message to calculate delay */ | 244 | /* select next message to calculate delay */ |
@@ -245,7 +249,8 @@ transmit_next (void *cls, | |||
245 | else | 249 | else |
246 | fsize = fc->mtu; | 250 | fsize = fc->mtu; |
247 | if (NULL != fc->tracker) | 251 | if (NULL != fc->tracker) |
248 | delay = GNUNET_BANDWIDTH_tracker_get_delay (fc->tracker, fsize); | 252 | delay = GNUNET_BANDWIDTH_tracker_get_delay (fc->tracker, |
253 | fsize); | ||
249 | else | 254 | else |
250 | delay = GNUNET_TIME_UNIT_ZERO; | 255 | delay = GNUNET_TIME_UNIT_ZERO; |
251 | delay = GNUNET_TIME_relative_max (delay, | 256 | delay = GNUNET_TIME_relative_max (delay, |
@@ -260,7 +265,9 @@ transmit_next (void *cls, | |||
260 | delay = GNUNET_TIME_relative_max (MIN_ACK_DELAY, delay); | 265 | delay = GNUNET_TIME_relative_max (MIN_ACK_DELAY, delay); |
261 | fc->wack = GNUNET_YES; | 266 | fc->wack = GNUNET_YES; |
262 | fc->last_round = GNUNET_TIME_absolute_get (); | 267 | fc->last_round = GNUNET_TIME_absolute_get (); |
263 | GNUNET_STATISTICS_update (fc->stats, _("# fragments wrap arounds"), 1, | 268 | GNUNET_STATISTICS_update (fc->stats, |
269 | _("# fragments wrap arounds"), | ||
270 | 1, | ||
264 | GNUNET_NO); | 271 | GNUNET_NO); |
265 | } | 272 | } |
266 | fc->proc_busy = GNUNET_YES; | 273 | fc->proc_busy = GNUNET_YES; |
@@ -304,10 +311,14 @@ GNUNET_FRAGMENT_context_create (struct GNUNET_STATISTICS_Handle *stats, | |||
304 | size_t size; | 311 | size_t size; |
305 | uint64_t bits; | 312 | uint64_t bits; |
306 | 313 | ||
307 | GNUNET_STATISTICS_update (stats, _("# messages fragmented"), 1, GNUNET_NO); | 314 | GNUNET_STATISTICS_update (stats, |
315 | _("# messages fragmented"), | ||
316 | 1, | ||
317 | GNUNET_NO); | ||
308 | GNUNET_assert (mtu >= 1024 + sizeof (struct FragmentHeader)); | 318 | GNUNET_assert (mtu >= 1024 + sizeof (struct FragmentHeader)); |
309 | size = ntohs (msg->size); | 319 | size = ntohs (msg->size); |
310 | GNUNET_STATISTICS_update (stats, _("# total size of fragmented messages"), | 320 | GNUNET_STATISTICS_update (stats, |
321 | _("# total size of fragmented messages"), | ||
311 | size, GNUNET_NO); | 322 | size, GNUNET_NO); |
312 | GNUNET_assert (size >= sizeof (struct GNUNET_MessageHeader)); | 323 | GNUNET_assert (size >= sizeof (struct GNUNET_MessageHeader)); |
313 | fc = GNUNET_malloc (sizeof (struct GNUNET_FRAGMENT_Context) + size); | 324 | fc = GNUNET_malloc (sizeof (struct GNUNET_FRAGMENT_Context) + size); |
@@ -395,7 +406,6 @@ GNUNET_FRAGMENT_process_ack (struct GNUNET_FRAGMENT_Context *fc, | |||
395 | ndelay = GNUNET_TIME_absolute_get_duration (fc->last_round); | 406 | ndelay = GNUNET_TIME_absolute_get_duration (fc->last_round); |
396 | fc->ack_delay.rel_value_us = | 407 | fc->ack_delay.rel_value_us = |
397 | (ndelay.rel_value_us / fc->num_transmissions + 3 * fc->ack_delay.rel_value_us) / 4; | 408 | (ndelay.rel_value_us / fc->num_transmissions + 3 * fc->ack_delay.rel_value_us) / 4; |
398 | fc->num_transmissions = 0; | ||
399 | /* calculate ratio msg sent vs. msg acked */ | 409 | /* calculate ratio msg sent vs. msg acked */ |
400 | ack_cnt = 0; | 410 | ack_cnt = 0; |
401 | snd_cnt = 0; | 411 | snd_cnt = 0; |
@@ -417,18 +427,22 @@ GNUNET_FRAGMENT_process_ack (struct GNUNET_FRAGMENT_Context *fc, | |||
417 | else if (snd_cnt > ack_cnt) | 427 | else if (snd_cnt > ack_cnt) |
418 | { | 428 | { |
419 | /* some loss, slow down proportionally */ | 429 | /* some loss, slow down proportionally */ |
420 | fprintf (stderr, "Prop loss\n"); | ||
421 | fc->msg_delay.rel_value_us = ((fc->msg_delay.rel_value_us * ack_cnt) / snd_cnt); | 430 | fc->msg_delay.rel_value_us = ((fc->msg_delay.rel_value_us * ack_cnt) / snd_cnt); |
422 | } | 431 | } |
423 | else if (100 < fc->msg_delay.rel_value_us) | 432 | else if (snd_cnt == ack_cnt) |
424 | { | 433 | { |
425 | fc->msg_delay.rel_value_us -= 100; /* try a bit faster */ | 434 | fc->msg_delay.rel_value_us = |
435 | (ndelay.rel_value_us / fc->num_transmissions + 3 * fc->msg_delay.rel_value_us) / 5; | ||
426 | } | 436 | } |
437 | fc->num_transmissions = 0; | ||
427 | fc->msg_delay = GNUNET_TIME_relative_min (fc->msg_delay, | 438 | fc->msg_delay = GNUNET_TIME_relative_min (fc->msg_delay, |
428 | GNUNET_TIME_UNIT_SECONDS); | 439 | GNUNET_TIME_UNIT_SECONDS); |
440 | fc->ack_delay = GNUNET_TIME_relative_min (fc->ack_delay, | ||
441 | GNUNET_TIME_UNIT_SECONDS); | ||
429 | } | 442 | } |
430 | GNUNET_STATISTICS_update (fc->stats, | 443 | GNUNET_STATISTICS_update (fc->stats, |
431 | _("# fragment acknowledgements received"), 1, | 444 | _("# fragment acknowledgements received"), |
445 | 1, | ||
432 | GNUNET_NO); | 446 | GNUNET_NO); |
433 | if (abits != (fc->acks & abits)) | 447 | if (abits != (fc->acks & abits)) |
434 | { | 448 | { |
@@ -458,9 +472,10 @@ GNUNET_FRAGMENT_process_ack (struct GNUNET_FRAGMENT_Context *fc, | |||
458 | 472 | ||
459 | /* all done */ | 473 | /* all done */ |
460 | GNUNET_STATISTICS_update (fc->stats, | 474 | GNUNET_STATISTICS_update (fc->stats, |
461 | _("# fragmentation transmissions completed"), 1, | 475 | _("# fragmentation transmissions completed"), |
476 | 1, | ||
462 | GNUNET_NO); | 477 | GNUNET_NO); |
463 | if (fc->task != NULL) | 478 | if (NULL != fc->task) |
464 | { | 479 | { |
465 | GNUNET_SCHEDULER_cancel (fc->task); | 480 | GNUNET_SCHEDULER_cancel (fc->task); |
466 | fc->task = NULL; | 481 | fc->task = NULL; |