aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/core/gnunet-service-core_neighbours.c18
-rw-r--r--src/fs/gnunet-service-fs.c37
-rw-r--r--src/fs/gnunet-service-fs.h5
-rw-r--r--src/fs/gnunet-service-fs_cp.c4
4 files changed, 52 insertions, 12 deletions
diff --git a/src/core/gnunet-service-core_neighbours.c b/src/core/gnunet-service-core_neighbours.c
index 9b33a286e..d7ce91a88 100644
--- a/src/core/gnunet-service-core_neighbours.c
+++ b/src/core/gnunet-service-core_neighbours.c
@@ -307,14 +307,14 @@ process_queue (struct Neighbour *n)
307 * 307 *
308 * @param cls closure 308 * @param cls closure
309 * @param peer the peer that connected 309 * @param peer the peer that connected
310 * @param ats performance data 310 * @param atsi performance data
311 * @param ats_count number of entries in ats (excluding 0-termination) 311 * @param atsi_count number of entries in ats (excluding 0-termination)
312 */ 312 */
313static void 313static void
314handle_transport_notify_connect (void *cls, 314handle_transport_notify_connect (void *cls,
315 const struct GNUNET_PeerIdentity *peer, 315 const struct GNUNET_PeerIdentity *peer,
316 const struct GNUNET_ATS_Information 316 const struct GNUNET_ATS_Information
317 *ats, uint32_t ats_count) 317 *atsi, uint32_t atsi_count)
318{ 318{
319 struct Neighbour *n; 319 struct Neighbour *n;
320 320
@@ -381,14 +381,14 @@ handle_transport_notify_disconnect (void *cls,
381 * @param cls closure 381 * @param cls closure
382 * @param peer (claimed) identity of the other peer 382 * @param peer (claimed) identity of the other peer
383 * @param message the message 383 * @param message the message
384 * @param ats performance data 384 * @param atsi performance data
385 * @param ats_count number of entries in ats (excluding 0-termination) 385 * @param atsi_count number of entries in ats (excluding 0-termination)
386 */ 386 */
387static void 387static void
388handle_transport_receive (void *cls, const struct GNUNET_PeerIdentity *peer, 388handle_transport_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
389 const struct GNUNET_MessageHeader *message, 389 const struct GNUNET_MessageHeader *message,
390 const struct GNUNET_ATS_Information *ats, 390 const struct GNUNET_ATS_Information *atsi,
391 uint32_t ats_count) 391 uint32_t atsi_count)
392{ 392{
393 struct Neighbour *n; 393 struct Neighbour *n;
394 uint16_t type; 394 uint16_t type;
@@ -424,8 +424,8 @@ handle_transport_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
424 break; 424 break;
425 case GNUNET_MESSAGE_TYPE_CORE_ENCRYPTED_MESSAGE: 425 case GNUNET_MESSAGE_TYPE_CORE_ENCRYPTED_MESSAGE:
426 GSC_KX_handle_encrypted_message (n->kxinfo, 426 GSC_KX_handle_encrypted_message (n->kxinfo,
427 message, ats, 427 message, atsi,
428 ats_count); 428 atsi_count);
429 break; 429 break;
430 default: 430 default:
431 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 431 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
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
diff --git a/src/fs/gnunet-service-fs.h b/src/fs/gnunet-service-fs.h
index 8ba90dd22..e4efbb8f5 100644
--- a/src/fs/gnunet-service-fs.h
+++ b/src/fs/gnunet-service-fs.h
@@ -125,6 +125,11 @@ extern struct GNUNET_DHT_Handle *GSF_dht;
125extern struct GNUNET_LOAD_Value *GSF_rt_entry_lifetime; 125extern struct GNUNET_LOAD_Value *GSF_rt_entry_lifetime;
126 126
127/** 127/**
128 * Running average of the observed latency to other peers (round trip).
129 */
130extern struct GNUNET_TIME_Relative GSF_avg_latency;
131
132/**
128 * Typical priorities we're seeing from other peers right now. Since 133 * Typical priorities we're seeing from other peers right now. Since
129 * most priorities will be zero, this value is the weighted average of 134 * most priorities will be zero, this value is the weighted average of
130 * non-zero priorities seen "recently". In order to ensure that new 135 * non-zero priorities seen "recently". In order to ensure that new
diff --git a/src/fs/gnunet-service-fs_cp.c b/src/fs/gnunet-service-fs_cp.c
index fc9c44785..859d9275f 100644
--- a/src/fs/gnunet-service-fs_cp.c
+++ b/src/fs/gnunet-service-fs_cp.c
@@ -838,11 +838,11 @@ get_randomized_delay ()
838{ 838{
839 struct GNUNET_TIME_Relative ret; 839 struct GNUNET_TIME_Relative ret;
840 840
841 /* FIXME: replace 5000 with something relating to current observed P2P message latency */
842 ret = 841 ret =
843 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 842 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS,
844 GNUNET_CRYPTO_random_u32 843 GNUNET_CRYPTO_random_u32
845 (GNUNET_CRYPTO_QUALITY_WEAK, 5000)); 844 (GNUNET_CRYPTO_QUALITY_WEAK,
845 2 * GSF_avg_latency.rel_value + 1));
846 GNUNET_STATISTICS_update (GSF_stats, 846 GNUNET_STATISTICS_update (GSF_stats,
847 gettext_noop 847 gettext_noop
848 ("# artificial delays introduced (ms)"), 848 ("# artificial delays introduced (ms)"),