diff options
author | Christian Grothoff <christian@grothoff.org> | 2010-05-31 11:25:31 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2010-05-31 11:25:31 +0000 |
commit | 281d5b7680f9b1d2adce9f69c75b38f1b1e7f177 (patch) | |
tree | 945cb90c4bb628018d3ae9e5a62a795c38b75d32 /src/transport/test_transport_api_reliability.c | |
parent | 746774c9bb1df3cc5d0e731afbad8904ebb39133 (diff) | |
download | gnunet-281d5b7680f9b1d2adce9f69c75b38f1b1e7f177.tar.gz gnunet-281d5b7680f9b1d2adce9f69c75b38f1b1e7f177.zip |
fixes
Diffstat (limited to 'src/transport/test_transport_api_reliability.c')
-rw-r--r-- | src/transport/test_transport_api_reliability.c | 49 |
1 files changed, 42 insertions, 7 deletions
diff --git a/src/transport/test_transport_api_reliability.c b/src/transport/test_transport_api_reliability.c index 9b2c167cb..fe7b6590e 100644 --- a/src/transport/test_transport_api_reliability.c +++ b/src/transport/test_transport_api_reliability.c | |||
@@ -35,12 +35,17 @@ | |||
35 | #include "gnunet_transport_service.h" | 35 | #include "gnunet_transport_service.h" |
36 | #include "transport.h" | 36 | #include "transport.h" |
37 | 37 | ||
38 | #define VERBOSE GNUNET_YES | 38 | #define VERBOSE GNUNET_NO |
39 | 39 | ||
40 | #define VERBOSE_ARM GNUNET_NO | 40 | #define VERBOSE_ARM GNUNET_NO |
41 | 41 | ||
42 | #define START_ARM GNUNET_YES | 42 | #define START_ARM GNUNET_YES |
43 | 43 | ||
44 | /** | ||
45 | * Note that this value must not significantly exceed | ||
46 | * 'MAX_PENDING' in 'gnunet-service-transport.c', otherwise | ||
47 | * messages may be dropped even for a reliable transport. | ||
48 | */ | ||
44 | #define TOTAL_MSGS (60000 * 2) | 49 | #define TOTAL_MSGS (60000 * 2) |
45 | 50 | ||
46 | /** | 51 | /** |
@@ -72,6 +77,10 @@ static int is_tcp; | |||
72 | 77 | ||
73 | static int is_http; | 78 | static int is_http; |
74 | 79 | ||
80 | static unsigned long long total_bytes; | ||
81 | |||
82 | static struct GNUNET_TIME_Absolute start_time; | ||
83 | |||
75 | static GNUNET_SCHEDULER_TaskIdentifier die_task; | 84 | static GNUNET_SCHEDULER_TaskIdentifier die_task; |
76 | 85 | ||
77 | #if VERBOSE | 86 | #if VERBOSE |
@@ -84,15 +93,23 @@ static GNUNET_SCHEDULER_TaskIdentifier die_task; | |||
84 | static void | 93 | static void |
85 | end () | 94 | end () |
86 | { | 95 | { |
87 | GNUNET_assert (ok == 6); | 96 | unsigned long long delta; |
97 | |||
88 | GNUNET_SCHEDULER_cancel (sched, die_task); | 98 | GNUNET_SCHEDULER_cancel (sched, die_task); |
99 | die_task = GNUNET_SCHEDULER_NO_TASK; | ||
100 | #if VERBOSE | ||
89 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting from transports!\n"); | 101 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting from transports!\n"); |
102 | #endif | ||
90 | GNUNET_TRANSPORT_disconnect (p1.th); | 103 | GNUNET_TRANSPORT_disconnect (p1.th); |
91 | GNUNET_TRANSPORT_disconnect (p2.th); | 104 | GNUNET_TRANSPORT_disconnect (p2.th); |
92 | 105 | #if VERBOSE | |
93 | die_task = GNUNET_SCHEDULER_NO_TASK; | ||
94 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 106 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
95 | "Transports disconnected, returning success!\n"); | 107 | "Transports disconnected, returning success!\n"); |
108 | #endif | ||
109 | delta = GNUNET_TIME_absolute_get_duration (start_time).value; | ||
110 | fprintf (stderr, | ||
111 | "\nThroughput was %llu kb/s\n", | ||
112 | total_bytes * 1000 / 1024 / delta); | ||
96 | ok = 0; | 113 | ok = 0; |
97 | } | 114 | } |
98 | 115 | ||
@@ -175,11 +192,15 @@ notify_receive (void *cls, | |||
175 | die_task = GNUNET_SCHEDULER_add_now (sched, &end_badly, NULL); | 192 | die_task = GNUNET_SCHEDULER_add_now (sched, &end_badly, NULL); |
176 | return; | 193 | return; |
177 | } | 194 | } |
195 | #if VERBOSE | ||
178 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 196 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
179 | "Got message %u of size %u\n", | 197 | "Got message %u of size %u\n", |
180 | ntohl (hdr->num), | 198 | ntohl (hdr->num), |
181 | ntohs (message->size)); | 199 | ntohs (message->size)); |
200 | #endif | ||
182 | n++; | 201 | n++; |
202 | if (0 == (n % (TOTAL_MSGS/100))) | ||
203 | fprintf (stderr, "."); | ||
183 | if (n == TOTAL_MSGS) | 204 | if (n == TOTAL_MSGS) |
184 | end (); | 205 | end (); |
185 | } | 206 | } |
@@ -214,10 +235,12 @@ notify_ready (void *cls, size_t size, void *buf) | |||
214 | ret += sizeof (struct TestMessage); | 235 | ret += sizeof (struct TestMessage); |
215 | memset (&cbuf[ret], n, s - sizeof (struct TestMessage)); | 236 | memset (&cbuf[ret], n, s - sizeof (struct TestMessage)); |
216 | ret += s - sizeof (struct TestMessage); | 237 | ret += s - sizeof (struct TestMessage); |
238 | #if VERBOSE | ||
217 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 239 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
218 | "Sending message %u of size %u\n", | 240 | "Sending message %u of size %u\n", |
219 | n, | 241 | n, |
220 | s); | 242 | s); |
243 | #endif | ||
221 | n++; | 244 | n++; |
222 | s = get_size (n); | 245 | s = get_size (n); |
223 | if (0 == GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 16)) | 246 | if (0 == GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 16)) |
@@ -233,6 +256,7 @@ notify_ready (void *cls, size_t size, void *buf) | |||
233 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 256 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
234 | "Returning total message block of size %u\n", | 257 | "Returning total message block of size %u\n", |
235 | ret); | 258 | ret); |
259 | total_bytes += ret; | ||
236 | return ret; | 260 | return ret; |
237 | } | 261 | } |
238 | 262 | ||
@@ -251,6 +275,7 @@ notify_connect (void *cls, | |||
251 | GNUNET_BANDWIDTH_value_init (1024 * 1024 * 1024), | 275 | GNUNET_BANDWIDTH_value_init (1024 * 1024 * 1024), |
252 | GNUNET_TIME_UNIT_FOREVER_REL, | 276 | GNUNET_TIME_UNIT_FOREVER_REL, |
253 | NULL, NULL); | 277 | NULL, NULL); |
278 | start_time = GNUNET_TIME_absolute_get (); | ||
254 | GNUNET_TRANSPORT_notify_transmit_ready (p1.th, | 279 | GNUNET_TRANSPORT_notify_transmit_ready (p1.th, |
255 | &p2.id, | 280 | &p2.id, |
256 | get_size (0), 0, TIMEOUT, | 281 | get_size (0), 0, TIMEOUT, |
@@ -266,17 +291,21 @@ notify_connect (void *cls, | |||
266 | GNUNET_TIME_UNIT_FOREVER_REL, | 291 | GNUNET_TIME_UNIT_FOREVER_REL, |
267 | NULL, NULL); | 292 | NULL, NULL); |
268 | } | 293 | } |
294 | #if VERBOSE | ||
269 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 295 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
270 | "Peer `%4s' connected to us (%p)!\n", GNUNET_i2s (peer), cls); | 296 | "Peer `%4s' connected to us (%p)!\n", GNUNET_i2s (peer), cls); |
297 | #endif | ||
271 | } | 298 | } |
272 | 299 | ||
273 | 300 | ||
274 | static void | 301 | static void |
275 | notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) | 302 | notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) |
276 | { | 303 | { |
304 | #if VERBOSE | ||
277 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 305 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
278 | "Peer `%4s' disconnected (%p)!\n", | 306 | "Peer `%4s' disconnected (%p)!\n", |
279 | GNUNET_i2s (peer), cls); | 307 | GNUNET_i2s (peer), cls); |
308 | #endif | ||
280 | } | 309 | } |
281 | 310 | ||
282 | 311 | ||
@@ -310,8 +339,10 @@ exchange_hello_last (void *cls, | |||
310 | struct PeerContext *me = cls; | 339 | struct PeerContext *me = cls; |
311 | 340 | ||
312 | GNUNET_TRANSPORT_get_hello_cancel (p2.th, &exchange_hello_last, me); | 341 | GNUNET_TRANSPORT_get_hello_cancel (p2.th, &exchange_hello_last, me); |
342 | #if VERBOSE | ||
313 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 343 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
314 | "Exchanging HELLO with peer (%p)!\n", cls); | 344 | "Exchanging HELLO with peer (%p)!\n", cls); |
345 | #endif | ||
315 | GNUNET_assert (ok >= 3); | 346 | GNUNET_assert (ok >= 3); |
316 | OKPP; | 347 | OKPP; |
317 | GNUNET_assert (message != NULL); | 348 | GNUNET_assert (message != NULL); |
@@ -331,8 +362,10 @@ exchange_hello (void *cls, | |||
331 | struct PeerContext *me = cls; | 362 | struct PeerContext *me = cls; |
332 | 363 | ||
333 | GNUNET_TRANSPORT_get_hello_cancel (p1.th, &exchange_hello, me); | 364 | GNUNET_TRANSPORT_get_hello_cancel (p1.th, &exchange_hello, me); |
365 | #if VERBOSE | ||
334 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 366 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
335 | "Exchanging HELLO with peer (%p)!\n", cls); | 367 | "Exchanging HELLO with peer (%p)!\n", cls); |
368 | #endif | ||
336 | GNUNET_assert (ok >= 2); | 369 | GNUNET_assert (ok >= 2); |
337 | OKPP; | 370 | OKPP; |
338 | GNUNET_assert (message != NULL); | 371 | GNUNET_assert (message != NULL); |
@@ -340,9 +373,11 @@ exchange_hello (void *cls, | |||
340 | GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *) | 373 | GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *) |
341 | message, &me->id)); | 374 | message, &me->id)); |
342 | 375 | ||
376 | #if VERBOSE | ||
343 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 377 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
344 | "Received HELLO size %d\n", GNUNET_HELLO_size((const struct GNUNET_HELLO_Message *)message)); | 378 | "Received HELLO size %d\n", |
345 | 379 | GNUNET_HELLO_size((const struct GNUNET_HELLO_Message *)message)); | |
380 | #endif | ||
346 | GNUNET_TRANSPORT_offer_hello (p2.th, message); | 381 | GNUNET_TRANSPORT_offer_hello (p2.th, message); |
347 | GNUNET_TRANSPORT_get_hello (p2.th, &exchange_hello_last, &p2); | 382 | GNUNET_TRANSPORT_get_hello (p2.th, &exchange_hello_last, &p2); |
348 | } | 383 | } |
@@ -399,7 +434,7 @@ check () | |||
399 | #endif | 434 | #endif |
400 | ok = 1; | 435 | ok = 1; |
401 | GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, | 436 | GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, |
402 | argv, "test-transport-api", "nohelp", | 437 | argv, "test-transport-api-reliability", "nohelp", |
403 | options, &run, &ok); | 438 | options, &run, &ok); |
404 | stop_arm (&p1); | 439 | stop_arm (&p1); |
405 | stop_arm (&p2); | 440 | stop_arm (&p2); |