From 0da987ec432f930b88913e0087738864f437bfcc Mon Sep 17 00:00:00 2001 From: Darien Raymond Date: Thu, 25 Aug 2016 00:04:54 +0200 Subject: [PATCH] refine buffer size --- transport/internet/kcp/config.go | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/transport/internet/kcp/config.go b/transport/internet/kcp/config.go index 7f82c932..ce501477 100644 --- a/transport/internet/kcp/config.go +++ b/transport/internet/kcp/config.go @@ -41,33 +41,18 @@ func (this *Config) GetSendingInFlightSize() uint32 { } func (this *Config) GetSendingBufferSize() uint32 { - size := this.WriteBuffer / this.Mtu - if size < this.GetSendingInFlightSize() { - size = this.GetSendingInFlightSize() - } - return size + return this.GetSendingInFlightSize() + this.WriteBuffer/this.Mtu } -func (this *Config) GetReceivingWindowSize() uint32 { +func (this *Config) GetReceivingBufferSize() uint32 { size := this.DownlinkCapacity * 1024 * 1024 / this.Mtu / (1000 / this.Tti) / 2 if size < 8 { size = 8 } + size += this.ReadBuffer / this.Mtu return size } -func (this *Config) GetReceivingBufferSize() uint32 { - bufferSize := this.ReadBuffer / this.Mtu - windowSize := this.DownlinkCapacity * 1024 * 1024 / this.Mtu / (1000 / this.Tti) / 2 - if windowSize < 8 { - windowSize = 8 - } - if bufferSize < windowSize { - bufferSize = windowSize - } - return bufferSize -} - func DefaultConfig() Config { return Config{ Mtu: 1350,