diff --git a/srtcore/buffer_rcv.cpp b/srtcore/buffer_rcv.cpp index 1f46788aa..7ea0945bc 100644 --- a/srtcore/buffer_rcv.cpp +++ b/srtcore/buffer_rcv.cpp @@ -130,7 +130,7 @@ CRcvBuffer::CRcvBuffer(int initSeqNo, size_t size, CUnitQueue* unitqueue, bool b , m_bMessageAPI(bMessageAPI) , m_iBytesCount(0) , m_iPktsCount(0) - , m_uAvgPayloadSz(SRT_LIVE_DEF_PLSIZE) + , m_uAvgPayloadSz(0) { SRT_ASSERT(size < size_t(std::numeric_limits::max())); // All position pointers are integers } @@ -758,7 +758,12 @@ void CRcvBuffer::countBytes(int pkts, int bytes) m_iBytesCount += bytes; // added or removed bytes from rcv buffer m_iPktsCount += pkts; if (bytes > 0) // Assuming one pkt when adding bytes - m_uAvgPayloadSz = avg_iir<100>(m_uAvgPayloadSz, (unsigned) bytes); + { + if (!m_uAvgPayloadSz) + m_uAvgPayloadSz = bytes; + else + m_uAvgPayloadSz = avg_iir<100>(m_uAvgPayloadSz, (unsigned) bytes); + } } void CRcvBuffer::releaseUnitInPos(int pos) diff --git a/srtcore/channel.cpp b/srtcore/channel.cpp index 091adf115..38ce5b598 100644 --- a/srtcore/channel.cpp +++ b/srtcore/channel.cpp @@ -1016,6 +1016,15 @@ srt::EReadStatus srt::CChannel::recvfrom(sockaddr_any& w_addr, CPacket& w_packet if ((msg_flags & errmsgflg[i].first) != 0) flg << " " << errmsgflg[i].second; + if (msg_flags & MSG_TRUNC) + { + // Additionally show buffer information in this case + flg << " buffers: "; + for (size_t i = 0; i < CPacket::PV_SIZE; ++i) + { + flg << "[" << w_packet.m_PacketVector[i].iov_len << "] "; + } + } // This doesn't work the same way on Windows, so on Windows just skip it. #endif diff --git a/srtcore/common.cpp b/srtcore/common.cpp index b621c8025..dc60b3db7 100644 --- a/srtcore/common.cpp +++ b/srtcore/common.cpp @@ -205,7 +205,7 @@ void srt::CIPAddress::pton(sockaddr_any& w_addr, const uint32_t ip[4], const soc { // Check if the peer address is a model of IPv4-mapped-on-IPv6. // If so, it means that the `ip` array should be interpreted as IPv4. - const bool is_mapped_ipv4 = checkMappedIPv4((uint16_t*)peer.sin6.sin6_addr.s6_addr); + const bool is_mapped_ipv4 = checkMappedIPv4(peer.sin6); sockaddr_in6* a = (&w_addr.sin6); diff --git a/srtcore/common.h b/srtcore/common.h index 5021fa5a8..de42a7d83 100644 --- a/srtcore/common.h +++ b/srtcore/common.h @@ -1422,6 +1422,15 @@ inline std::string SrtVersionString(int version) bool SrtParseConfig(const std::string& s, SrtConfig& w_config); +bool checkMappedIPv4(const uint16_t* sa); + +inline bool checkMappedIPv4(const sockaddr_in6& sa) +{ + const uint16_t* addr = reinterpret_cast(&sa.sin6_addr.s6_addr); + return checkMappedIPv4(addr); +} + + } // namespace srt #endif diff --git a/srtcore/congctl.cpp b/srtcore/congctl.cpp index 91c73d660..b9265c046 100644 --- a/srtcore/congctl.cpp +++ b/srtcore/congctl.cpp @@ -63,6 +63,7 @@ class LiveCC: public SrtCongestionControlBase int64_t m_llSndMaxBW; //Max bandwidth (bytes/sec) srt::sync::atomic m_zSndAvgPayloadSize; //Average Payload Size of packets to xmit size_t m_zMaxPayloadSize; + size_t m_zHeaderSize; // NAKREPORT stuff. int m_iMinNakInterval_us; // Minimum NAK Report Period (usec) @@ -81,6 +82,8 @@ class LiveCC: public SrtCongestionControlBase m_zMaxPayloadSize = parent->maxPayloadSize(); m_zSndAvgPayloadSize = m_zMaxPayloadSize; + m_zHeaderSize = parent->m_config.iMSS - parent->maxPayloadSize(); + m_iMinNakInterval_us = 20000; //Minimum NAK Report Period (usec) m_iNakReportAccel = 2; //Default NAK Report Period (RTT) accelerator (send periodic NAK every RTT/2) @@ -173,7 +176,7 @@ class LiveCC: public SrtCongestionControlBase void updatePktSndPeriod() { // packet = payload + header - const double pktsize = (double) m_zSndAvgPayloadSize.load() + CPacket::SRT_DATA_HDR_SIZE; + const double pktsize = (double) m_zSndAvgPayloadSize.load() + m_zHeaderSize; m_dPktSndPeriod = 1000 * 1000.0 * (pktsize / m_llSndMaxBW); HLOGC(cclog.Debug, log << "LiveCC: sending period updated: " << m_dPktSndPeriod << " by avg pktsize=" << m_zSndAvgPayloadSize