diff --git a/src/utp_stream.cpp b/src/utp_stream.cpp index 423313574..6bc1b1aea 100644 --- a/src/utp_stream.cpp +++ b/src/utp_stream.cpp @@ -136,8 +136,6 @@ enum { ACK_MASK = 0xffff, - // the number of packets that'll fit in the reorder buffer - max_packets_reorder = 512, // if a packet receives more than this number of // duplicate acks, we'll trigger a fast re-send @@ -2862,6 +2860,10 @@ bool utp_socket_impl::incoming_packet(boost::uint8_t const* buf, int size if (ph->get_type() == ST_DATA) m_sm->inc_stats_counter(counters::utp_payload_pkts_in); + // the number of packets that'll fit in the reorder buffer + // incoming MTU of 1100 and minimal size of 16 packets are chosen arbitrarly + const boost::uint32_t max_packets_reorder = std::max(16, m_in_buf_size / 1100); + if (m_state != UTP_STATE_NONE && m_state != UTP_STATE_SYN_SENT && compare_less_wrap((m_ack_nr + max_packets_reorder) & ACK_MASK, ph->seq_nr, ACK_MASK))