new: IKCP_FASTACK_CONSERVE
This commit is contained in:
parent
1a3773881a
commit
3a9196b1b7
@ -146,7 +146,7 @@ TCP是为流量设计的(每秒内可以传输多少KB的数据),讲究的
|
|||||||
- [asio-kcp](https://github.com/libinzhangyuan/asio_kcp): 使用 KCP的完整 UDP网络库,完整实现了基于 UDP的链接状态管理,会话控制,KCP协议调度等
|
- [asio-kcp](https://github.com/libinzhangyuan/asio_kcp): 使用 KCP的完整 UDP网络库,完整实现了基于 UDP的链接状态管理,会话控制,KCP协议调度等
|
||||||
- [kcp-java](https://github.com/hkspirt/kcp-java):Java版本 KCP协议实现。
|
- [kcp-java](https://github.com/hkspirt/kcp-java):Java版本 KCP协议实现。
|
||||||
- [kcp-netty](https://github.com/szhnet/kcp-netty):kcp的Java语言实现,基于netty。
|
- [kcp-netty](https://github.com/szhnet/kcp-netty):kcp的Java语言实现,基于netty。
|
||||||
- [java-Kcp](https://github.com/l42111996/java-Kcp): JAVA版本KCP,基于netty实现(包含fec功能)
|
- [java-kcp](https://github.com/l42111996/java-Kcp): JAVA版本KCP,基于netty实现(包含fec功能)
|
||||||
- [kcp-go](https://github.com/xtaci/kcp-go): 高安全性的kcp的 GO语言实现,包含 UDP会话管理的简单实现,可以作为后续开发的基础库。
|
- [kcp-go](https://github.com/xtaci/kcp-go): 高安全性的kcp的 GO语言实现,包含 UDP会话管理的简单实现,可以作为后续开发的基础库。
|
||||||
- [kcp-csharp](https://github.com/limpo1989/kcp-csharp): kcp的 csharp移植,同时包含一份回话管理,可以连接上面kcp-go的服务端。
|
- [kcp-csharp](https://github.com/limpo1989/kcp-csharp): kcp的 csharp移植,同时包含一份回话管理,可以连接上面kcp-go的服务端。
|
||||||
- [kcp-csharp](https://github.com/KumoKyaku/KCP): 新版本 Kcp的 csharp移植。线程安全,运行时无alloc,对gc无压力。
|
- [kcp-csharp](https://github.com/KumoKyaku/KCP): 新版本 Kcp的 csharp移植。线程安全,运行时无alloc,对gc无压力。
|
||||||
|
20
ikcp.c
20
ikcp.c
@ -604,7 +604,7 @@ static void ikcp_parse_una(ikcpcb *kcp, IUINT32 una)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ikcp_parse_fastack(ikcpcb *kcp, IUINT32 sn)
|
static void ikcp_parse_fastack(ikcpcb *kcp, IUINT32 sn, IUINT32 ts)
|
||||||
{
|
{
|
||||||
struct IQUEUEHEAD *p, *next;
|
struct IQUEUEHEAD *p, *next;
|
||||||
|
|
||||||
@ -618,7 +618,12 @@ static void ikcp_parse_fastack(ikcpcb *kcp, IUINT32 sn)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else if (sn != seg->sn) {
|
else if (sn != seg->sn) {
|
||||||
|
#ifndef IKCP_FASTACK_CONSERVE
|
||||||
seg->fastack++;
|
seg->fastack++;
|
||||||
|
#else
|
||||||
|
if (_itimediff(ts, seg->ts) >= 0)
|
||||||
|
seg->fastack++;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -742,7 +747,7 @@ void ikcp_parse_data(ikcpcb *kcp, IKCPSEG *newseg)
|
|||||||
int ikcp_input(ikcpcb *kcp, const char *data, long size)
|
int ikcp_input(ikcpcb *kcp, const char *data, long size)
|
||||||
{
|
{
|
||||||
IUINT32 prev_una = kcp->snd_una;
|
IUINT32 prev_una = kcp->snd_una;
|
||||||
IUINT32 maxack = 0;
|
IUINT32 maxack = 0, latest_ts = 0;
|
||||||
int flag = 0;
|
int flag = 0;
|
||||||
|
|
||||||
if (ikcp_canlog(kcp, IKCP_LOG_INPUT)) {
|
if (ikcp_canlog(kcp, IKCP_LOG_INPUT)) {
|
||||||
@ -791,9 +796,18 @@ int ikcp_input(ikcpcb *kcp, const char *data, long size)
|
|||||||
if (flag == 0) {
|
if (flag == 0) {
|
||||||
flag = 1;
|
flag = 1;
|
||||||
maxack = sn;
|
maxack = sn;
|
||||||
|
latest_ts = ts;
|
||||||
} else {
|
} else {
|
||||||
if (_itimediff(sn, maxack) > 0) {
|
if (_itimediff(sn, maxack) > 0) {
|
||||||
|
#ifndef IKCP_FASTACK_CONSERVE
|
||||||
maxack = sn;
|
maxack = sn;
|
||||||
|
latest_ts = ts;
|
||||||
|
#else
|
||||||
|
if (_itimediff(ts, latest_ts) > 0) {
|
||||||
|
maxack = sn;
|
||||||
|
latest_ts = ts;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ikcp_canlog(kcp, IKCP_LOG_IN_ACK)) {
|
if (ikcp_canlog(kcp, IKCP_LOG_IN_ACK)) {
|
||||||
@ -853,7 +867,7 @@ int ikcp_input(ikcpcb *kcp, const char *data, long size)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (flag != 0) {
|
if (flag != 0) {
|
||||||
ikcp_parse_fastack(kcp, maxack);
|
ikcp_parse_fastack(kcp, maxack, latest_ts);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_itimediff(kcp->snd_una, prev_una) > 0) {
|
if (_itimediff(kcp->snd_una, prev_una) > 0) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user