/*
This file is part of GNUnet
- (C) 2009, 2011 Christian Grothoff (and other contributing authors)
+ (C) 2009-2013 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
delay = GNUNET_BANDWIDTH_tracker_get_delay (fc->tracker, fsize);
else
delay = GNUNET_TIME_UNIT_ZERO;
- if (delay.rel_value > 0)
+ if (delay.rel_value_us > 0)
{
fc->task = GNUNET_SCHEDULER_add_delayed (delay, &transmit_next, fc);
return;
GNUNET_BANDWIDTH_tracker_consume (fc->tracker, fsize);
GNUNET_STATISTICS_update (fc->stats, _("# fragments transmitted"), 1,
GNUNET_NO);
- if (0 != fc->last_round.abs_value)
+ if (0 != fc->last_round.abs_value_us)
GNUNET_STATISTICS_update (fc->stats, _("# fragments retransmitted"), 1,
GNUNET_NO);
else
delay = GNUNET_TIME_UNIT_ZERO;
delay = GNUNET_TIME_relative_max (delay,
- fc->msg_delay);
+ GNUNET_TIME_relative_multiply (fc->msg_delay,
+ (1 << fc->num_rounds)));
if (wrap)
{
/* full round transmitted wait 2x delay for ACK before going again */
fc->num_rounds++;
- delay = GNUNET_TIME_relative_multiply (delay, 2);
- fc->msg_delay = GNUNET_TIME_relative_multiply (fc->msg_delay,
- 2 + (size / (fc->mtu - sizeof (struct FragmentHeader))));
+ delay = GNUNET_TIME_relative_multiply (fc->ack_delay, 2);
/* never use zero, need some time for ACK always */
- delay = GNUNET_TIME_relative_max (MIN_ACK_DELAY, delay);
+ delay = GNUNET_TIME_relative_max (MIN_ACK_DELAY, delay);
fc->wack = GNUNET_YES;
fc->last_round = GNUNET_TIME_absolute_get ();
GNUNET_STATISTICS_update (fc->stats, _("# fragments wrap arounds"), 1,
struct GNUNET_FRAGMENT_Context *fc;
size_t size;
uint64_t bits;
-
+
GNUNET_STATISTICS_update (stats, _("# messages fragmented"), 1, GNUNET_NO);
GNUNET_assert (mtu >= 1024 + sizeof (struct FragmentHeader));
size = ntohs (msg->size);
unsigned int snd_cnt;
unsigned int i;
- fprintf (stderr, "Got ACK!\n");
if (sizeof (struct FragmentAcknowledgement) != ntohs (msg->size))
{
GNUNET_break_op (0);
/* normal ACK, can update running average of delay... */
fc->wack = GNUNET_NO;
ndelay = GNUNET_TIME_absolute_get_duration (fc->last_round);
- fc->ack_delay.rel_value =
- (ndelay.rel_value / fc->num_transmissions + 3 * fc->ack_delay.rel_value) / 4;
+ fc->ack_delay.rel_value_us =
+ (ndelay.rel_value_us / fc->num_transmissions + 3 * fc->ack_delay.rel_value_us) / 4;
fc->num_transmissions = 0;
/* calculate ratio msg sent vs. msg acked */
ack_cnt = 0;
if (0 == ack_cnt)
{
/* complete loss */
- fc->msg_delay = GNUNET_TIME_relative_multiply (fc->msg_delay,
- snd_cnt);
+ fc->msg_delay = GNUNET_TIME_relative_multiply (fc->msg_delay,
+ snd_cnt);
}
else if (snd_cnt > ack_cnt)
{
/* some loss, slow down proportionally */
- fc->msg_delay.rel_value = ((fc->msg_delay.rel_value * ack_cnt) / snd_cnt);
+ fprintf (stderr, "Prop loss\n");
+ fc->msg_delay.rel_value_us = ((fc->msg_delay.rel_value_us * ack_cnt) / snd_cnt);
}
- else if (0 < fc->msg_delay.rel_value)
+ else if (100 < fc->msg_delay.rel_value_us)
{
- fc->msg_delay.rel_value--; /* try a bit faster */
+ fc->msg_delay.rel_value_us -= 100; /* try a bit faster */
}
- fc->msg_delay = GNUNET_TIME_relative_max (fc->msg_delay,
+ fc->msg_delay = GNUNET_TIME_relative_min (fc->msg_delay,
GNUNET_TIME_UNIT_SECONDS);
- fprintf (stderr, "New msg delay: %llu\n",
- (unsigned long long )fc->msg_delay.rel_value);
}
GNUNET_STATISTICS_update (fc->stats,
_("# fragment acknowledgements received"), 1,
if (NULL != ack_delay)
*ack_delay = fc->ack_delay;
if (NULL != msg_delay)
- *msg_delay = fc->msg_delay;
+ *msg_delay = GNUNET_TIME_relative_multiply (fc->msg_delay,
+ fc->num_rounds);
GNUNET_free (fc);
}