From c3bf3ec9232f0917234d8a8258c1fefd65a1ce2b Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Thu, 7 Oct 2010 11:33:09 +0000 Subject: [PATCH] track delay between transmission request and satisfaction: --- src/fs/gnunet-service-fs.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/fs/gnunet-service-fs.c b/src/fs/gnunet-service-fs.c index 2e1c574c8..a0c09e946 100644 --- a/src/fs/gnunet-service-fs.c +++ b/src/fs/gnunet-service-fs.c @@ -216,6 +216,18 @@ struct ConnectedPeer */ struct PendingMessage *pending_messages_tail; + /** + * How long does it typically take for us to transmit a message + * to this peer? (delay between the request being issued and + * the callback being invoked). + */ + struct GNUNET_LOAD_Value *transmission_delay; + + /** + * Time when the last transmission request was issued. + */ + struct GNUNET_TIME_Absolute last_transmission_request_start; + /** * Average priority of successful replies. Calculated * as a moving average: new_avg = ((n-1)*last_avg+curr_prio) / n @@ -1456,6 +1468,7 @@ peer_connect_handler (void *cls, uint32_t trust; cp = GNUNET_malloc (sizeof (struct ConnectedPeer)); + cp->transmission_delay = GNUNET_LOAD_value_init (); cp->pid = GNUNET_PEER_intern (peer); fn = get_trust_filename (peer); @@ -1671,6 +1684,7 @@ peer_disconnect_handler (void *cls, GNUNET_CORE_notify_transmit_ready_cancel (cp->cth); while (NULL != (pm = cp->pending_messages_head)) destroy_pending_message (pm, 0 /* delivery failed */); + GNUNET_LOAD_value_free (cp->transmission_delay); GNUNET_break (0 == cp->pending_requests); GNUNET_free (cp); } @@ -1905,6 +1919,8 @@ transmit_to_peer (void *cls, #endif return 0; } + GNUNET_LOAD_update (cp->transmission_delay, + GNUNET_TIME_absolute_get_duration (cp->last_transmission_request_start).value); msize = 0; while ( (NULL != (pm = cp->pending_messages_head) ) && (pm->msize <= size) ) @@ -1918,6 +1934,7 @@ transmit_to_peer (void *cls, { GNUNET_PEER_resolve (cp->pid, &pid); + cp->last_transmission_request_start = GNUNET_TIME_absolute_get (); cp->cth = GNUNET_CORE_notify_transmit_ready (core, pm->priority, GNUNET_CONSTANTS_SERVICE_TIMEOUT, @@ -2036,6 +2053,7 @@ add_to_pending_messages_for_peer (struct ConnectedPeer *cp, if (NULL != cp->cth) GNUNET_CORE_notify_transmit_ready_cancel (cp->cth); /* need to schedule transmission */ + cp->last_transmission_request_start = GNUNET_TIME_absolute_get (); cp->cth = GNUNET_CORE_notify_transmit_ready (core, cp->pending_messages_head->priority, MAX_TRANSMIT_DELAY, -- 2.25.1