diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2011-10-05 12:06:08 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2011-10-05 12:06:08 +0000 |
commit | 7b4ad1742d4eb984b8c4f2d756d5b1cf859ed156 (patch) | |
tree | 304c629e5d51f0a0179bdf861934ea3e36fa5b53 /src/transport/test_transport_api_reliability.c | |
parent | 90f4f1c9760a5ab8b5279e1dd4a7e2e219e446be (diff) | |
download | gnunet-7b4ad1742d4eb984b8c4f2d756d5b1cf859ed156.tar.gz gnunet-7b4ad1742d4eb984b8c4f2d756d5b1cf859ed156.zip |
Diffstat (limited to 'src/transport/test_transport_api_reliability.c')
-rw-r--r-- | src/transport/test_transport_api_reliability.c | 62 |
1 files changed, 48 insertions, 14 deletions
diff --git a/src/transport/test_transport_api_reliability.c b/src/transport/test_transport_api_reliability.c index a64a6fbe3..f49cbfdf1 100644 --- a/src/transport/test_transport_api_reliability.c +++ b/src/transport/test_transport_api_reliability.c | |||
@@ -38,7 +38,7 @@ | |||
38 | #include "transport.h" | 38 | #include "transport.h" |
39 | #include "transport-testing.h" | 39 | #include "transport-testing.h" |
40 | 40 | ||
41 | #define VERBOSE GNUNET_YES | 41 | #define VERBOSE GNUNET_EXTRA_LOGGING |
42 | 42 | ||
43 | #define VERBOSE_ARM GNUNET_EXTRA_LOGGING | 43 | #define VERBOSE_ARM GNUNET_EXTRA_LOGGING |
44 | 44 | ||
@@ -69,6 +69,10 @@ struct PeerContext *p1; | |||
69 | 69 | ||
70 | struct PeerContext *p2; | 70 | struct PeerContext *p2; |
71 | 71 | ||
72 | struct PeerContext * sender; | ||
73 | |||
74 | struct PeerContext * receiver; | ||
75 | |||
72 | struct GNUNET_TRANSPORT_TransmitHandle *th; | 76 | struct GNUNET_TRANSPORT_TransmitHandle *th; |
73 | 77 | ||
74 | char *cfg_file_p1; | 78 | char *cfg_file_p1; |
@@ -189,6 +193,7 @@ notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
189 | unsigned int s; | 193 | unsigned int s; |
190 | char cbuf[GNUNET_SERVER_MAX_MESSAGE_SIZE - 1]; | 194 | char cbuf[GNUNET_SERVER_MAX_MESSAGE_SIZE - 1]; |
191 | const struct TestMessage *hdr; | 195 | const struct TestMessage *hdr; |
196 | struct PeerContext * p = cls; | ||
192 | 197 | ||
193 | hdr = (const struct TestMessage *) message; | 198 | hdr = (const struct TestMessage *) message; |
194 | s = get_size (n); | 199 | s = get_size (n); |
@@ -233,8 +238,10 @@ notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
233 | #if VERBOSE | 238 | #if VERBOSE |
234 | if (ntohl (hdr->num) % 5000 == 0) | 239 | if (ntohl (hdr->num) % 5000 == 0) |
235 | { | 240 | { |
236 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Got message %u of size %u\n", | 241 | char * ps = strdup(GNUNET_i2s(&p->id)); |
237 | ntohl (hdr->num), ntohs (message->size)); | 242 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer %u (`%s') got message %u of size %u from peer (`%s')\n", |
243 | p->no, ps, ntohl (hdr->num), ntohs (message->size), GNUNET_i2s(peer)); | ||
244 | GNUNET_free (ps); | ||
238 | } | 245 | } |
239 | #endif | 246 | #endif |
240 | n++; | 247 | n++; |
@@ -294,8 +301,14 @@ notify_ready (void *cls, size_t size, void *buf) | |||
294 | #if VERBOSE | 301 | #if VERBOSE |
295 | if (n % 5000 == 0) | 302 | if (n % 5000 == 0) |
296 | { | 303 | { |
297 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending message %u of size %u\n", n, | 304 | |
298 | s); | 305 | char * receiver_s = strdup(GNUNET_i2s (&receiver->id)); |
306 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
307 | "Sending message of size %u from peer %u (`%4s') -> peer %u (`%s') !\n", | ||
308 | n, | ||
309 | sender->no, | ||
310 | GNUNET_i2s (&sender->id), receiver->no, receiver_s); | ||
311 | GNUNET_free (receiver_s); | ||
299 | } | 312 | } |
300 | #endif | 313 | #endif |
301 | n++; | 314 | n++; |
@@ -333,8 +346,9 @@ notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
333 | uint32_t ats_count) | 346 | uint32_t ats_count) |
334 | { | 347 | { |
335 | 348 | ||
336 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer `%4s' connected to us (%p)!\n", | 349 | struct PeerContext *p = cls; |
337 | GNUNET_i2s (peer), cls); | 350 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer %u (`%4s') connected to us!\n", |
351 | p->no, GNUNET_i2s (peer)); | ||
338 | 352 | ||
339 | if (cls == p1) | 353 | if (cls == p1) |
340 | { | 354 | { |
@@ -358,8 +372,9 @@ notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
358 | static void | 372 | static void |
359 | notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) | 373 | notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) |
360 | { | 374 | { |
361 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer `%4s' disconnected (%p)!\n", | 375 | struct PeerContext *p = cls; |
362 | GNUNET_i2s (peer), cls); | 376 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer %u (`%4s') disconnected!\n", |
377 | p->no, GNUNET_i2s (peer)); | ||
363 | if (th != NULL) | 378 | if (th != NULL) |
364 | GNUNET_TRANSPORT_notify_transmit_ready_cancel (th); | 379 | GNUNET_TRANSPORT_notify_transmit_ready_cancel (th); |
365 | th = NULL; | 380 | th = NULL; |
@@ -379,9 +394,9 @@ static void | |||
379 | testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls) | 394 | testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls) |
380 | { | 395 | { |
381 | char *p1_c = strdup (GNUNET_i2s (&p1->id)); | 396 | char *p1_c = strdup (GNUNET_i2s (&p1->id)); |
382 | 397 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peers connected: %u (%s) <-> %u (%s)\n", | |
383 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peers connected: %s <-> %s\n", p1_c, | 398 | p1->no, p1_c, |
384 | GNUNET_i2s (&p2->id)); | 399 | p2->no, GNUNET_i2s (&p2->id)); |
385 | GNUNET_free (p1_c); | 400 | GNUNET_free (p1_c); |
386 | 401 | ||
387 | // FIXME: THIS IS REQUIRED! SEEMS TO BE A BUG! | 402 | // FIXME: THIS IS REQUIRED! SEEMS TO BE A BUG! |
@@ -394,12 +409,16 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
394 | { | 409 | { |
395 | die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL); | 410 | die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL); |
396 | 411 | ||
397 | p1 = GNUNET_TRANSPORT_TESTING_start_peer (cfg_file_p1, ¬ify_receive, | 412 | p1 = GNUNET_TRANSPORT_TESTING_start_peer (cfg_file_p1, |
413 | ¬ify_receive, | ||
398 | ¬ify_connect, ¬ify_disconnect, | 414 | ¬ify_connect, ¬ify_disconnect, |
399 | NULL); | 415 | NULL); |
400 | p2 = GNUNET_TRANSPORT_TESTING_start_peer (cfg_file_p2, ¬ify_receive, | 416 | p1->no = 1; |
417 | p2 = GNUNET_TRANSPORT_TESTING_start_peer (cfg_file_p2, | ||
418 | ¬ify_receive, | ||
401 | ¬ify_connect, ¬ify_disconnect, | 419 | ¬ify_connect, ¬ify_disconnect, |
402 | NULL); | 420 | NULL); |
421 | p2->no = 2; | ||
403 | 422 | ||
404 | if ((p1 == NULL) || (p2 == NULL)) | 423 | if ((p1 == NULL) || (p2 == NULL)) |
405 | { | 424 | { |
@@ -411,6 +430,21 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
411 | } | 430 | } |
412 | test_connected = GNUNET_NO; | 431 | test_connected = GNUNET_NO; |
413 | 432 | ||
433 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer %u: `%s' using configuration file `%s'\n", | ||
434 | p1->no, | ||
435 | GNUNET_i2s (&p1->id), cfg_file_p1); | ||
436 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer %u: `%s' using configuration file `%s'\n", | ||
437 | p2->no, | ||
438 | GNUNET_i2s (&p2->id), cfg_file_p2); | ||
439 | |||
440 | sender = p2; | ||
441 | receiver = p1; | ||
442 | |||
443 | char *sender_c = strdup (GNUNET_i2s (&sender->id)); | ||
444 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test triest to send from %u (%s) -> peer %u (%s)\n", | ||
445 | sender->no, sender_c, | ||
446 | receiver->no, GNUNET_i2s (&receiver->id)); | ||
447 | |||
414 | GNUNET_TRANSPORT_TESTING_connect_peers (p1, p2, &testing_connect_cb, NULL); | 448 | GNUNET_TRANSPORT_TESTING_connect_peers (p1, p2, &testing_connect_cb, NULL); |
415 | } | 449 | } |
416 | 450 | ||