From: Christian Grothoff Date: Mon, 19 Sep 2011 09:39:28 +0000 (+0000) Subject: do latency computation - #1768 X-Git-Tag: initial-import-from-subversion-38251~17020 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=ad1b129bbcd973f1c151c5a0b77dd31543fa74d8;p=oweals%2Fgnunet.git do latency computation - #1768 --- diff --git a/src/transport/gnunet-service-transport.c b/src/transport/gnunet-service-transport.c index 4687a0907..07861eaff 100644 --- a/src/transport/gnunet-service-transport.c +++ b/src/transport/gnunet-service-transport.c @@ -241,13 +241,17 @@ plugin_env_receive_callback (void *cls, const struct GNUNET_PeerIdentity *peer, break; } } - GNUNET_assert ((ats_count > 0) && (ats != NULL)); - + /* + FIXME: this gives an address that might not have been validated to + ATS for 'selection', which is probably not what we want; this + might be particularly wrong (as in, possibly hiding bugs with address + validation) as 'GNUNET_ATS_address_update' currently ignores + the expiration given. + */ GNUNET_ATS_address_update (GST_ats, peer, GNUNET_TIME_absolute_get (), /* valid at least until right now... */ plugin_name, session, sender_address, sender_address_len, ats, ats_count); - return ret; } diff --git a/src/transport/gnunet-service-transport_validation.c b/src/transport/gnunet-service-transport_validation.c index 57fa86260..7fcb76396 100644 --- a/src/transport/gnunet-service-transport_validation.c +++ b/src/transport/gnunet-service-transport_validation.c @@ -394,6 +394,7 @@ add_valid_address (void *cls, const char *tname, struct ValidationEntry *ve; struct GNUNET_PeerIdentity pid; struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded public_key; + struct GNUNET_TRANSPORT_ATS_Information ats; if (GNUNET_TIME_absolute_get_remaining (expiration).rel_value == 0) return GNUNET_OK; /* expired */ @@ -405,11 +406,8 @@ add_valid_address (void *cls, const char *tname, } ve = find_validation_entry (&public_key, &pid, tname, addr, addrlen); ve->valid_until = GNUNET_TIME_absolute_max (ve->valid_until, expiration); - struct GNUNET_TRANSPORT_ATS_Information ats; - ats.type = htonl (GNUNET_TRANSPORT_ATS_ARRAY_TERMINATOR); ats.value = htonl (0); - GNUNET_ATS_address_update (GST_ats, &pid, ve->valid_until, tname, NULL, addr, addrlen, &ats, 1); return GNUNET_OK; @@ -979,12 +977,18 @@ GST_validation_handle_pong (const struct GNUNET_PeerIdentity *sender, /* validity achieved, remember it! */ ve->valid_until = GNUNET_TIME_relative_to_absolute (HELLO_ADDRESS_EXPIRATION); - struct GNUNET_TRANSPORT_ATS_Information ats; - - ats.type = htonl (GNUNET_TRANSPORT_ATS_ARRAY_TERMINATOR); - ats.value = htonl (0); - GNUNET_ATS_address_update (GST_ats, &ve->pid, ve->valid_until, ve->transport_name, NULL, ve->addr, ve->addrlen, &ats, 1); /* FIXME: compute and add latency here... */ - + { + struct GNUNET_TRANSPORT_ATS_Information ats[2]; + + ats[0].type = htonl (GNUNET_TRANSPORT_ATS_QUALITY_NET_DELAY); + ats[0].value = htonl ((uint32_t) GNUNET_TIME_absolute_get_duration (ve->send_time).rel_value); + ats[1].type = htonl (GNUNET_TRANSPORT_ATS_ARRAY_TERMINATOR); + ats[1].value = htonl (0); + GNUNET_ATS_address_update (GST_ats, &ve->pid, ve->valid_until, + ve->transport_name, NULL, ve->addr, ve->addrlen, + ats, 2); + } + /* build HELLO to store in PEERINFO */ ve->copied = GNUNET_NO; hello = GNUNET_HELLO_create (&ve->public_key, &add_valid_peer_address, ve);