aboutsummaryrefslogtreecommitdiff
path: root/src/fs/gnunet-service-fs.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-11-04 13:32:45 +0000
committerChristian Grothoff <christian@grothoff.org>2011-11-04 13:32:45 +0000
commitf23af8a34c2abcc816cf67e6674fcf18041630b5 (patch)
treeaea05f924f38dc3a0336f6388b78d47b35ea5e87 /src/fs/gnunet-service-fs.c
parent77b6ff6328120de950fd5d7802819882455a4da1 (diff)
downloadgnunet-f23af8a34c2abcc816cf67e6674fcf18041630b5.tar.gz
gnunet-f23af8a34c2abcc816cf67e6674fcf18041630b5.zip
implementing #1785
Diffstat (limited to 'src/fs/gnunet-service-fs.c')
-rw-r--r--src/fs/gnunet-service-fs.c37
1 files changed, 36 insertions, 1 deletions
diff --git a/src/fs/gnunet-service-fs.c b/src/fs/gnunet-service-fs.c
index c5933d989..404993130 100644
--- a/src/fs/gnunet-service-fs.c
+++ b/src/fs/gnunet-service-fs.c
@@ -94,6 +94,12 @@ struct GNUNET_DHT_Handle *GSF_dht;
94struct GNUNET_LOAD_Value *GSF_rt_entry_lifetime; 94struct GNUNET_LOAD_Value *GSF_rt_entry_lifetime;
95 95
96/** 96/**
97 * Running average of the observed latency to other peers (round trip).
98 * Initialized to 5s as the initial default.
99 */
100struct GNUNET_TIME_Relative GSF_avg_latency = { 5000 };
101
102/**
97 * Typical priorities we're seeing from other peers right now. Since 103 * Typical priorities we're seeing from other peers right now. Since
98 * most priorities will be zero, this value is the weighted average of 104 * most priorities will be zero, this value is the weighted average of
99 * non-zero priorities seen "recently". In order to ensure that new 105 * non-zero priorities seen "recently". In order to ensure that new
@@ -172,7 +178,6 @@ age_cover_counters (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
172} 178}
173 179
174 180
175
176/** 181/**
177 * We've just now completed a datastore request. Update our 182 * We've just now completed a datastore request. Update our
178 * datastore load calculations. 183 * datastore load calculations.
@@ -213,6 +218,34 @@ GSF_test_get_load_too_high_ (uint32_t priority)
213 218
214 219
215/** 220/**
221 * We've received peer performance information. Update
222 * our running average for the P2P latency.
223 *
224 * @param atsi performance information
225 * @param atsi_count number of 'atsi' records
226 */
227static void
228update_latencies (const struct GNUNET_ATS_Information *atsi,
229 unsigned int atsi_count)
230{
231 unsigned int i;
232
233 for (i=0;i<atsi_count;i++)
234 {
235 if (ntohl(atsi[i].type) == GNUNET_ATS_QUALITY_NET_DELAY)
236 {
237 GSF_avg_latency.rel_value = (GSF_avg_latency.rel_value * 31 + ntohl (atsi[i].value)) / 32;
238 GNUNET_STATISTICS_set (GSF_stats,
239 gettext_noop ("# running average P2P latency (ms)"),
240 GSF_avg_latency.rel_value,
241 GNUNET_NO);
242 break;
243 }
244 }
245}
246
247
248/**
216 * Handle P2P "PUT" message. 249 * Handle P2P "PUT" message.
217 * 250 *
218 * @param cls closure, always NULL 251 * @param cls closure, always NULL
@@ -239,6 +272,7 @@ handle_p2p_put (void *cls, const struct GNUNET_PeerIdentity *other,
239 return GNUNET_OK; 272 return GNUNET_OK;
240 } 273 }
241 GSF_cover_content_count++; 274 GSF_cover_content_count++;
275 update_latencies (atsi, atsi_count);
242 return GSF_handle_p2p_content_ (cp, message); 276 return GSF_handle_p2p_content_ (cp, message);
243} 277}
244 278
@@ -317,6 +351,7 @@ handle_p2p_get (void *cls, const struct GNUNET_PeerIdentity *other,
317 if (NULL == pr) 351 if (NULL == pr)
318 return GNUNET_SYSERR; 352 return GNUNET_SYSERR;
319 GSF_local_lookup_ (pr, &consider_forwarding, NULL); 353 GSF_local_lookup_ (pr, &consider_forwarding, NULL);
354 update_latencies (atsi, atsi_count);
320 return GNUNET_OK; 355 return GNUNET_OK;
321} 356}
322 357