aboutsummaryrefslogtreecommitdiff
path: root/src/dv/test_transport_api_dv.c
diff options
context:
space:
mode:
authorNathan S. Evans <evans@in.tum.de>2011-11-19 19:08:37 +0000
committerNathan S. Evans <evans@in.tum.de>2011-11-19 19:08:37 +0000
commitdbaa827eaaeded675980aa2f8f8af87f82923df6 (patch)
treeca8057e0245147461abc350421e50c01036aedd1 /src/dv/test_transport_api_dv.c
parentc5e920135215aa0b59839c2d42190b99214dca24 (diff)
downloadgnunet-dbaa827eaaeded675980aa2f8f8af87f82923df6.tar.gz
gnunet-dbaa827eaaeded675980aa2f8f8af87f82923df6.zip
debugging dv/transport problems
Diffstat (limited to 'src/dv/test_transport_api_dv.c')
-rw-r--r--src/dv/test_transport_api_dv.c66
1 files changed, 35 insertions, 31 deletions
diff --git a/src/dv/test_transport_api_dv.c b/src/dv/test_transport_api_dv.c
index 0a3bbaa51..5f40fb522 100644
--- a/src/dv/test_transport_api_dv.c
+++ b/src/dv/test_transport_api_dv.c
@@ -25,7 +25,7 @@
25#include "gnunet_testing_lib.h" 25#include "gnunet_testing_lib.h"
26#include "gnunet_core_service.h" 26#include "gnunet_core_service.h"
27 27
28#define VERBOSE GNUNET_EXTRA_LOGGING 28#define VERBOSE 1
29 29
30#define TEST_ALL GNUNET_NO 30#define TEST_ALL GNUNET_NO
31 31
@@ -394,24 +394,28 @@ send_other_messages (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc);
394 * @return connected transport distance 394 * @return connected transport distance
395 */ 395 */
396static uint32_t 396static uint32_t
397get_atsi_distance (const struct GNUNET_ATS_Information *atsi) 397get_atsi_distance (const struct GNUNET_ATS_Information *atsi, unsigned int atsi_count)
398{ 398{
399 while ((ntohl (atsi->type) != GNUNET_ATS_ARRAY_TERMINATOR) && 399 unsigned int i;
400 (ntohl (atsi->type) != GNUNET_ATS_QUALITY_NET_DISTANCE)) 400
401 atsi++; 401 for (i = 0; i < atsi_count; i++)
402 if (ntohl (atsi->type) == GNUNET_ATS_ARRAY_TERMINATOR) 402 {
403 { 403 if (ntohl (atsi->type) == GNUNET_ATS_QUALITY_NET_DISTANCE)
404 GNUNET_break (0); 404 return ntohl (atsi->value);
405 /* FIXME: we do not have distance data? Assume direct neighbor. */ 405 }
406 return 1; 406
407 } 407 GNUNET_break (0);
408 return ntohl (atsi->value); 408 /* FIXME: we do not have distance data? Assume direct neighbor. */
409 return 1;
409} 410}
410 411
412
411static int 413static int
412process_mtype (void *cls, const struct GNUNET_PeerIdentity *peer, 414process_mtype (void *cls,
415 const struct GNUNET_PeerIdentity *peer,
413 const struct GNUNET_MessageHeader *message, 416 const struct GNUNET_MessageHeader *message,
414 const struct GNUNET_ATS_Information *atsi) 417 const struct GNUNET_ATS_Information *atsi,
418 unsigned int atsi_count)
415{ 419{
416 struct TestMessageContext *pos = cls; 420 struct TestMessageContext *pos = cls;
417 struct GNUNET_TestMessage *msg = (struct GNUNET_TestMessage *) message; 421 struct GNUNET_TestMessage *msg = (struct GNUNET_TestMessage *) message;
@@ -423,7 +427,7 @@ process_mtype (void *cls, const struct GNUNET_PeerIdentity *peer,
423 return GNUNET_OK; 427 return GNUNET_OK;
424 428
425#if VERBOSE 429#if VERBOSE
426 distance = get_atsi_distance (atsi); 430 distance = get_atsi_distance (atsi, atsi_count);
427#endif 431#endif
428 GNUNET_assert (0 == 432 GNUNET_assert (0 ==
429 memcmp (peer, &pos->peer1->id, 433 memcmp (peer, &pos->peer1->id,
@@ -450,7 +454,7 @@ process_mtype (void *cls, const struct GNUNET_PeerIdentity *peer,
450 GNUNET_i2s (peer), ntohs (message->type), ntohl (msg->uid), 454 GNUNET_i2s (peer), ntohs (message->type), ntohl (msg->uid),
451 distance); 455 distance);
452 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 456 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
453 "Total messages received %d, expected %d.\n", 457 "Total OTHER messages received %d, expected %d.\n",
454 total_other_messages, total_other_expected_messages); 458 total_other_messages, total_other_expected_messages);
455#endif 459#endif
456 } 460 }
@@ -459,18 +463,12 @@ process_mtype (void *cls, const struct GNUNET_PeerIdentity *peer,
459 (total_other_messages == 0)) 463 (total_other_messages == 0))
460 { 464 {
461 GNUNET_SCHEDULER_cancel (die_task); 465 GNUNET_SCHEDULER_cancel (die_task);
466#if VERBOSE
467 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Scheduling timeout from DV connections.\n");
468#endif
462 die_task = 469 die_task =
463 GNUNET_SCHEDULER_add_delayed (TEST_TIMEOUT, &end_badly, 470 GNUNET_SCHEDULER_add_delayed (TEST_TIMEOUT, &end_badly,
464 "waiting for DV peers to connect!"); 471 "waiting for DV peers to connect!");
465 /*
466 * if ((num_peers == 3) && (total_other_expected_messages == 2))
467 * {
468 * GNUNET_SCHEDULER_add_now (&send_other_messages, NULL);
469 * }
470 * else
471 * {
472 * GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 20), &send_other_messages, NULL);
473 * } */
474 } 472 }
475 else if ((total_other_expected_messages > 0) && 473 else if ((total_other_expected_messages > 0) &&
476 (total_other_messages == total_other_expected_messages)) 474 (total_other_messages == total_other_expected_messages))
@@ -524,10 +522,12 @@ static struct GNUNET_CORE_MessageHandler handlers[] = {
524 * @param cls closure 522 * @param cls closure
525 * @param peer peer identity this notification is about 523 * @param peer peer identity this notification is about
526 * @param atsi performance data for the connection 524 * @param atsi performance data for the connection
525 * @param atsi_count number of ATS information included
527 */ 526 */
528static void 527static void
529connect_notify_peer2 (void *cls, const struct GNUNET_PeerIdentity *peer, 528connect_notify_peer2 (void *cls, const struct GNUNET_PeerIdentity *peer,
530 const struct GNUNET_ATS_Information *atsi) 529 const struct GNUNET_ATS_Information *atsi,
530 unsigned int atsi_count)
531{ 531{
532 struct TestMessageContext *pos = cls; 532 struct TestMessageContext *pos = cls;
533 533
@@ -577,10 +577,12 @@ init_notify_peer2 (void *cls, struct GNUNET_CORE_Handle *server,
577 * @param cls closure 577 * @param cls closure
578 * @param peer peer identity this notification is about 578 * @param peer peer identity this notification is about
579 * @param atsi performance data for the connection 579 * @param atsi performance data for the connection
580 * @param atsi_count number of atsi datums
580 */ 581 */
581static void 582static void
582connect_notify_peer1 (void *cls, const struct GNUNET_PeerIdentity *peer, 583connect_notify_peer1 (void *cls, const struct GNUNET_PeerIdentity *peer,
583 const struct GNUNET_ATS_Information *atsi) 584 const struct GNUNET_ATS_Information *atsi,
585 unsigned int atsi_count)
584{ 586{
585 struct TestMessageContext *pos = cls; 587 struct TestMessageContext *pos = cls;
586 588
@@ -835,12 +837,14 @@ topology_callback (void *cls, const struct GNUNET_PeerIdentity *first,
835 * 837 *
836 * @param cls closure 838 * @param cls closure
837 * @param peer peer identity this notification is about 839 * @param peer peer identity this notification is about
838 * @param latency reported latency of the connection with 'other' 840 * @param atsi performance data about this peer's connection
839 * @param distance reported distance (DV) to 'other' 841 * @param atsi_count number of atsi datums
842 *
840 */ 843 */
841static void 844static void
842all_connect_handler (void *cls, const struct GNUNET_PeerIdentity *peer, 845all_connect_handler (void *cls, const struct GNUNET_PeerIdentity *peer,
843 const struct GNUNET_ATS_Information *atsi) 846 const struct GNUNET_ATS_Information *atsi,
847 unsigned int atsi_count)
844{ 848{
845 struct GNUNET_TESTING_Daemon *d = cls; 849 struct GNUNET_TESTING_Daemon *d = cls;
846 struct GNUNET_TESTING_Daemon *second_daemon; 850 struct GNUNET_TESTING_Daemon *second_daemon;
@@ -854,7 +858,7 @@ all_connect_handler (void *cls, const struct GNUNET_PeerIdentity *peer,
854 if (0 == memcmp (&d->id, peer, sizeof (struct GNUNET_PeerIdentity))) 858 if (0 == memcmp (&d->id, peer, sizeof (struct GNUNET_PeerIdentity)))
855 return; 859 return;
856 second_shortname = GNUNET_strdup (GNUNET_i2s (peer)); 860 second_shortname = GNUNET_strdup (GNUNET_i2s (peer));
857 distance = get_atsi_distance (atsi); 861 distance = get_atsi_distance (atsi, atsi_count);
858 862
859#if VERBOSE 863#if VERBOSE
860 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 864 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,