forked from v2fly/v2ray-core
-
Notifications
You must be signed in to change notification settings - Fork 1
/
config.go
37 lines (31 loc) · 788 Bytes
/
config.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package kcp
type Config struct {
Mtu uint32 // Maximum transmission unit
Tti uint32
UplinkCapacity uint32
DownlinkCapacity uint32
Congestion bool
WriteBuffer uint32
}
func (this *Config) Apply() {
effectiveConfig = *this
}
func (this *Config) GetSendingWindowSize() uint32 {
return this.UplinkCapacity * 1024 * 1024 / this.Mtu / (1000 / this.Tti)
}
func (this *Config) GetReceivingWindowSize() uint32 {
return this.DownlinkCapacity * 1024 * 1024 / this.Mtu / (1000 / this.Tti)
}
func DefaultConfig() Config {
return Config{
Mtu: 1350,
Tti: 20,
UplinkCapacity: 5,
DownlinkCapacity: 20,
Congestion: false,
WriteBuffer: 8 * 1024 * 1024,
}
}
var (
effectiveConfig = DefaultConfig()
)