From: Christian Grothoff Date: Fri, 4 Nov 2011 13:32:45 +0000 (+0000) Subject: implementing #1785 X-Git-Tag: initial-import-from-subversion-38251~16059 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=f23af8a34c2abcc816cf67e6674fcf18041630b5;p=oweals%2Fgnunet.git implementing #1785 --- 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) * * @param cls closure * @param peer the peer that connected - * @param ats performance data - * @param ats_count number of entries in ats (excluding 0-termination) + * @param atsi performance data + * @param atsi_count number of entries in ats (excluding 0-termination) */ static void handle_transport_notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_ATS_Information - *ats, uint32_t ats_count) + *atsi, uint32_t atsi_count) { struct Neighbour *n; @@ -381,14 +381,14 @@ handle_transport_notify_disconnect (void *cls, * @param cls closure * @param peer (claimed) identity of the other peer * @param message the message - * @param ats performance data - * @param ats_count number of entries in ats (excluding 0-termination) + * @param atsi performance data + * @param atsi_count number of entries in ats (excluding 0-termination) */ static void handle_transport_receive (void *cls, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_MessageHeader *message, - const struct GNUNET_ATS_Information *ats, - uint32_t ats_count) + const struct GNUNET_ATS_Information *atsi, + uint32_t atsi_count) { struct Neighbour *n; uint16_t type; @@ -424,8 +424,8 @@ handle_transport_receive (void *cls, const struct GNUNET_PeerIdentity *peer, break; case GNUNET_MESSAGE_TYPE_CORE_ENCRYPTED_MESSAGE: GSC_KX_handle_encrypted_message (n->kxinfo, - message, ats, - ats_count); + message, atsi, + atsi_count); break; default: 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 @@ -93,6 +93,12 @@ struct GNUNET_DHT_Handle *GSF_dht; */ struct GNUNET_LOAD_Value *GSF_rt_entry_lifetime; +/** + * Running average of the observed latency to other peers (round trip). + * Initialized to 5s as the initial default. + */ +struct GNUNET_TIME_Relative GSF_avg_latency = { 5000 }; + /** * Typical priorities we're seeing from other peers right now. Since * most priorities will be zero, this value is the weighted average of @@ -172,7 +178,6 @@ age_cover_counters (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) } - /** * We've just now completed a datastore request. Update our * datastore load calculations. @@ -212,6 +217,34 @@ GSF_test_get_load_too_high_ (uint32_t priority) } +/** + * We've received peer performance information. Update + * our running average for the P2P latency. + * + * @param atsi performance information + * @param atsi_count number of 'atsi' records + */ +static void +update_latencies (const struct GNUNET_ATS_Information *atsi, + unsigned int atsi_count) +{ + unsigned int i; + + for (i=0;i