aboutsummaryrefslogtreecommitdiff
path: root/src/stream
diff options
context:
space:
mode:
authorSree Harsha Totakura <totakura@in.tum.de>2012-11-18 19:54:17 +0000
committerSree Harsha Totakura <totakura@in.tum.de>2012-11-18 19:54:17 +0000
commitff62b90718f62a2cf806da81c1b9602e97d18457 (patch)
tree5973a04b808ecbc80d4cfcca00132b77c8e6e619 /src/stream
parenta618961d96910d622476341e7efdf6d1180acdd3 (diff)
downloadgnunet-ff62b90718f62a2cf806da81c1b9602e97d18457.tar.gz
gnunet-ff62b90718f62a2cf806da81c1b9602e97d18457.zip
use statistics
Diffstat (limited to 'src/stream')
-rw-r--r--src/stream/Makefile.am1
-rw-r--r--src/stream/stream_api.c87
-rw-r--r--src/stream/test_stream_local.conf5
3 files changed, 67 insertions, 26 deletions
diff --git a/src/stream/Makefile.am b/src/stream/Makefile.am
index 8a5e141ab..16c4f78b2 100644
--- a/src/stream/Makefile.am
+++ b/src/stream/Makefile.am
@@ -16,6 +16,7 @@ libgnunetstream_la_SOURCES = \
16libgnunetstream_la_LIBADD = \ 16libgnunetstream_la_LIBADD = \
17 $(top_builddir)/src/mesh/libgnunetmesh.la \ 17 $(top_builddir)/src/mesh/libgnunetmesh.la \
18 $(top_builddir)/src/lockmanager/libgnunetlockmanager.la \ 18 $(top_builddir)/src/lockmanager/libgnunetlockmanager.la \
19 $(top_builddir)/src/statistics/libgnunetstatistics.la \
19 $(top_builddir)/src/util/libgnunetutil.la $(XLIB) 20 $(top_builddir)/src/util/libgnunetutil.la $(XLIB)
20libgnunetstream_la_LDFLAGS = \ 21libgnunetstream_la_LDFLAGS = \
21 $(GN_LIB_LDFLAGS) \ 22 $(GN_LIB_LDFLAGS) \
diff --git a/src/stream/stream_api.c b/src/stream/stream_api.c
index 1aec60285..05d09aced 100644
--- a/src/stream/stream_api.c
+++ b/src/stream/stream_api.c
@@ -39,6 +39,7 @@
39#include "gnunet_common.h" 39#include "gnunet_common.h"
40#include "gnunet_crypto_lib.h" 40#include "gnunet_crypto_lib.h"
41#include "gnunet_lockmanager_service.h" 41#include "gnunet_lockmanager_service.h"
42#include "gnunet_statistics_service.h"
42#include "gnunet_stream_lib.h" 43#include "gnunet_stream_lib.h"
43#include "stream_protocol.h" 44#include "stream_protocol.h"
44 45
@@ -175,29 +176,14 @@ struct MessageQueue
175struct GNUNET_STREAM_Socket 176struct GNUNET_STREAM_Socket
176{ 177{
177 /** 178 /**
178 * Retransmission timeout 179 * The mesh handle
179 */
180 struct GNUNET_TIME_Relative retransmit_timeout;
181
182 /**
183 * The Acknowledgement Bitmap
184 */
185 GNUNET_STREAM_AckBitmap ack_bitmap;
186
187 /**
188 * Time when the Acknowledgement was queued
189 */
190 struct GNUNET_TIME_Absolute ack_time_registered;
191
192 /**
193 * Queued Acknowledgement deadline
194 */ 180 */
195 struct GNUNET_TIME_Relative ack_time_deadline; 181 struct GNUNET_MESH_Handle *mesh;
196 182
197 /** 183 /**
198 * The mesh handle 184 * Handle to statistics
199 */ 185 */
200 struct GNUNET_MESH_Handle *mesh; 186 struct GNUNET_STATISTICS_Handle *stat_handle;
201 187
202 /** 188 /**
203 * The mesh tunnel handle 189 * The mesh tunnel handle
@@ -261,6 +247,11 @@ struct GNUNET_STREAM_Socket
261 struct GNUNET_PeerIdentity other_peer; 247 struct GNUNET_PeerIdentity other_peer;
262 248
263 /** 249 /**
250 * The Acknowledgement Bitmap
251 */
252 GNUNET_STREAM_AckBitmap ack_bitmap;
253
254 /**
264 * Task identifier for retransmission task after timeout 255 * Task identifier for retransmission task after timeout
265 */ 256 */
266 GNUNET_SCHEDULER_TaskIdentifier data_retransmission_task_id; 257 GNUNET_SCHEDULER_TaskIdentifier data_retransmission_task_id;
@@ -276,6 +267,21 @@ struct GNUNET_STREAM_Socket
276 GNUNET_SCHEDULER_TaskIdentifier ack_task_id; 267 GNUNET_SCHEDULER_TaskIdentifier ack_task_id;
277 268
278 /** 269 /**
270 * Retransmission timeout
271 */
272 struct GNUNET_TIME_Relative retransmit_timeout;
273
274 /**
275 * Time when the Acknowledgement was queued
276 */
277 struct GNUNET_TIME_Absolute ack_time_registered;
278
279 /**
280 * Queued Acknowledgement deadline
281 */
282 struct GNUNET_TIME_Relative ack_time_deadline;
283
284 /**
279 * The state of the protocol associated with this socket 285 * The state of the protocol associated with this socket
280 */ 286 */
281 enum State state; 287 enum State state;
@@ -291,14 +297,14 @@ struct GNUNET_STREAM_Socket
291 unsigned int retries; 297 unsigned int retries;
292 298
293 /** 299 /**
294 * The application port number (type: uint32_t) 300 * Whether testing mode is active or not
295 */ 301 */
296 GNUNET_MESH_ApplicationType app_port; 302 int testing_active;
297 303
298 /** 304 /**
299 * Whether testing mode is active or not 305 * The application port number (type: uint32_t)
300 */ 306 */
301 int testing_active; 307 GNUNET_MESH_ApplicationType app_port;
302 308
303 /** 309 /**
304 * The write sequence number to be set incase of testing 310 * The write sequence number to be set incase of testing
@@ -364,6 +370,11 @@ struct GNUNET_STREAM_ListenSocket
364 struct GNUNET_MESH_Handle *mesh; 370 struct GNUNET_MESH_Handle *mesh;
365 371
366 /** 372 /**
373 * Handle to statistics
374 */
375 struct GNUNET_STATISTICS_Handle *stat_handle;
376
377 /**
367 * Our configuration 378 * Our configuration
368 */ 379 */
369 struct GNUNET_CONFIGURATION_Handle *cfg; 380 struct GNUNET_CONFIGURATION_Handle *cfg;
@@ -2738,6 +2749,7 @@ new_tunnel_notify (void *cls,
2738 socket->tunnel = tunnel; 2749 socket->tunnel = tunnel;
2739 socket->state = STATE_INIT; 2750 socket->state = STATE_INIT;
2740 socket->lsocket = lsocket; 2751 socket->lsocket = lsocket;
2752 socket->stat_handle = lsocket->stat_handle;
2741 socket->retransmit_timeout = lsocket->retransmit_timeout; 2753 socket->retransmit_timeout = lsocket->retransmit_timeout;
2742 socket->testing_active = lsocket->testing_active; 2754 socket->testing_active = lsocket->testing_active;
2743 socket->testing_set_write_sequence_number_value = 2755 socket->testing_set_write_sequence_number_value =
@@ -2747,6 +2759,15 @@ new_tunnel_notify (void *cls,
2747 "%s: Peer %s initiated tunnel to us\n", 2759 "%s: Peer %s initiated tunnel to us\n",
2748 GNUNET_i2s (&socket->other_peer), 2760 GNUNET_i2s (&socket->other_peer),
2749 GNUNET_i2s (&socket->other_peer)); 2761 GNUNET_i2s (&socket->other_peer));
2762 if (NULL != socket->stat_handle)
2763 {
2764 GNUNET_STATISTICS_update (socket->stat_handle,
2765 "total inbound connections received",
2766 1, GNUNET_NO);
2767 GNUNET_STATISTICS_update (socket->stat_handle,
2768 "inbound connections", 1, GNUNET_NO);
2769 }
2770
2750 return socket; 2771 return socket;
2751} 2772}
2752 2773
@@ -2777,6 +2798,13 @@ tunnel_cleaner (void *cls,
2777 "%s: Peer %s has terminated connection abruptly\n", 2798 "%s: Peer %s has terminated connection abruptly\n",
2778 GNUNET_i2s (&socket->other_peer), 2799 GNUNET_i2s (&socket->other_peer),
2779 GNUNET_i2s (&socket->other_peer)); 2800 GNUNET_i2s (&socket->other_peer));
2801 if (NULL != socket->stat_handle)
2802 {
2803 GNUNET_STATISTICS_update (socket->stat_handle,
2804 "connections terminated abruptly", 1, GNUNET_NO);
2805 GNUNET_STATISTICS_update (socket->stat_handle,
2806 "inbound connections", -1, GNUNET_NO);
2807 }
2780 socket->status = GNUNET_STREAM_SHUTDOWN; 2808 socket->status = GNUNET_STREAM_SHUTDOWN;
2781 /* Clear Transmit handles */ 2809 /* Clear Transmit handles */
2782 if (NULL != socket->transmit_handle) 2810 if (NULL != socket->transmit_handle)
@@ -2983,6 +3011,7 @@ GNUNET_STREAM_open (const struct GNUNET_CONFIGURATION_Handle *cfg,
2983 GNUNET_assert (NULL != socket->tunnel); 3011 GNUNET_assert (NULL != socket->tunnel);
2984 GNUNET_MESH_peer_request_connect_add (socket->tunnel, 3012 GNUNET_MESH_peer_request_connect_add (socket->tunnel,
2985 &socket->other_peer); 3013 &socket->other_peer);
3014 socket->stat_handle = GNUNET_STATISTICS_create ("stream", cfg);
2986 LOG (GNUNET_ERROR_TYPE_DEBUG, "%s() END\n", __func__); 3015 LOG (GNUNET_ERROR_TYPE_DEBUG, "%s() END\n", __func__);
2987 return socket; 3016 return socket;
2988} 3017}
@@ -3138,11 +3167,14 @@ GNUNET_STREAM_close (struct GNUNET_STREAM_Socket *socket)
3138 socket->tunnel = NULL; 3167 socket->tunnel = NULL;
3139 } 3168 }
3140 /* Close mesh connection */ 3169 /* Close mesh connection */
3141 if (NULL != socket->mesh && NULL == socket->lsocket) 3170 if ((NULL != socket->mesh) && (NULL == socket->lsocket))
3142 { 3171 {
3143 GNUNET_MESH_disconnect (socket->mesh); 3172 GNUNET_MESH_disconnect (socket->mesh);
3144 socket->mesh = NULL; 3173 socket->mesh = NULL;
3145 } 3174 }
3175 /* Close statistics connection */
3176 if ( (NULL != socket->stat_handle) && (NULL == socket->lsocket) )
3177 GNUNET_STATISTICS_destroy (socket->stat_handle, GNUNET_YES);
3146 /* Release receive buffer */ 3178 /* Release receive buffer */
3147 if (NULL != socket->receive_buffer) 3179 if (NULL != socket->receive_buffer)
3148 { 3180 {
@@ -3170,7 +3202,6 @@ GNUNET_STREAM_listen (const struct GNUNET_CONFIGURATION_Handle *cfg,
3170 void *listen_cb_cls, 3202 void *listen_cb_cls,
3171 ...) 3203 ...)
3172{ 3204{
3173 /* FIXME: Add variable args for passing configration options? */
3174 struct GNUNET_STREAM_ListenSocket *lsocket; 3205 struct GNUNET_STREAM_ListenSocket *lsocket;
3175 struct GNUNET_TIME_Relative listen_timeout; 3206 struct GNUNET_TIME_Relative listen_timeout;
3176 enum GNUNET_STREAM_Option option; 3207 enum GNUNET_STREAM_Option option;
@@ -3237,6 +3268,8 @@ GNUNET_STREAM_listen (const struct GNUNET_CONFIGURATION_Handle *cfg,
3237 lsocket->lockmanager_acquire_timeout_task = 3268 lsocket->lockmanager_acquire_timeout_task =
3238 GNUNET_SCHEDULER_add_delayed (listen_timeout, 3269 GNUNET_SCHEDULER_add_delayed (listen_timeout,
3239 &lockmanager_acquire_timeout, lsocket); 3270 &lockmanager_acquire_timeout, lsocket);
3271 lsocket->stat_handle = GNUNET_STATISTICS_create ("stream",
3272 lsocket->cfg);
3240 return lsocket; 3273 return lsocket;
3241} 3274}
3242 3275
@@ -3252,6 +3285,8 @@ GNUNET_STREAM_listen_close (struct GNUNET_STREAM_ListenSocket *lsocket)
3252 /* Close MESH connection */ 3285 /* Close MESH connection */
3253 if (NULL != lsocket->mesh) 3286 if (NULL != lsocket->mesh)
3254 GNUNET_MESH_disconnect (lsocket->mesh); 3287 GNUNET_MESH_disconnect (lsocket->mesh);
3288 if (NULL != lsocket->stat_handle)
3289 GNUNET_STATISTICS_destroy (lsocket->stat_handle, GNUNET_YES);
3255 GNUNET_CONFIGURATION_destroy (lsocket->cfg); 3290 GNUNET_CONFIGURATION_destroy (lsocket->cfg);
3256 if (GNUNET_SCHEDULER_NO_TASK != lsocket->lockmanager_acquire_timeout_task) 3291 if (GNUNET_SCHEDULER_NO_TASK != lsocket->lockmanager_acquire_timeout_task)
3257 GNUNET_SCHEDULER_cancel (lsocket->lockmanager_acquire_timeout_task); 3292 GNUNET_SCHEDULER_cancel (lsocket->lockmanager_acquire_timeout_task);
diff --git a/src/stream/test_stream_local.conf b/src/stream/test_stream_local.conf
index 5a517cb3f..d0daffaec 100644
--- a/src/stream/test_stream_local.conf
+++ b/src/stream/test_stream_local.conf
@@ -4,6 +4,11 @@ ACCEPT_FROM = 127.0.0.1;
4HOSTNAME = localhost 4HOSTNAME = localhost
5PORT = 12101 5PORT = 12101
6 6
7[statistics]
8AUTOSTART = YES
9ACCEPT_FROM = 127.0.0.1;
10PORT = 12102
11
7[fs] 12[fs]
8AUTOSTART = NO 13AUTOSTART = NO
9 14