mirror of https://github.com/v2ray/v2ray-core
adjust receiving buffer size
parent
0da987ec43
commit
fcad4aa212
|
@ -44,15 +44,18 @@ func (this *Config) GetSendingBufferSize() uint32 {
|
||||||
return this.GetSendingInFlightSize() + this.WriteBuffer/this.Mtu
|
return this.GetSendingInFlightSize() + this.WriteBuffer/this.Mtu
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *Config) GetReceivingBufferSize() uint32 {
|
func (this *Config) GetReceivingInFlightSize() uint32 {
|
||||||
size := this.DownlinkCapacity * 1024 * 1024 / this.Mtu / (1000 / this.Tti) / 2
|
size := this.DownlinkCapacity * 1024 * 1024 / this.Mtu / (1000 / this.Tti) / 2
|
||||||
if size < 8 {
|
if size < 8 {
|
||||||
size = 8
|
size = 8
|
||||||
}
|
}
|
||||||
size += this.ReadBuffer / this.Mtu
|
|
||||||
return size
|
return size
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (this *Config) GetReceivingBufferSize() uint32 {
|
||||||
|
return this.GetReceivingInFlightSize() + this.ReadBuffer/this.Mtu
|
||||||
|
}
|
||||||
|
|
||||||
func DefaultConfig() Config {
|
func DefaultConfig() Config {
|
||||||
return Config{
|
return Config{
|
||||||
Mtu: 1350,
|
Mtu: 1350,
|
||||||
|
|
|
@ -123,11 +123,10 @@ type ReceivingWorker struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewReceivingWorker(kcp *Connection) *ReceivingWorker {
|
func NewReceivingWorker(kcp *Connection) *ReceivingWorker {
|
||||||
windowSize := effectiveConfig.GetReceivingBufferSize()
|
|
||||||
worker := &ReceivingWorker{
|
worker := &ReceivingWorker{
|
||||||
conn: kcp,
|
conn: kcp,
|
||||||
window: NewReceivingWindow(windowSize),
|
window: NewReceivingWindow(effectiveConfig.GetReceivingBufferSize()),
|
||||||
windowSize: windowSize,
|
windowSize: effectiveConfig.GetReceivingInFlightSize(),
|
||||||
}
|
}
|
||||||
worker.acklist = NewAckList(worker)
|
worker.acklist = NewAckList(worker)
|
||||||
return worker
|
return worker
|
||||||
|
@ -155,6 +154,7 @@ func (this *ReceivingWorker) ProcessSegment(seg *DataSegment) {
|
||||||
if !this.window.Set(idx, seg) {
|
if !this.window.Set(idx, seg) {
|
||||||
seg.Release()
|
seg.Release()
|
||||||
}
|
}
|
||||||
|
this.updated = true
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *ReceivingWorker) Read(b []byte) int {
|
func (this *ReceivingWorker) Read(b []byte) int {
|
||||||
|
|
Loading…
Reference in New Issue