diff options
Diffstat (limited to 'src/cadet')
-rw-r--r-- | src/cadet/test_cadet_new.c | 61 |
1 files changed, 45 insertions, 16 deletions
diff --git a/src/cadet/test_cadet_new.c b/src/cadet/test_cadet_new.c index d32404815..302119906 100644 --- a/src/cadet/test_cadet_new.c +++ b/src/cadet/test_cadet_new.c | |||
@@ -460,7 +460,7 @@ send_test_message (struct GNUNET_CADET_Channel *channel) | |||
460 | struct GNUNET_MQ_Envelope *env; | 460 | struct GNUNET_MQ_Envelope *env; |
461 | struct GNUNET_MessageHeader *msg; | 461 | struct GNUNET_MessageHeader *msg; |
462 | uint32_t *data; | 462 | uint32_t *data; |
463 | int *counter; | 463 | int payload; |
464 | int size; | 464 | int size; |
465 | 465 | ||
466 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 466 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
@@ -471,25 +471,47 @@ send_test_message (struct GNUNET_CADET_Channel *channel) | |||
471 | { | 471 | { |
472 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending INITIALIZER\n"); | 472 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending INITIALIZER\n"); |
473 | size += 1000; | 473 | size += 1000; |
474 | counter = &data_sent; | 474 | payload = data_sent; |
475 | if (SPEED_ACK == test) // FIXME unify SPEED_ACK with an initializer | 475 | if (SPEED_ACK == test) // FIXME unify SPEED_ACK with an initializer |
476 | data_sent++; | 476 | data_sent++; |
477 | } | 477 | } |
478 | else if (SPEED == test || SPEED_ACK == test) | 478 | else if (SPEED == test || SPEED_ACK == test) |
479 | { | 479 | { |
480 | counter = get_target_channel() == channel ? &ack_sent : &data_sent; | 480 | if (get_target_channel() == channel) |
481 | size += *counter; | 481 | { |
482 | *counter = *counter + 1; | 482 | payload = ack_sent; |
483 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Sending message %u\n", *counter); | 483 | size += ack_sent; |
484 | ack_sent++; | ||
485 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
486 | "Sending ACK %u [%d bytes]\n", | ||
487 | payload, size); | ||
488 | } | ||
489 | else | ||
490 | { | ||
491 | payload = data_sent; | ||
492 | size += data_sent; | ||
493 | data_sent++; | ||
494 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
495 | "Sending DATA %u [%d bytes]\n", | ||
496 | data_sent, size); | ||
497 | } | ||
498 | } | ||
499 | else if (FORWARD == test) | ||
500 | { | ||
501 | payload = ack_sent; | ||
502 | } | ||
503 | else if (P2P_SIGNAL == test) | ||
504 | { | ||
505 | payload = data_sent; | ||
484 | } | 506 | } |
485 | else | 507 | else |
486 | { | 508 | { |
487 | counter = &ack_sent; | 509 | GNUNET_assert (0); |
488 | } | 510 | } |
489 | env = GNUNET_MQ_msg_extra (msg, size, GNUNET_MESSAGE_TYPE_DUMMY); | 511 | env = GNUNET_MQ_msg_extra (msg, size, GNUNET_MESSAGE_TYPE_DUMMY); |
490 | 512 | ||
491 | data = (uint32_t *) &msg[1]; | 513 | data = (uint32_t *) &msg[1]; |
492 | *data = htonl (*counter); | 514 | *data = htonl (payload); |
493 | GNUNET_MQ_send (GNUNET_CADET_get_mq (channel), env); | 515 | GNUNET_MQ_send (GNUNET_CADET_get_mq (channel), env); |
494 | } | 516 | } |
495 | 517 | ||
@@ -517,7 +539,10 @@ send_next_msg (void *cls) | |||
517 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 539 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
518 | "Scheduling message %d\n", | 540 | "Scheduling message %d\n", |
519 | data_sent + 1); | 541 | data_sent + 1); |
520 | send_next_msg_task = GNUNET_SCHEDULER_add_now (&send_next_msg, NULL); | 542 | send_next_msg_task = |
543 | GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_UNIT_SECONDS, | ||
544 | &send_next_msg, | ||
545 | NULL); | ||
521 | } | 546 | } |
522 | } | 547 | } |
523 | 548 | ||
@@ -585,7 +610,7 @@ handle_data (void *cls, const struct GNUNET_MessageHeader *message) | |||
585 | 610 | ||
586 | if (channel == outgoing_ch) | 611 | if (channel == outgoing_ch) |
587 | { | 612 | { |
588 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Root client got a message!\n"); | 613 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Root client got a message.\n"); |
589 | } | 614 | } |
590 | else if (channel == incoming_ch) | 615 | else if (channel == incoming_ch) |
591 | { | 616 | { |
@@ -685,8 +710,9 @@ connect_handler (void *cls, struct GNUNET_CADET_Channel *channel, | |||
685 | struct CadetTestChannelWrapper *ch; | 710 | struct CadetTestChannelWrapper *ch; |
686 | long peer = (long) cls; | 711 | long peer = (long) cls; |
687 | 712 | ||
688 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Incoming channel from %s to peer %ld\n", | 713 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
689 | GNUNET_i2s (source), peer); | 714 | "Incoming channel from %s to %ld: %p\n", |
715 | GNUNET_i2s (source), peer, channel); | ||
690 | ok++; | 716 | ok++; |
691 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, " ok: %d\n", ok); | 717 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, " ok: %d\n", ok); |
692 | if (peer == peers_requested - 1) | 718 | if (peer == peers_requested - 1) |
@@ -708,9 +734,9 @@ connect_handler (void *cls, struct GNUNET_CADET_Channel *channel, | |||
708 | if (NULL != disconnect_task) | 734 | if (NULL != disconnect_task) |
709 | { | 735 | { |
710 | GNUNET_SCHEDULER_cancel (disconnect_task); | 736 | GNUNET_SCHEDULER_cancel (disconnect_task); |
711 | disconnect_task = | 737 | disconnect_task = GNUNET_SCHEDULER_add_delayed (SHORT_TIME, |
712 | GNUNET_SCHEDULER_add_delayed (SHORT_TIME, &gather_stats_and_exit, | 738 | &gather_stats_and_exit, |
713 | (void *) __LINE__); | 739 | (void *) __LINE__); |
714 | } | 740 | } |
715 | 741 | ||
716 | /* TODO: cannot return channel as-is, in order to unify the data handlers */ | 742 | /* TODO: cannot return channel as-is, in order to unify the data handlers */ |
@@ -811,6 +837,7 @@ start_test (void *cls) | |||
811 | NULL, | 837 | NULL, |
812 | &disconnect_handler, | 838 | &disconnect_handler, |
813 | handlers); | 839 | handlers); |
840 | |||
814 | ch->ch = outgoing_ch; | 841 | ch->ch = outgoing_ch; |
815 | 842 | ||
816 | disconnect_task = GNUNET_SCHEDULER_add_delayed (SHORT_TIME, | 843 | disconnect_task = GNUNET_SCHEDULER_add_delayed (SHORT_TIME, |
@@ -824,7 +851,9 @@ start_test (void *cls) | |||
824 | data_sent = 0; | 851 | data_sent = 0; |
825 | ack_received = 0; | 852 | ack_received = 0; |
826 | ack_sent = 0; | 853 | ack_sent = 0; |
827 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending data initializer...\n"); | 854 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
855 | "Sending data initializer on channel %p...\n", | ||
856 | outgoing_ch); | ||
828 | send_test_message (outgoing_ch); | 857 | send_test_message (outgoing_ch); |
829 | } | 858 | } |
830 | 859 | ||