From 9408c72ce1cbc03d7001a778e793359cb94d4798 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Thu, 12 Feb 2015 15:18:37 +0000 Subject: -better stats for KEEPALIVEs --- src/transport/gnunet-service-transport.c | 15 +++--- .../gnunet-service-transport_neighbours.c | 55 ++++++++++++---------- .../gnunet-service-transport_validation.c | 42 ++++++++++++----- 3 files changed, 68 insertions(+), 44 deletions(-) diff --git a/src/transport/gnunet-service-transport.c b/src/transport/gnunet-service-transport.c index efbd67619..60f942d91 100644 --- a/src/transport/gnunet-service-transport.c +++ b/src/transport/gnunet-service-transport.c @@ -504,7 +504,7 @@ GST_receive_callback (void *cls, return ret; case GNUNET_MESSAGE_TYPE_TRANSPORT_PING: GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Processing `%s' from `%s'\n", "PING", + "Processing PING from `%s'\n", GST_plugins_a2s (address)); if (GNUNET_OK != GST_validation_handle_ping (&address->peer, @@ -520,7 +520,7 @@ GST_receive_callback (void *cls, break; case GNUNET_MESSAGE_TYPE_TRANSPORT_PONG: GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, - "Processing `%s' from `%s'\n", "PONG", + "Processing PONG from `%s'\n", GST_plugins_a2s (address)); if (GNUNET_OK != GST_validation_handle_pong (&address->peer, message)) { @@ -572,13 +572,16 @@ GST_receive_callback (void *cls, } break; case GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_DISCONNECT: - GST_neighbours_handle_disconnect_message (&address->peer, message); + GST_neighbours_handle_disconnect_message (&address->peer, + message); break; case GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_KEEPALIVE: - GST_neighbours_keepalive (&address->peer, message); + GST_neighbours_keepalive (&address->peer, + message); break; case GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_KEEPALIVE_RESPONSE: - GST_neighbours_keepalive_response (&address->peer, message); + GST_neighbours_keepalive_response (&address->peer, + message); break; default: /* should be payload */ @@ -591,7 +594,7 @@ GST_receive_callback (void *cls, message); break; } - end: + end: GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Allowing receive from peer %s to continue in %s\n", GNUNET_i2s (&address->peer), diff --git a/src/transport/gnunet-service-transport_neighbours.c b/src/transport/gnunet-service-transport_neighbours.c index 729de12d3..c4886520b 100644 --- a/src/transport/gnunet-service-transport_neighbours.c +++ b/src/transport/gnunet-service-transport_neighbours.c @@ -1402,7 +1402,7 @@ send_keepalive (struct NeighbourMapEntry *n) GNUNET_YES, NULL, NULL); GNUNET_STATISTICS_update (GST_stats, - gettext_noop ("# keepalives sent"), + gettext_noop ("# KEEPALIVES sent"), 1, GNUNET_NO); n->primary_address.keep_alive_nonce = nonce; @@ -1428,9 +1428,12 @@ GST_neighbours_keepalive (const struct GNUNET_PeerIdentity *neighbour, struct SessionKeepAliveMessage msg; if (sizeof (struct SessionKeepAliveMessage) != ntohs (m->size)) + { + GNUNET_break_op (0); return; + } - msg_in = (struct SessionKeepAliveMessage *) m; + msg_in = (const struct SessionKeepAliveMessage *) m; if (NULL == (n = lookup_neighbour (neighbour))) { GNUNET_STATISTICS_update (GST_stats, @@ -1449,8 +1452,9 @@ GST_neighbours_keepalive (const struct GNUNET_PeerIdentity *neighbour, } GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Received keep alive request from peer `%s' with nonce %u\n", - GNUNET_i2s (&n->id), ntohl (msg_in->nonce)); + "Received KEEPALIVE request from peer `%s' with nonce %u\n", + GNUNET_i2s (&n->id), + ntohl (msg_in->nonce)); /* send reply to allow neighbour to measure latency */ msg.header.size = htons (sizeof (struct SessionKeepAliveMessage)); @@ -1484,50 +1488,50 @@ GST_neighbours_keepalive_response (const struct GNUNET_PeerIdentity *neighbour, struct GNUNET_TIME_Relative latency; if (sizeof (struct SessionKeepAliveMessage) != ntohs (m->size)) + { + GNUNET_break_op (0); return; + } msg = (const struct SessionKeepAliveMessage *) m; if (NULL == (n = lookup_neighbour (neighbour))) { GNUNET_STATISTICS_update (GST_stats, - gettext_noop - ("# KEEPALIVE_RESPONSE messages discarded (not connected)"), - 1, GNUNET_NO); + gettext_noop ("# KEEPALIVE_RESPONSE messages discarded (not connected)"), + 1, + GNUNET_NO); return; } if ( (GNUNET_TRANSPORT_PS_CONNECTED != n->state) || (GNUNET_YES != n->expect_latency_response) ) { GNUNET_STATISTICS_update (GST_stats, - gettext_noop - ("# KEEPALIVE_RESPONSE messages discarded (not expected)"), - 1, GNUNET_NO); + gettext_noop ("# KEEPALIVE_RESPONSE messages discarded (not expected)"), + 1, + GNUNET_NO); return; } if (NULL == n->primary_address.address) { GNUNET_STATISTICS_update (GST_stats, - gettext_noop - ("# KEEPALIVE_RESPONSE messages discarded (address changed)"), - 1, GNUNET_NO); + gettext_noop ("# KEEPALIVE_RESPONSE messages discarded (address changed)"), + 1, + GNUNET_NO); return; } if (n->primary_address.keep_alive_nonce != ntohl (msg->nonce)) { GNUNET_STATISTICS_update (GST_stats, - gettext_noop - ("# KEEPALIVE_RESPONSE messages discarded (wrong nonce)"), - 1, GNUNET_NO); + gettext_noop ("# KEEPALIVE_RESPONSE messages discarded (wrong nonce)"), + 1, + GNUNET_NO); return; } - else - { - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Received keep alive response from peer `%s' for session %p\n", - GNUNET_i2s (&n->id), - n->primary_address.session); + GNUNET_STATISTICS_update (GST_stats, + gettext_noop ("# KEEPALIVE_RESPONSE messages received in good order"), + 1, + GNUNET_NO); - } /* Update session timeout here */ if (NULL != (papi = GST_plugins_find (n->primary_address.address->transport_name))) @@ -1553,12 +1557,13 @@ GST_neighbours_keepalive_response (const struct GNUNET_PeerIdentity *neighbour, latency = GNUNET_TIME_absolute_get_duration (n->last_keep_alive_time); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Latency for peer `%s' is %s\n", + "Received KEEPALIVE_RESPONSE from peer `%s', latency is %s\n", GNUNET_i2s (&n->id), GNUNET_STRINGS_relative_time_to_string (latency, GNUNET_YES)); GST_ats_update_delay (n->primary_address.address, - GNUNET_TIME_relative_divide (latency, 2)); + GNUNET_TIME_relative_divide (latency, + 2)); } diff --git a/src/transport/gnunet-service-transport_validation.c b/src/transport/gnunet-service-transport_validation.c index b6b323bd0..ee8a145c1 100644 --- a/src/transport/gnunet-service-transport_validation.c +++ b/src/transport/gnunet-service-transport_validation.c @@ -413,7 +413,8 @@ cleanup_validation_entry (void *cls, ve->valid_until = GNUNET_TIME_UNIT_ZERO_ABS; /* Notify about deleted entry */ - validation_entry_changed (ve, GNUNET_TRANSPORT_VS_REMOVE); + validation_entry_changed (ve, + GNUNET_TRANSPORT_VS_REMOVE); if (NULL != ve->bc) { @@ -449,9 +450,6 @@ cleanup_validation_entry (void *cls, gettext_noop ("# validations running"), validations_running, GNUNET_NO); - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Validation aborted, %u validation processes running\n", - validations_running); } GNUNET_free (ve); return GNUNET_OK; @@ -474,20 +472,30 @@ timeout_hello_validation (void *cls, struct GNUNET_TIME_Relative left; ve->timeout_task = NULL; + /* For valid addresses, we want to wait until the expire; + for addresses under PING validation, we want to wait + until we give up on the PING */ max = GNUNET_TIME_absolute_max (ve->valid_until, ve->revalidation_block); - left = GNUNET_TIME_absolute_get_remaining (max); + left = GNUNET_TIME_absolute_get_remaining (ve->max); if (left.rel_value_us > 0) { - /* should wait a bit longer */ + /* We should wait a bit longer. This happens when + address lifetimes are extended due to successful + validations. */ ve->timeout_task = - GNUNET_SCHEDULER_add_delayed (left, &timeout_hello_validation, ve); + GNUNET_SCHEDULER_add_delayed (left, + &timeout_hello_validation, + ve); return; } GNUNET_STATISTICS_update (GST_stats, - gettext_noop ("# address records discarded"), 1, + gettext_noop ("# address records discarded (timeout)"), + 1, GNUNET_NO); - cleanup_validation_entry (NULL, &ve->address->peer, ve); + cleanup_validation_entry (NULL, + &ve->address->peer, + ve); } @@ -519,11 +527,17 @@ transmit_ping_if_allowed (void *cls, if (GNUNET_NO == result) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Blacklist denies to send PING to `%s' `%s' `%s'\n", + "Blacklist denies sending PING to `%s' `%s' `%s'\n", GNUNET_i2s (pid), GST_plugins_a2s (ve->address), ve->address->transport_name); - cleanup_validation_entry (NULL, pid, ve); + GNUNET_STATISTICS_update (GST_stats, + gettext_noop ("# address records discarded (blacklist)"), + 1, + GNUNET_NO); + cleanup_validation_entry (NULL, + pid, + ve); return; } hello = GST_hello_get (); @@ -775,8 +789,10 @@ find_validation_entry (const struct GNUNET_HELLO_Address *address) GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_NONCE, UINT32_MAX); ve->timeout_task = GNUNET_SCHEDULER_add_delayed (UNVALIDATED_PING_KEEPALIVE, - &timeout_hello_validation, ve); - GNUNET_CONTAINER_multipeermap_put (validation_map, &address->peer, + &timeout_hello_validation, + ve); + GNUNET_CONTAINER_multipeermap_put (validation_map, + &address->peer, ve, GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); publish_ve_stat_update (); -- cgit v1.2.3