update rto calculation

This commit is contained in:
skywind3000 2020-03-26 19:28:17 +08:00
parent cf683713cb
commit 9158f84781
2 changed files with 6 additions and 4 deletions

6
ikcp.c
View File

@ -1056,9 +1056,11 @@ void ikcp_flush(ikcpcb *kcp)
segment->xmit++;
kcp->xmit++;
if (kcp->nodelay == 0) {
segment->rto += kcp->rx_rto;
segment->rto += _imax_(segment->rto, (IUINT32)kcp->rx_rto);
} else {
segment->rto += kcp->rx_rto / 2;
IINT32 step = (kcp->nodelay < 2)?
((IINT32)(segment->rto)) : kcp->rx_rto;
segment->rto += step / 2;
}
segment->resendts = current + segment->rto;
lost = 1;

View File

@ -70,8 +70,8 @@ void test(int mode)
// 第三个参数 interval为内部处理时钟默认设置为 10ms
// 第四个参数 resend为快速重传指标设置为2
// 第五个参数 为是否禁用常规流控,这里禁止
ikcp_nodelay(kcp1, 1, 10, 2, 1);
ikcp_nodelay(kcp2, 1, 10, 2, 1);
ikcp_nodelay(kcp1, 2, 10, 2, 1);
ikcp_nodelay(kcp2, 2, 10, 2, 1);
kcp1->rx_minrto = 10;
kcp1->fastresend = 1;
}