Commit 3cca4015 by xiongguangjie

fix rtt and rtt variance

parent 62dfed39
...@@ -308,7 +308,7 @@ void SrtTransport::handleDropReq(uint8_t *buf, int len, struct sockaddr_storage ...@@ -308,7 +308,7 @@ void SrtTransport::handleDropReq(uint8_t *buf, int len, struct sockaddr_storage
} }
auto nak_interval = (_rtt+_rtt_variance*4)/2; auto nak_interval = (_rtt+_rtt_variance*4)/2;
if(nak_interval >= 20*1000){ if(nak_interval <= 20*1000){
nak_interval = 20*1000; nak_interval = 20*1000;
} }
if(_nak_ticker.elapsedTime(_now)>nak_interval){ if(_nak_ticker.elapsedTime(_now)>nak_interval){
...@@ -346,9 +346,11 @@ void SrtTransport::handleACKACK(uint8_t *buf, int len, struct sockaddr_storage * ...@@ -346,9 +346,11 @@ void SrtTransport::handleACKACK(uint8_t *buf, int len, struct sockaddr_storage *
pkt->loadFromData(buf,len); pkt->loadFromData(buf,len);
uint32_t rtt = DurationCountMicroseconds(_now - _ack_send_timestamp[pkt->ack_number]); uint32_t rtt = DurationCountMicroseconds(_now - _ack_send_timestamp[pkt->ack_number]);
_rtt_variance = (3*_rtt_variance+abs((long)(_rtt - rtt)))/4; _rtt_variance = (3*_rtt_variance+abs((long)_rtt - (long)rtt))/4;
_rtt = (7*rtt+_rtt)/8; _rtt = (7*rtt+_rtt)/8;
//TraceL<<" rtt:"<<_rtt<<" rtt variance:"<<_rtt_variance;
_ack_send_timestamp.erase(pkt->ack_number); _ack_send_timestamp.erase(pkt->ack_number);
} }
...@@ -426,19 +428,22 @@ void SrtTransport::handleDataPacket(uint8_t *buf, int len, struct sockaddr_stora ...@@ -426,19 +428,22 @@ void SrtTransport::handleDataPacket(uint8_t *buf, int len, struct sockaddr_stora
onSRTData(std::move(data)); onSRTData(std::move(data));
} }
if(list.empty()){
//TraceL<<_recv_buf->dump();
}
auto nak_interval = (_rtt+_rtt_variance*4)/2; auto nak_interval = (_rtt+_rtt_variance*4)/2;
if(nak_interval <= 20*1000){ if(nak_interval <= 20*1000){
nak_interval = 20*1000; nak_interval = 20*1000;
} }
if(list.empty()){
//TraceL<<_recv_buf->dump()<<" nake interval:"<<nak_interval/1000<<" ticker:"<<_nak_ticker.elapsedTime(_now)/1000;
}
if(_nak_ticker.elapsedTime(_now)>nak_interval){ if(_nak_ticker.elapsedTime(_now)>nak_interval){
auto lost = _recv_buf->getLostSeq(); auto lost = _recv_buf->getLostSeq();
if(!lost.empty()){ if(!lost.empty()){
sendNAKPacket(lost); sendNAKPacket(lost);
//TraceL<<"send NAK"; //TraceL<<"send NAK";
}else{
//TraceL<<"lost is empty";
} }
_nak_ticker.resetTime(_now); _nak_ticker.resetTime(_now);
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论