aboutsummaryrefslogtreecommitdiff
path: root/src/stream
diff options
context:
space:
mode:
authorSree Harsha Totakura <totakura@in.tum.de>2012-09-22 22:10:53 +0000
committerSree Harsha Totakura <totakura@in.tum.de>2012-09-22 22:10:53 +0000
commit352999acf6e0f360bbbdb4ed05d2a3a18b2c8fe4 (patch)
treee98a225038b98f196331b92cde5c8c54db9eb6ba /src/stream
parent97af2e18b39220b23e5ef725914206eedd64cdbf (diff)
downloadgnunet-352999acf6e0f360bbbdb4ed05d2a3a18b2c8fe4.tar.gz
gnunet-352999acf6e0f360bbbdb4ed05d2a3a18b2c8fe4.zip
fixing stream data retransmissions
Diffstat (limited to 'src/stream')
-rw-r--r--src/stream/stream_api.c43
1 files changed, 20 insertions, 23 deletions
diff --git a/src/stream/stream_api.c b/src/stream/stream_api.c
index c618d3f2b..6cf732081 100644
--- a/src/stream/stream_api.c
+++ b/src/stream/stream_api.c
@@ -482,6 +482,14 @@ struct GNUNET_STREAM_IOWriteHandle
482 * Number of bytes in this write handle 482 * Number of bytes in this write handle
483 */ 483 */
484 size_t size; 484 size_t size;
485
486 /**
487 * Number of packets already transmitted from this IO handle. Retransmitted
488 * packets are not taken into account here. This is used to determine which
489 * packets account for retransmission and which packets occupy buffer space at
490 * the receiver.
491 */
492 unsigned int packets_sent;
485}; 493};
486 494
487 495
@@ -857,36 +865,23 @@ static void
857write_data (struct GNUNET_STREAM_Socket *socket) 865write_data (struct GNUNET_STREAM_Socket *socket)
858{ 866{
859 struct GNUNET_STREAM_IOWriteHandle *io_handle = socket->write_handle; 867 struct GNUNET_STREAM_IOWriteHandle *io_handle = socket->write_handle;
860 int packet; /* Although an int, should never be negative */ 868 unsigned int packet;
861 int ack_packet; 869
862 870 for (packet=0; packet < io_handle->packets_sent; packet++)
863 ack_packet = -1;
864 /* Find the last acknowledged packet */
865 for (packet=0; packet < GNUNET_STREAM_ACK_BITMAP_BIT_LENGTH; packet++)
866 {
867 if (GNUNET_YES == ackbitmap_is_bit_set (&io_handle->ack_bitmap,
868 packet))
869 ack_packet = packet;
870 else if (NULL == io_handle->messages[packet])
871 break;
872 }
873 /* Resend packets which weren't ack'ed */
874 for (packet=0; packet < ack_packet; packet++)
875 { 871 {
876 if (GNUNET_NO == ackbitmap_is_bit_set (&io_handle->ack_bitmap, 872 if (GNUNET_NO == ackbitmap_is_bit_set (&io_handle->ack_bitmap,
877 packet)) 873 packet))
878 { 874 {
879 LOG (GNUNET_ERROR_TYPE_DEBUG, 875 LOG (GNUNET_ERROR_TYPE_DEBUG,
880 "%s: Placing DATA message with sequence %u in send queue\n", 876 "%s: Retransmitting DATA message with sequence %u\n",
881 GNUNET_i2s (&socket->other_peer), 877 GNUNET_i2s (&socket->other_peer),
882 ntohl (io_handle->messages[packet]->sequence_number)); 878 ntohl (io_handle->messages[packet]->sequence_number));
883 copy_and_queue_message (socket, 879 copy_and_queue_message (socket,
884 &io_handle->messages[packet]->header, 880 &io_handle->messages[packet]->header,
885 NULL, 881 NULL,
886 NULL); 882 NULL);
887 } 883 }
888 } 884 }
889 packet = ack_packet + 1;
890 /* Now send new packets if there is enough buffer space */ 885 /* Now send new packets if there is enough buffer space */
891 while ( (NULL != io_handle->messages[packet]) && 886 while ( (NULL != io_handle->messages[packet]) &&
892 (socket->receiver_window_available 887 (socket->receiver_window_available
@@ -905,6 +900,7 @@ write_data (struct GNUNET_STREAM_Socket *socket)
905 NULL); 900 NULL);
906 packet++; 901 packet++;
907 } 902 }
903 io_handle->packets_sent = packet;
908 if (GNUNET_SCHEDULER_NO_TASK == socket->data_retransmission_task_id) 904 if (GNUNET_SCHEDULER_NO_TASK == socket->data_retransmission_task_id)
909 socket->data_retransmission_task_id = 905 socket->data_retransmission_task_id =
910 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply 906 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
@@ -3339,6 +3335,7 @@ GNUNET_STREAM_write (struct GNUNET_STREAM_Socket *socket,
3339 io_handle->write_cont = write_cont; 3335 io_handle->write_cont = write_cont;
3340 io_handle->write_cont_cls = write_cont_cls; 3336 io_handle->write_cont_cls = write_cont_cls;
3341 io_handle->size = size; 3337 io_handle->size = size;
3338 io_handle->packets_sent = 0;
3342 sweep = data; 3339 sweep = data;
3343 /* FIXME: Remove the fixed delay for ack deadline; Set it to the value 3340 /* FIXME: Remove the fixed delay for ack deadline; Set it to the value
3344 determined from RTT */ 3341 determined from RTT */