From c363b30360cb58e45e6b47a206c511f5b4cf46dc Mon Sep 17 00:00:00 2001 From: xiongguangjie Date: Fri, 23 Sep 2022 09:35:10 +0800 Subject: [PATCH] srt optimize ack send logic ignore too many ack packet --- srt/SrtTransport.cpp | 14 ++++++++++---- srt/SrtTransport.hpp | 2 +- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/srt/SrtTransport.cpp b/srt/SrtTransport.cpp index 89a83cb2..503f11dd 100644 --- a/srt/SrtTransport.cpp +++ b/srt/SrtTransport.cpp @@ -292,7 +292,7 @@ void SrtTransport::handleHandshakeConclusion(HandshakePacket &pkt, struct sockad return; } - //_last_ack_pkt_seq_num = _init_seq_number; + _last_ack_pkt_seq = _init_seq_number; } void SrtTransport::handleHandshake(uint8_t *buf, int len, struct sockaddr_storage *addr) { @@ -437,7 +437,13 @@ void SrtTransport::checkAndSendAckNak(){ _light_ack_pkt_count = 0; _ack_ticker.resetTime(_now); // send a ack per 10 ms for receiver - sendACKPacket(); + if(_last_ack_pkt_seq != _recv_buf->getExpectedSeq()){ + //TraceL<<"send a ack packet"; + sendACKPacket(); + }else{ + //TraceL<<" ignore repeate ack packet"; + } + } else { if (_light_ack_pkt_count >= 64) { // for high bitrate stream send light ack @@ -519,7 +525,7 @@ void SrtTransport::sendACKPacket() { } pkt->storeToData(); _ack_send_timestamp[pkt->ack_number] = _now; - //_last_ack_pkt_seq_num = pkt->last_ack_pkt_seq_number; + _last_ack_pkt_seq = pkt->last_ack_pkt_seq_number; sendControlPacket(pkt, true); // TraceL<<"send ack "<dump(); // TraceL<<_recv_buf->dump(); @@ -539,7 +545,7 @@ void SrtTransport::sendLightACKPacket() { pkt->estimated_link_capacity = 0; pkt->recv_rate = 0; pkt->storeToData(); - //_last_ack_pkt_seq_num = pkt->last_ack_pkt_seq_number; + _last_ack_pkt_seq = pkt->last_ack_pkt_seq_number; sendControlPacket(pkt, true); TraceL << "send ack " << pkt->dump(); } diff --git a/srt/SrtTransport.hpp b/srt/SrtTransport.hpp index ecb2eb42..094ba1b3 100644 --- a/srt/SrtTransport.hpp +++ b/srt/SrtTransport.hpp @@ -133,7 +133,7 @@ private: uint32_t _rtt_variance = 50 * 1000; uint32_t _light_ack_pkt_count = 0; uint32_t _ack_number_count = 0; - //uint32_t _last_ack_pkt_seq_num = 0; + uint32_t _last_ack_pkt_seq = 0; uint32_t _last_recv_ackack_seq_num = 0; uint32_t _last_pkt_seq = 0;