diff --git a/srtcore/common.h b/srtcore/common.h index 89d77686a8..6350c22222 100644 --- a/srtcore/common.h +++ b/srtcore/common.h @@ -210,7 +210,7 @@ struct EventVariant union U { CPacket* packet; - uint32_t ack; + int32_t ack; struct { int32_t* ptr; @@ -238,7 +238,7 @@ struct EventVariant } void operator=(CPacket* arg) { Assign(arg); }; - void operator=(uint32_t arg) { Assign(arg); }; + void operator=(int32_t arg) { Assign(arg); }; void operator=(ECheckTimerStage arg) { Assign(arg); }; void operator=(EInitEvent arg) { Assign(arg); }; @@ -323,7 +323,7 @@ template<> struct EventVariant::VariantFor template<> struct EventVariant::VariantFor { - typedef uint32_t type; + typedef int32_t type; static type U::*field() { return &U::ack; } }; diff --git a/srtcore/congctl.cpp b/srtcore/congctl.cpp index 6cd07214fa..5d4a507fff 100644 --- a/srtcore/congctl.cpp +++ b/srtcore/congctl.cpp @@ -248,9 +248,6 @@ class FileCC: public SrtCongestionControlBase { typedef FileCC Me; // Required by SSLOT macro - // Fields from CCC not used by LiveCC - int m_iACKPeriod; - // Fields from CUDTCC int m_iRCInterval; // UDT Rate control interval uint64_t m_LastRCTime; // last rate increase time @@ -270,7 +267,6 @@ class FileCC: public SrtCongestionControlBase FileCC(CUDT* parent) : SrtCongestionControlBase(parent) - , m_iACKPeriod(CUDT::COMM_SYN_INTERVAL_US) , m_iRCInterval(CUDT::COMM_SYN_INTERVAL_US) , m_LastRCTime(CTimer::getTime()) , m_bSlowStart(true) diff --git a/srtcore/congctl.h b/srtcore/congctl.h index cdb2ff4a38..6c87678a56 100644 --- a/srtcore/congctl.h +++ b/srtcore/congctl.h @@ -156,19 +156,17 @@ class SrtCongestionControlBase // If not, it will be internally calculated. virtual int RTO() { return 0; } - // How many packets to send one ACK, in packets. - // If user-defined, will return nonzero value. It can enforce extra ACKs - // beside those calculated by ACK, sent only when the number of packets - // received since the last EXP that fired "fat" ACK does not exceed this - // value. - virtual int ACKInterval() { return 0; } - - // Periodical timer to send an ACK, in microseconds. - // If user-defined, this value in microseconds will be used to calculate + // ACK interval in packets. + // Specifies the number of packets to receive before sending the ACK. + // Used by CUDT together with ACKIntervalMicrosec() to trigger ACK packet sending. + virtual int ACKIntervalPkts() const { return 0; } + + // Periodical interval to send an ACK, in microseconds. + // If user-defined, this value will be used to calculate // the next ACK time every time ACK is considered to be sent (see CUDT::checkTimers). // Otherwise this will be calculated internally in CUDT, normally taken - // from CPacket::SYN_INTERVAL. - virtual int ACKPeriod() { return 0; } + // from CUDT::COMM_SYN_INTERVAL_US. + virtual int ACKIntervalMicrosec() const { return 0; } // Called when the settings concerning m_llMaxBW were changed. // Arg 1: value of CUDT::m_llMaxBW diff --git a/srtcore/core.cpp b/srtcore/core.cpp index 235279d3f3..2b9a5063c8 100644 --- a/srtcore/core.cpp +++ b/srtcore/core.cpp @@ -1287,8 +1287,6 @@ void CUDT::open() m_iRTTVar = m_iRTT >> 1; m_ullCPUFrequency = CTimer::getCPUFrequency(); - // set up the timers - m_ullSYNInt_tk = COMM_SYN_INTERVAL_US * m_ullCPUFrequency; // set minimum NAK and EXP timeout to 300ms /* @@ -1303,16 +1301,17 @@ void CUDT::open() else #endif */ + // Set up timers m_ullMinNakInt_tk = 300000 * m_ullCPUFrequency; m_ullMinExpInt_tk = 300000 * m_ullCPUFrequency; - m_ullACKInt_tk = m_ullSYNInt_tk; + m_ullACKInt_tk = COMM_SYN_INTERVAL_US * m_ullCPUFrequency; m_ullNAKInt_tk = m_ullMinNakInt_tk; uint64_t currtime_tk; CTimer::rdtsc(currtime_tk); m_ullLastRspTime_tk = currtime_tk; - m_ullNextACKTime_tk = currtime_tk + m_ullSYNInt_tk; + m_ullNextACKTime_tk = currtime_tk + m_ullACKInt_tk; m_ullNextNAKTime_tk = currtime_tk + m_ullNAKInt_tk; m_ullLastRspAckTime_tk = currtime_tk; m_ullLastSndTime_tk = currtime_tk; @@ -4788,7 +4787,7 @@ void CUDT::setupCC() uint64_t currtime_tk; CTimer::rdtsc(currtime_tk); m_ullLastRspTime_tk = currtime_tk; - m_ullNextACKTime_tk = currtime_tk + m_ullSYNInt_tk; + m_ullNextACKTime_tk = currtime_tk + m_ullACKInt_tk; m_ullNextNAKTime_tk = currtime_tk + m_ullNAKInt_tk; m_ullLastRspAckTime_tk = currtime_tk; m_ullLastSndTime_tk = currtime_tk; @@ -6628,7 +6627,8 @@ void CUDT::sendCtrl(UDTMessageType pkttype, void* lparam, void* rparam, int size if (data[ACKD_BUFFERLEFT] < 2) data[ACKD_BUFFERLEFT] = 2; - if (currtime_tk - m_ullLastAckTime_tk > m_ullSYNInt_tk) + // NOTE: m_CongCtl->ACKIntervalMicrosec() should be taken into account. + if (currtime_tk - m_ullLastAckTime_tk > m_ullACKInt_tk) { int rcvRate; int ctrlsz = ACKD_TOTAL_SIZE_UDTBASE * ACKD_FIELD_SIZE; // Minimum required size @@ -6648,7 +6648,6 @@ void CUDT::sendCtrl(UDTMessageType pkttype, void* lparam, void* rparam, int size // Normal, currently expected version. data[ACKD_RCVRATE] = rcvRate; //bytes/sec ctrlsz = ACKD_FIELD_SIZE * ACKD_TOTAL_SIZE_VER101; - } // ELSE: leave the buffer with ...UDTBASE size. @@ -8666,17 +8665,17 @@ void CUDT::addLossRecord(std::vector& lr, int32_t lo, int32_t hi) void CUDT::checkACKTimer(uint64_t currtime_tk) { if (currtime_tk > m_ullNextACKTime_tk // ACK time has come - // OR the number of sent packets since last ACK has reached - // the congctl-defined value of ACK Interval - // (note that none of the builtin congctls defines ACK Interval) - || (m_CongCtl->ACKInterval() > 0 && m_iPktCount >= m_CongCtl->ACKInterval())) + // OR the number of sent packets since last ACK has reached + // the congctl-defined value of ACK Interval + // (note that none of the builtin congctls defines ACK Interval) + || (m_CongCtl->ACKIntervalPkts() > 0 && m_iPktCount >= m_CongCtl->ACKIntervalPkts())) { // ACK timer expired or ACK interval is reached sendCtrl(UMSG_ACK); CTimer::rdtsc(currtime_tk); - const int ack_interval_tk = m_CongCtl->ACKPeriod() > 0 - ? m_CongCtl->ACKPeriod() * m_ullCPUFrequency + const int ack_interval_tk = m_CongCtl->ACKIntervalMicrosec() > 0 + ? m_CongCtl->ACKIntervalMicrosec() * m_ullCPUFrequency : m_ullACKInt_tk; m_ullNextACKTime_tk = currtime_tk + ack_interval_tk; diff --git a/srtcore/core.h b/srtcore/core.h index 550b064129..b5d3398caa 100644 --- a/srtcore/core.h +++ b/srtcore/core.h @@ -795,7 +795,6 @@ class CUDT uint64_t m_ullNextACKTime_tk; // Next ACK time, in CPU clock cycles, same below uint64_t m_ullNextNAKTime_tk; // Next NAK time - volatile uint64_t m_ullSYNInt_tk; // SYN interval volatile uint64_t m_ullACKInt_tk; // ACK interval volatile uint64_t m_ullNAKInt_tk; // NAK interval volatile uint64_t m_ullLastRspTime_tk; // time stamp of last response from the peer diff --git a/srtcore/packet.h b/srtcore/packet.h index 13f38820e8..3a26f8a760 100644 --- a/srtcore/packet.h +++ b/srtcore/packet.h @@ -416,7 +416,7 @@ friend class CRcvQueue; int32_t& m_iSeqNo; // alias: sequence number int32_t& m_iMsgNo; // alias: message number int32_t& m_iTimeStamp; // alias: timestamp - int32_t& m_iID; // alias: socket ID + int32_t& m_iID; // alias: socket ID char*& m_pcData; // alias: data/control information //static const int m_iPktHdrSize; // packet header size diff --git a/test/test_epoll.cpp b/test/test_epoll.cpp index 5bee608ce7..11adfaf992 100644 --- a/test/test_epoll.cpp +++ b/test/test_epoll.cpp @@ -247,7 +247,6 @@ TEST(CEPoll, NotifyConnectionBreak) SRTSOCKET client_sock = srt_socket(AF_INET, SOCK_DGRAM, 0); ASSERT_NE(client_sock, SRT_ERROR); - const int yes = 1; const int no = 0; ASSERT_NE(srt_setsockopt(client_sock, 0, SRTO_RCVSYN, &no, sizeof no), SRT_ERROR); // for async connect ASSERT_NE(srt_setsockopt(client_sock, 0, SRTO_SNDSYN, &no, sizeof no), SRT_ERROR); // for async connect