mirror of https://github.com/v2ray/v2ray-core
congestion control
parent
af5a2ac0bc
commit
812ac54290
|
@ -114,6 +114,7 @@ func NewKCP(conv uint16, mtu uint32, sendingWindowSize uint32, receivingWindowSi
|
||||||
kcp.rcv_buf = NewReceivingWindow(receivingWindowSize)
|
kcp.rcv_buf = NewReceivingWindow(receivingWindowSize)
|
||||||
kcp.snd_queue = NewSendingQueue(sendingQueueSize)
|
kcp.snd_queue = NewSendingQueue(sendingQueueSize)
|
||||||
kcp.acklist = new(ACKList)
|
kcp.acklist = new(ACKList)
|
||||||
|
kcp.cwnd = kcp.snd_wnd
|
||||||
return kcp
|
return kcp
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -404,13 +405,7 @@ func (kcp *KCP) flush() {
|
||||||
}
|
}
|
||||||
|
|
||||||
current := kcp.current
|
current := kcp.current
|
||||||
//lost := false
|
lost := false
|
||||||
|
|
||||||
//var seg Segment
|
|
||||||
//seg.conv = kcp.conv
|
|
||||||
//seg.cmd = IKCP_CMD_ACK
|
|
||||||
//seg.wnd = uint32(kcp.rcv_nxt + kcp.rcv_wnd)
|
|
||||||
//seg.una = kcp.rcv_nxt
|
|
||||||
|
|
||||||
// flush acknowledges
|
// flush acknowledges
|
||||||
ackSeg := kcp.acklist.AsSegment()
|
ackSeg := kcp.acklist.AsSegment()
|
||||||
|
@ -457,12 +452,13 @@ func (kcp *KCP) flush() {
|
||||||
segment.transmit++
|
segment.transmit++
|
||||||
kcp.xmit++
|
kcp.xmit++
|
||||||
segment.timeout = current + kcp.rx_rto
|
segment.timeout = current + kcp.rx_rto
|
||||||
//lost = true
|
lost = true
|
||||||
} else if segment.ackSkipped >= resent {
|
} else if segment.ackSkipped >= resent {
|
||||||
needsend = true
|
needsend = true
|
||||||
segment.transmit++
|
segment.transmit++
|
||||||
segment.ackSkipped = 0
|
segment.ackSkipped = 0
|
||||||
segment.timeout = current + kcp.rx_rto
|
segment.timeout = current + kcp.rx_rto
|
||||||
|
lost = true
|
||||||
}
|
}
|
||||||
|
|
||||||
if needsend {
|
if needsend {
|
||||||
|
@ -501,34 +497,19 @@ func (kcp *KCP) flush() {
|
||||||
// flash remain segments
|
// flash remain segments
|
||||||
kcp.output.Flush()
|
kcp.output.Flush()
|
||||||
|
|
||||||
// update ssthresh
|
if kcp.congestionControl {
|
||||||
// rate halving, https://tools.ietf.org/html/rfc6937
|
|
||||||
/*
|
|
||||||
if change != 0 {
|
|
||||||
inflight := kcp.snd_nxt - kcp.snd_una
|
|
||||||
kcp.ssthresh = inflight / 2
|
|
||||||
if kcp.ssthresh < IKCP_THRESH_MIN {
|
|
||||||
kcp.ssthresh = IKCP_THRESH_MIN
|
|
||||||
}
|
|
||||||
kcp.cwnd = kcp.ssthresh + resent
|
|
||||||
kcp.incr = kcp.cwnd * kcp.mss
|
|
||||||
}*/
|
|
||||||
|
|
||||||
// congestion control, https://tools.ietf.org/html/rfc5681
|
|
||||||
/*
|
|
||||||
if lost {
|
if lost {
|
||||||
kcp.ssthresh = cwnd / 2
|
kcp.cwnd = 3 * kcp.cwnd / 4
|
||||||
if kcp.ssthresh < IKCP_THRESH_MIN {
|
} else {
|
||||||
kcp.ssthresh = IKCP_THRESH_MIN
|
kcp.cwnd += kcp.cwnd / 4
|
||||||
|
}
|
||||||
|
if kcp.cwnd < 4 {
|
||||||
|
kcp.cwnd = 4
|
||||||
|
}
|
||||||
|
if kcp.cwnd > kcp.snd_wnd {
|
||||||
|
kcp.cwnd = kcp.snd_wnd
|
||||||
}
|
}
|
||||||
kcp.cwnd = 1
|
|
||||||
kcp.incr = kcp.mss
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if kcp.cwnd < 1 {
|
|
||||||
kcp.cwnd = 1
|
|
||||||
kcp.incr = kcp.mss
|
|
||||||
}*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update updates state (call it repeatedly, every 10ms-100ms), or you can ask
|
// Update updates state (call it repeatedly, every 10ms-100ms), or you can ask
|
||||||
|
|
Loading…
Reference in New Issue