v2ray-core/transport/internet/kcp/config.go

38 lines
767 B
Go
Raw Normal View History

2016-06-14 20:54:08 +00:00
package kcp
2016-06-11 09:30:38 +00:00
type Config struct {
2016-06-20 14:10:47 +00:00
Mtu int // Maximum transmission unit
Tti int
UplinkCapacity int
DownlinkCapacity int
Congestion bool
2016-06-23 20:37:48 +00:00
WriteBuffer int
2016-06-11 09:30:38 +00:00
}
2016-06-14 20:54:08 +00:00
func (this *Config) Apply() {
effectiveConfig = *this
2016-06-11 09:30:38 +00:00
}
2016-06-14 20:54:08 +00:00
2016-06-20 14:10:47 +00:00
func (this *Config) GetSendingWindowSize() int {
return this.UplinkCapacity * 1024 * 1024 / this.Mtu / (1000 / this.Tti)
}
func (this *Config) GetReceivingWindowSize() int {
return this.DownlinkCapacity * 1024 * 1024 / this.Mtu / (1000 / this.Tti)
}
2016-06-17 14:57:48 +00:00
func DefaultConfig() Config {
return Config{
2016-06-20 14:10:47 +00:00
Mtu: 1350,
Tti: 20,
UplinkCapacity: 5,
DownlinkCapacity: 20,
Congestion: false,
2016-06-23 20:37:48 +00:00
WriteBuffer: 8 * 1024 * 1024,
2016-06-14 20:54:08 +00:00
}
2016-06-17 14:57:48 +00:00
}
var (
effectiveConfig = DefaultConfig()
2016-06-14 20:54:08 +00:00
)