mirror of
https://github.com/v2fly/v2ray-core.git
synced 2025-01-18 07:17:32 -05:00
refine mtu settings
This commit is contained in:
parent
8e98ede75d
commit
a2abdc3d2f
@ -69,8 +69,7 @@ func NewConnection(conv uint16, writerCloser io.WriteCloser, local *net.UDPAddr,
|
||||
Authenticator: block,
|
||||
Writer: writerCloser,
|
||||
}
|
||||
mtu := effectiveConfig.Mtu - uint32(block.HeaderSize()) - headerSize
|
||||
conn.kcp = NewKCP(conv, mtu, effectiveConfig.GetSendingWindowSize(), effectiveConfig.GetReceivingWindowSize(), conn.writeBufferSize, authWriter)
|
||||
conn.kcp = NewKCP(conv, effectiveConfig.GetSendingWindowSize(), effectiveConfig.GetReceivingWindowSize(), conn.writeBufferSize, authWriter)
|
||||
conn.kcp.NoDelay(effectiveConfig.Tti, 2, effectiveConfig.Congestion)
|
||||
conn.kcp.current = conn.Elapsed()
|
||||
|
||||
|
@ -7,7 +7,6 @@ package kcp
|
||||
|
||||
import (
|
||||
"github.com/v2ray/v2ray-core/common/alloc"
|
||||
v2io "github.com/v2ray/v2ray-core/common/io"
|
||||
"github.com/v2ray/v2ray-core/common/log"
|
||||
)
|
||||
|
||||
@ -46,7 +45,7 @@ type KCP struct {
|
||||
receivingUpdated bool
|
||||
lastPingTime uint32
|
||||
|
||||
mtu, mss uint32
|
||||
mss uint32
|
||||
snd_una, snd_nxt, rcv_nxt uint32
|
||||
rx_rttvar, rx_srtt, rx_rto uint32
|
||||
snd_wnd, rcv_wnd, rmt_wnd, cwnd uint32
|
||||
@ -66,18 +65,17 @@ type KCP struct {
|
||||
|
||||
// NewKCP create a new kcp control object, 'conv' must equal in two endpoint
|
||||
// from the same connection.
|
||||
func NewKCP(conv uint16, mtu uint32, sendingWindowSize uint32, receivingWindowSize uint32, sendingQueueSize uint32, output v2io.Writer) *KCP {
|
||||
func NewKCP(conv uint16, sendingWindowSize uint32, receivingWindowSize uint32, sendingQueueSize uint32, output *AuthenticationWriter) *KCP {
|
||||
log.Debug("KCP|Core: creating KCP ", conv)
|
||||
kcp := new(KCP)
|
||||
kcp.conv = conv
|
||||
kcp.snd_wnd = sendingWindowSize
|
||||
kcp.rcv_wnd = receivingWindowSize
|
||||
kcp.rmt_wnd = IKCP_WND_RCV
|
||||
kcp.mtu = mtu
|
||||
kcp.mss = kcp.mtu - DataSegmentOverhead
|
||||
kcp.mss = output.Mtu() - DataSegmentOverhead
|
||||
kcp.rx_rto = IKCP_RTO_DEF
|
||||
kcp.interval = IKCP_INTERVAL
|
||||
kcp.output = NewSegmentWriter(mtu, output)
|
||||
kcp.output = NewSegmentWriter(output)
|
||||
kcp.rcv_buf = NewReceivingWindow(receivingWindowSize)
|
||||
kcp.snd_queue = NewSendingQueue(sendingQueueSize)
|
||||
kcp.rcv_queue = NewReceivingQueue()
|
||||
|
@ -15,9 +15,9 @@ type SegmentWriter struct {
|
||||
writer v2io.Writer
|
||||
}
|
||||
|
||||
func NewSegmentWriter(mtu uint32, writer v2io.Writer) *SegmentWriter {
|
||||
func NewSegmentWriter(writer *AuthenticationWriter) *SegmentWriter {
|
||||
return &SegmentWriter{
|
||||
mtu: mtu,
|
||||
mtu: writer.Mtu(),
|
||||
writer: writer,
|
||||
}
|
||||
}
|
||||
@ -68,3 +68,7 @@ func (this *AuthenticationWriter) Write(payload *alloc.Buffer) error {
|
||||
}
|
||||
|
||||
func (this *AuthenticationWriter) Release() {}
|
||||
|
||||
func (this *AuthenticationWriter) Mtu() uint32 {
|
||||
return effectiveConfig.Mtu - uint32(this.Authenticator.HeaderSize())
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user