mirror of
https://github.com/skywind3000/kcp.git
synced 2026-08-19 06:03:28 +08:00
simple pacing
This commit is contained in:
13
ikcp.c
13
ikcp.c
@@ -981,6 +981,7 @@ void ikcp_flush(ikcpcb *kcp)
|
||||
IUINT32 rtomin;
|
||||
IUINT32 prior_cwnd;
|
||||
IUINT32 eff_cwnd, cur_inflight;
|
||||
IINT32 pacing_budget = -1;
|
||||
struct IQUEUEHEAD *p;
|
||||
int change = 0;
|
||||
int lost = 0;
|
||||
@@ -993,6 +994,10 @@ void ikcp_flush(ikcpcb *kcp)
|
||||
kcp->ccops->on_tick(kcp);
|
||||
}
|
||||
|
||||
if (kcp->ccops && kcp->ccops->pacing_rate) {
|
||||
pacing_budget = (IINT32)kcp->ccops->pacing_rate(kcp);
|
||||
}
|
||||
|
||||
prior_cwnd = kcp->cwnd;
|
||||
|
||||
seg.conv = kcp->conv;
|
||||
@@ -1149,6 +1154,10 @@ void ikcp_flush(ikcpcb *kcp)
|
||||
segment->wnd = seg.wnd;
|
||||
segment->una = kcp->rcv_nxt;
|
||||
|
||||
if (pacing_budget >= 0 && pacing_budget < (IINT32)segment->len) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (kcp->ccops && kcp->ccops->on_pkt_sent) {
|
||||
kcp->ccops->on_pkt_sent(kcp, segment->sn, current,
|
||||
segment->len, kcp->nsnd_buf, segment->xmit);
|
||||
@@ -1169,6 +1178,10 @@ void ikcp_flush(ikcpcb *kcp)
|
||||
ptr += segment->len;
|
||||
}
|
||||
|
||||
if (pacing_budget >= 0) {
|
||||
pacing_budget -= (IINT32)segment->len;
|
||||
}
|
||||
|
||||
if (segment->xmit >= kcp->dead_link) {
|
||||
kcp->state = (IUINT32)-1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user