diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2012-09-26 13:34:09 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2012-09-26 13:34:09 +0000 |
commit | 5a753cbdb8bcf30257ac96d3abb720671a2728fd (patch) | |
tree | c4fe806213db96bd2df0d342ce7aa9cb46538c78 /src/transport | |
parent | adb58602debdaa3d6ef84eea9570bea78437c2ec (diff) | |
download | gnunet-5a753cbdb8bcf30257ac96d3abb720671a2728fd.tar.gz gnunet-5a753cbdb8bcf30257ac96d3abb720671a2728fd.zip |
- statistics values for all plugins
Diffstat (limited to 'src/transport')
-rw-r--r-- | src/transport/plugin_transport_http_client.c | 25 | ||||
-rw-r--r-- | src/transport/plugin_transport_http_server.c | 25 | ||||
-rw-r--r-- | src/transport/plugin_transport_udp.c | 19 |
3 files changed, 67 insertions, 2 deletions
diff --git a/src/transport/plugin_transport_http_client.c b/src/transport/plugin_transport_http_client.c index 212fb1b59..536e7382b 100644 --- a/src/transport/plugin_transport_http_client.c +++ b/src/transport/plugin_transport_http_client.c | |||
@@ -443,6 +443,7 @@ http_client_plugin_send (void *cls, | |||
443 | { | 443 | { |
444 | struct HTTP_Client_Plugin *plugin = cls; | 444 | struct HTTP_Client_Plugin *plugin = cls; |
445 | struct HTTP_Message *msg; | 445 | struct HTTP_Message *msg; |
446 | char *stat_txt; | ||
446 | 447 | ||
447 | GNUNET_assert (plugin != NULL); | 448 | GNUNET_assert (plugin != NULL); |
448 | GNUNET_assert (s != NULL); | 449 | GNUNET_assert (s != NULL); |
@@ -470,6 +471,12 @@ http_client_plugin_send (void *cls, | |||
470 | memcpy (msg->buf, msgbuf, msgbuf_size); | 471 | memcpy (msg->buf, msgbuf, msgbuf_size); |
471 | GNUNET_CONTAINER_DLL_insert_tail (s->msg_head, s->msg_tail, msg); | 472 | GNUNET_CONTAINER_DLL_insert_tail (s->msg_head, s->msg_tail, msg); |
472 | 473 | ||
474 | GNUNET_asprintf (&stat_txt, "# bytes currently in %s_client buffers", plugin->protocol); | ||
475 | GNUNET_STATISTICS_update (plugin->env->stats, | ||
476 | stat_txt, msgbuf_size, GNUNET_NO); | ||
477 | |||
478 | GNUNET_free (stat_txt); | ||
479 | |||
473 | if (GNUNET_YES == s->put_tmp_disconnecting) | 480 | if (GNUNET_YES == s->put_tmp_disconnecting) |
474 | { | 481 | { |
475 | /* PUT connection is currently getting disconnected */ | 482 | /* PUT connection is currently getting disconnected */ |
@@ -737,6 +744,7 @@ client_send_cb (void *stream, size_t size, size_t nmemb, void *cls) | |||
737 | struct HTTP_Client_Plugin *plugin = s->plugin; | 744 | struct HTTP_Client_Plugin *plugin = s->plugin; |
738 | struct HTTP_Message *msg = s->msg_head; | 745 | struct HTTP_Message *msg = s->msg_head; |
739 | size_t len; | 746 | size_t len; |
747 | char *stat_txt; | ||
740 | 748 | ||
741 | if (GNUNET_YES != client_exist_session (plugin, s)) | 749 | if (GNUNET_YES != client_exist_session (plugin, s)) |
742 | { | 750 | { |
@@ -779,6 +787,17 @@ client_send_cb (void *stream, size_t size, size_t nmemb, void *cls) | |||
779 | msg->transmit_cont (msg->transmit_cont_cls, &s->target, GNUNET_OK); | 787 | msg->transmit_cont (msg->transmit_cont_cls, &s->target, GNUNET_OK); |
780 | GNUNET_free (msg); | 788 | GNUNET_free (msg); |
781 | } | 789 | } |
790 | |||
791 | GNUNET_asprintf (&stat_txt, "# bytes currently in %s_client buffers", plugin->protocol); | ||
792 | GNUNET_STATISTICS_update (plugin->env->stats, | ||
793 | stat_txt, -len, GNUNET_NO); | ||
794 | GNUNET_free (stat_txt); | ||
795 | |||
796 | GNUNET_asprintf (&stat_txt, "# bytes transmitted via %s_client", plugin->protocol); | ||
797 | GNUNET_STATISTICS_update (plugin->env->stats, | ||
798 | stat_txt, len, GNUNET_NO); | ||
799 | GNUNET_free (stat_txt); | ||
800 | |||
782 | client_reschedule_session_timeout (s); | 801 | client_reschedule_session_timeout (s); |
783 | return len; | 802 | return len; |
784 | } | 803 | } |
@@ -826,6 +845,7 @@ client_receive_mst_cb (void *cls, void *client, | |||
826 | struct HTTP_Client_Plugin *plugin; | 845 | struct HTTP_Client_Plugin *plugin; |
827 | struct GNUNET_TIME_Relative delay; | 846 | struct GNUNET_TIME_Relative delay; |
828 | struct GNUNET_ATS_Information atsi[2]; | 847 | struct GNUNET_ATS_Information atsi[2]; |
848 | char *stat_txt; | ||
829 | if (GNUNET_YES != client_exist_session(p, s)) | 849 | if (GNUNET_YES != client_exist_session(p, s)) |
830 | { | 850 | { |
831 | GNUNET_break (0); | 851 | GNUNET_break (0); |
@@ -843,6 +863,11 @@ client_receive_mst_cb (void *cls, void *client, | |||
843 | (const struct GNUNET_ATS_Information *) &atsi, 2, | 863 | (const struct GNUNET_ATS_Information *) &atsi, 2, |
844 | s, s->addr, s->addrlen); | 864 | s, s->addr, s->addrlen); |
845 | 865 | ||
866 | GNUNET_asprintf (&stat_txt, "# bytes received via %s_client", plugin->protocol); | ||
867 | GNUNET_STATISTICS_update (plugin->env->stats, | ||
868 | stat_txt, ntohs(message->size), GNUNET_NO); | ||
869 | GNUNET_free (stat_txt); | ||
870 | |||
846 | s->next_receive = | 871 | s->next_receive = |
847 | GNUNET_TIME_absolute_add (GNUNET_TIME_absolute_get (), delay); | 872 | GNUNET_TIME_absolute_add (GNUNET_TIME_absolute_get (), delay); |
848 | 873 | ||
diff --git a/src/transport/plugin_transport_http_server.c b/src/transport/plugin_transport_http_server.c index 19df500bd..ea8ef428f 100644 --- a/src/transport/plugin_transport_http_server.c +++ b/src/transport/plugin_transport_http_server.c | |||
@@ -510,6 +510,7 @@ http_server_plugin_send (void *cls, | |||
510 | struct HTTP_Server_Plugin *plugin = cls; | 510 | struct HTTP_Server_Plugin *plugin = cls; |
511 | struct HTTP_Message *msg; | 511 | struct HTTP_Message *msg; |
512 | int bytes_sent = 0; | 512 | int bytes_sent = 0; |
513 | char *stat_txt; | ||
513 | 514 | ||
514 | GNUNET_assert (plugin != NULL); | 515 | GNUNET_assert (plugin != NULL); |
515 | GNUNET_assert (session != NULL); | 516 | GNUNET_assert (session != NULL); |
@@ -547,6 +548,11 @@ http_server_plugin_send (void *cls, | |||
547 | 548 | ||
548 | GNUNET_CONTAINER_DLL_insert_tail (session->msg_head, session->msg_tail, msg); | 549 | GNUNET_CONTAINER_DLL_insert_tail (session->msg_head, session->msg_tail, msg); |
549 | 550 | ||
551 | GNUNET_asprintf (&stat_txt, "# bytes currently in %s_server buffers", plugin->protocol); | ||
552 | GNUNET_STATISTICS_update (plugin->env->stats, | ||
553 | stat_txt, msgbuf_size, GNUNET_NO); | ||
554 | GNUNET_free (stat_txt); | ||
555 | |||
550 | server_reschedule (session->plugin, session->server_send->mhd_daemon, GNUNET_YES); | 556 | server_reschedule (session->plugin, session->server_send->mhd_daemon, GNUNET_YES); |
551 | server_reschedule_session_timeout (session); | 557 | server_reschedule_session_timeout (session); |
552 | 558 | ||
@@ -1170,6 +1176,7 @@ server_send_callback (void *cls, uint64_t pos, char *buf, size_t max) | |||
1170 | struct Session *s = cls; | 1176 | struct Session *s = cls; |
1171 | ssize_t bytes_read = 0; | 1177 | ssize_t bytes_read = 0; |
1172 | struct HTTP_Message *msg; | 1178 | struct HTTP_Message *msg; |
1179 | char *stat_txt; | ||
1173 | 1180 | ||
1174 | GNUNET_assert (NULL != p); | 1181 | GNUNET_assert (NULL != p); |
1175 | if (GNUNET_NO == server_exist_session (p, s)) | 1182 | if (GNUNET_NO == server_exist_session (p, s)) |
@@ -1193,8 +1200,18 @@ server_send_callback (void *cls, uint64_t pos, char *buf, size_t max) | |||
1193 | } | 1200 | } |
1194 | } | 1201 | } |
1195 | if (0 < bytes_read) | 1202 | if (0 < bytes_read) |
1203 | { | ||
1196 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, s->plugin->name, | 1204 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, s->plugin->name, |
1197 | "Sent %u bytes to peer `%s' with session %p \n", bytes_read, GNUNET_i2s (&s->target), s); | 1205 | "Sent %u bytes to peer `%s' with session %p \n", bytes_read, GNUNET_i2s (&s->target), s); |
1206 | GNUNET_asprintf (&stat_txt, "# bytes currently in %s_server buffers", p->protocol); | ||
1207 | GNUNET_STATISTICS_update (p->env->stats, | ||
1208 | stat_txt, -bytes_read, GNUNET_NO); | ||
1209 | GNUNET_free (stat_txt); | ||
1210 | GNUNET_asprintf (&stat_txt, "# bytes transmitted via %s_server", p->protocol); | ||
1211 | GNUNET_STATISTICS_update (p->env->stats, | ||
1212 | stat_txt, bytes_read, GNUNET_NO); | ||
1213 | GNUNET_free (stat_txt); | ||
1214 | } | ||
1198 | return bytes_read; | 1215 | return bytes_read; |
1199 | } | 1216 | } |
1200 | 1217 | ||
@@ -1214,6 +1231,7 @@ server_receive_mst_cb (void *cls, void *client, | |||
1214 | struct Session *s = cls; | 1231 | struct Session *s = cls; |
1215 | struct GNUNET_ATS_Information atsi[2]; | 1232 | struct GNUNET_ATS_Information atsi[2]; |
1216 | struct GNUNET_TIME_Relative delay; | 1233 | struct GNUNET_TIME_Relative delay; |
1234 | char *stat_txt; | ||
1217 | 1235 | ||
1218 | GNUNET_assert (NULL != p); | 1236 | GNUNET_assert (NULL != p); |
1219 | if (GNUNET_NO == server_exist_session(p, s)) | 1237 | if (GNUNET_NO == server_exist_session(p, s)) |
@@ -1227,11 +1245,18 @@ server_receive_mst_cb (void *cls, void *client, | |||
1227 | atsi[1].value = s->ats_address_network_type; | 1245 | atsi[1].value = s->ats_address_network_type; |
1228 | GNUNET_break (s->ats_address_network_type != ntohl (GNUNET_ATS_NET_UNSPECIFIED)); | 1246 | GNUNET_break (s->ats_address_network_type != ntohl (GNUNET_ATS_NET_UNSPECIFIED)); |
1229 | 1247 | ||
1248 | |||
1230 | delay = plugin->env->receive (plugin->env->cls, | 1249 | delay = plugin->env->receive (plugin->env->cls, |
1231 | &s->target, | 1250 | &s->target, |
1232 | message, | 1251 | message, |
1233 | (const struct GNUNET_ATS_Information *) &atsi, 2, | 1252 | (const struct GNUNET_ATS_Information *) &atsi, 2, |
1234 | s, s->addr, s->addrlen); | 1253 | s, s->addr, s->addrlen); |
1254 | |||
1255 | GNUNET_asprintf (&stat_txt, "# bytes received via %s_server", plugin->protocol); | ||
1256 | GNUNET_STATISTICS_update (plugin->env->stats, | ||
1257 | stat_txt, ntohs (message->size), GNUNET_NO); | ||
1258 | GNUNET_free (stat_txt); | ||
1259 | |||
1235 | s->session_passed = GNUNET_YES; | 1260 | s->session_passed = GNUNET_YES; |
1236 | s->next_receive = GNUNET_TIME_absolute_add (GNUNET_TIME_absolute_get (), delay); | 1261 | s->next_receive = GNUNET_TIME_absolute_add (GNUNET_TIME_absolute_get (), delay); |
1237 | if (delay.rel_value > 0) | 1262 | if (delay.rel_value > 0) |
diff --git a/src/transport/plugin_transport_udp.c b/src/transport/plugin_transport_udp.c index f133dd749..74e46a50c 100644 --- a/src/transport/plugin_transport_udp.c +++ b/src/transport/plugin_transport_udp.c | |||
@@ -1233,6 +1233,10 @@ udp_plugin_send (void *cls, | |||
1233 | GNUNET_i2s (&s->target), | 1233 | GNUNET_i2s (&s->target), |
1234 | GNUNET_a2s(s->sock_addr, s->addrlen)); | 1234 | GNUNET_a2s(s->sock_addr, s->addrlen)); |
1235 | 1235 | ||
1236 | GNUNET_STATISTICS_update (plugin->env->stats, | ||
1237 | "# bytes currently in UDP buffers", | ||
1238 | msgbuf_size, GNUNET_NO); | ||
1239 | |||
1236 | /* Message */ | 1240 | /* Message */ |
1237 | udp = (struct UDPMessage *) mbuf; | 1241 | udp = (struct UDPMessage *) mbuf; |
1238 | udp->header.size = htons (mlen); | 1242 | udp->header.size = htons (mlen); |
@@ -1816,6 +1820,10 @@ udp_select_read (struct Plugin *plugin, struct GNUNET_NETWORK_Handle *rsock) | |||
1816 | return; | 1820 | return; |
1817 | } | 1821 | } |
1818 | 1822 | ||
1823 | GNUNET_STATISTICS_update (plugin->env->stats, | ||
1824 | "# bytes received via UDP", | ||
1825 | size, GNUNET_NO); | ||
1826 | |||
1819 | switch (ntohs (msg->type)) | 1827 | switch (ntohs (msg->type)) |
1820 | { | 1828 | { |
1821 | case GNUNET_MESSAGE_TYPE_TRANSPORT_BROADCAST_BEACON: | 1829 | case GNUNET_MESSAGE_TYPE_TRANSPORT_BROADCAST_BEACON: |
@@ -1867,7 +1875,7 @@ udp_select_send (struct Plugin *plugin, struct GNUNET_NETWORK_Handle *sock) | |||
1867 | const struct sockaddr * sa = udpw->session->sock_addr; | 1875 | const struct sockaddr * sa = udpw->session->sock_addr; |
1868 | slen = udpw->session->addrlen; | 1876 | slen = udpw->session->addrlen; |
1869 | 1877 | ||
1870 | max = GNUNET_TIME_absolute_max(udpw->timeout, GNUNET_TIME_absolute_get()); | 1878 | max = GNUNET_TIME_absolute_max (udpw->timeout, GNUNET_TIME_absolute_get()); |
1871 | 1879 | ||
1872 | while (udpw != NULL) | 1880 | while (udpw != NULL) |
1873 | { | 1881 | { |
@@ -1880,7 +1888,7 @@ udp_select_send (struct Plugin *plugin, struct GNUNET_NETWORK_Handle *sock) | |||
1880 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1888 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1881 | "Fragmented message for peer `%s' with size %u timed out\n", | 1889 | "Fragmented message for peer `%s' with size %u timed out\n", |
1882 | GNUNET_i2s(&udpw->session->target), udpw->frag_ctx->bytes_to_send); | 1890 | GNUNET_i2s(&udpw->session->target), udpw->frag_ctx->bytes_to_send); |
1883 | udpw->session->last_expected_delay = GNUNET_FRAGMENT_context_destroy(udpw->frag_ctx->frag); | 1891 | udpw->session->last_expected_delay = GNUNET_FRAGMENT_context_destroy (udpw->frag_ctx->frag); |
1884 | GNUNET_free (udpw->frag_ctx); | 1892 | GNUNET_free (udpw->frag_ctx); |
1885 | udpw->session->frag_ctx = NULL; | 1893 | udpw->session->frag_ctx = NULL; |
1886 | } | 1894 | } |
@@ -1985,10 +1993,17 @@ udp_select_send (struct Plugin *plugin, struct GNUNET_NETWORK_Handle *sock) | |||
1985 | "UDP transmitted %u-byte message to `%s' (%d: %s)\n", | 1993 | "UDP transmitted %u-byte message to `%s' (%d: %s)\n", |
1986 | (unsigned int) (udpw->msg_size), GNUNET_a2s (sa, slen), (int) sent, | 1994 | (unsigned int) (udpw->msg_size), GNUNET_a2s (sa, slen), (int) sent, |
1987 | (sent < 0) ? STRERROR (errno) : "ok"); | 1995 | (sent < 0) ? STRERROR (errno) : "ok"); |
1996 | GNUNET_STATISTICS_update (plugin->env->stats, | ||
1997 | "# bytes transmitted via UDP", | ||
1998 | sent, GNUNET_NO); | ||
1988 | call_continuation(udpw, GNUNET_OK); | 1999 | call_continuation(udpw, GNUNET_OK); |
1989 | network_down_error = GNUNET_NO; | 2000 | network_down_error = GNUNET_NO; |
1990 | } | 2001 | } |
1991 | 2002 | ||
2003 | GNUNET_STATISTICS_update (plugin->env->stats, | ||
2004 | "# bytes currently in UDP buffers", | ||
2005 | -udpw->msg_size, GNUNET_NO); | ||
2006 | |||
1992 | if (sock == plugin->sockv4) | 2007 | if (sock == plugin->sockv4) |
1993 | GNUNET_CONTAINER_DLL_remove(plugin->ipv4_queue_head, plugin->ipv4_queue_tail, udpw); | 2008 | GNUNET_CONTAINER_DLL_remove(plugin->ipv4_queue_head, plugin->ipv4_queue_tail, udpw); |
1994 | else if (sock == plugin->sockv6) | 2009 | else if (sock == plugin->sockv6) |