gettext_noop ("# average retransmission delay (ms)"),
total_delay * 1000LL / plan_count, GNUNET_NO);
prd = GSF_pending_request_get_data_ (rp->prl_head->pr);
-
+
if (rp->transmission_counter < 8)
delay =
GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS,
GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK,
delay.rel_value + 1);
/* Add 0.01 to avg_delay to avoid division-by-zero later */
- avg_delay = (((avg_delay * (N-1.0)) + delay.rel_value) / N) + 0.01;
+ avg_delay = (((avg_delay * (N - 1.0)) + delay.rel_value) / N) + 0.01;
/*
- For the priority, we need to consider a few basic rules:
- 1) if we just started requesting (delay is small), we should
- virtually always have a priority of zero.
- 2) for requests with average latency, our priority should match
- the average priority observed on the network
- 3) even the longest-running requests should not be WAY out of
- the observed average (thus we bound by a factor of 2)
- 4) we add +1 to the observed average priority to avoid everyone
- staying put at zero (2 * 0 = 0...).
-
- Using the specific calculation below, we get:
-
- delay = 0 => priority = 0;
- delay = avg delay => priority = running-average-observed-priority;
- delay >> avg_delay => priority = 2 * running-average-observed-priority;
-
- which satisfies all of the rules above.
-
- Note: M_PI_4 = PI/4 = arctan(1)
- */
- rp->priority = round ((GSF_current_priorities + 1.0) * atan (delay.rel_value / avg_delay)) / M_PI_4;
+ * For the priority, we need to consider a few basic rules:
+ * 1) if we just started requesting (delay is small), we should
+ * virtually always have a priority of zero.
+ * 2) for requests with average latency, our priority should match
+ * the average priority observed on the network
+ * 3) even the longest-running requests should not be WAY out of
+ * the observed average (thus we bound by a factor of 2)
+ * 4) we add +1 to the observed average priority to avoid everyone
+ * staying put at zero (2 * 0 = 0...).
+ *
+ * Using the specific calculation below, we get:
+ *
+ * delay = 0 => priority = 0;
+ * delay = avg delay => priority = running-average-observed-priority;
+ * delay >> avg_delay => priority = 2 * running-average-observed-priority;
+ *
+ * which satisfies all of the rules above.
+ *
+ * Note: M_PI_4 = PI/4 = arctan(1)
+ */
+ rp->priority =
+ round ((GSF_current_priorities +
+ 1.0) * atan (delay.rel_value / avg_delay)) / M_PI_4;
/* Note: usage of 'round' and 'atan' requires -lm */
if (rp->transmission_counter != 0)
(unsigned int) rp->transmission_counter,
(unsigned long long) delay.rel_value);
rp->earliest_transmission = GNUNET_TIME_relative_to_absolute (delay);
-#if DEBUG_FS
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Earliest (re)transmission for `%s' in %us\n",
GNUNET_h2s (&prd->query), rp->transmission_counter);
-#endif
-
GNUNET_assert (rp->hn == NULL);
if (GNUNET_TIME_absolute_get_remaining (rp->earliest_transmission).rel_value
== 0)
rp->last_transmission = GNUNET_TIME_absolute_get ();
rp->transmission_counter++;
total_delay++;
-#if DEBUG_FS
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Executing plan %p executed %u times, planning retransmission\n",
rp, rp->transmission_counter);
-#endif
plan (pp, rp);
GNUNET_STATISTICS_update (GSF_stats,
gettext_noop
rp = GNUNET_CONTAINER_heap_peek (pp->delay_heap);
if (NULL == rp)
{
-#if DEBUG_FS
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "No active requests for plan %p.\n",
pp);
-#endif
return; /* both queues empty */
}
delay = GNUNET_TIME_absolute_get_remaining (rp->earliest_transmission);
-#if DEBUG_FS
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Sleeping for %llu ms before retrying requests on plan %p.\n",
(unsigned long long) delay.rel_value, pp);
-#endif
GNUNET_STATISTICS_set (GSF_stats, gettext_noop ("# delay heap timeout"),
delay.rel_value, GNUNET_NO);
1, GNUNET_NO);
/* process from priority heap */
rp = GNUNET_CONTAINER_heap_peek (pp->priority_heap);
-#if DEBUG_FS > 1
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Executing query plan %p\n", rp);
-#endif
GNUNET_assert (NULL != rp);
msize = GSF_pending_request_get_message_ (get_latest (rp), 0, NULL);
pp->pth =
GNUNET_STATISTICS_update (GSF_stats, gettext_noop ("# query plan entries"), 1,
GNUNET_NO);
prd = GSF_pending_request_get_data_ (pr);
-#if DEBUG_FS
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Planning transmission of query `%s' to peer `%s'\n",
GNUNET_h2s (&prd->query), GNUNET_i2s (&id));
-#endif
rp = GNUNET_malloc (sizeof (struct GSF_RequestPlan));
rpr = GNUNET_malloc (sizeof (struct GSF_RequestPlanReference));
prl = GNUNET_malloc (sizeof (struct PendingRequestList));
GNUNET_free (pp);
}
+/**
+ * Get the last transmission attempt time for the request plan list
+ * referenced by 'rpr_head', that was sent to 'sender'
+ *
+ * @param rpr_head request plan reference list to check.
+ * @param sender the peer that we've sent the request to.
+ * @param result the timestamp to fill.
+ * @return GNUNET_YES if 'result' was changed, GNUNET_NO otherwise.
+ */
+int
+GSF_request_plan_reference_get_last_transmission_ (
+ struct GSF_RequestPlanReference *rpr_head, struct GSF_ConnectedPeer *sender,
+ struct GNUNET_TIME_Absolute *result)
+{
+ struct GSF_RequestPlanReference *rpr;
+ for (rpr = rpr_head; rpr; rpr = rpr->next)
+ {
+ if (rpr->rp->pp->cp == sender)
+ {
+ *result = rpr->rp->last_transmission;
+ return GNUNET_YES;
+ }
+ }
+ return GNUNET_NO;
+}
/**
* Notify the plan about a request being done; destroy all entries