1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2025-01-17 23:06:30 -05:00

optional field in kcp config

This commit is contained in:
Darien Raymond 2016-09-21 21:08:05 +02:00
parent 1a3f51ade7
commit b28d718b79
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169
7 changed files with 238 additions and 65 deletions

View File

@ -16,9 +16,7 @@ func (this *Config) UnmarshalJSON(data []byte) error {
KCPConfig kcp.Config `json:"kcpSettings"` KCPConfig kcp.Config `json:"kcpSettings"`
WSConfig *ws.Config `json:"wsSettings"` WSConfig *ws.Config `json:"wsSettings"`
} }
jsonConfig := &JsonConfig{ jsonConfig := &JsonConfig{}
KCPConfig: kcp.DefaultConfig(),
}
if err := json.Unmarshal(data, jsonConfig); err != nil { if err := json.Unmarshal(data, jsonConfig); err != nil {
return err return err
} }

View File

@ -4,6 +4,48 @@ import (
"v2ray.com/core/transport/internet" "v2ray.com/core/transport/internet"
) )
func (this *MTU) GetValue() uint32 {
if this == nil {
return 1350
}
return this.Value
}
func (this *TTI) GetValue() uint32 {
if this == nil {
return 50
}
return this.Value
}
func (this *UplinkCapacity) GetValue() uint32 {
if this == nil {
return 5
}
return this.Value
}
func (this *DownlinkCapacity) GetValue() uint32 {
if this == nil {
return 20
}
return this.Value
}
func (this *WriteBuffer) GetSize() uint32 {
if this == nil {
return 1 * 1024 * 1024
}
return this.Size
}
func (this *ReadBuffer) GetSize() uint32 {
if this == nil {
return 1 * 1024 * 1024
}
return this.Size
}
func (this *Config) Apply() { func (this *Config) Apply() {
effectiveConfig = *this effectiveConfig = *this
} }
@ -21,7 +63,7 @@ func (this *Config) GetAuthenticator() (internet.Authenticator, error) {
} }
func (this *Config) GetSendingInFlightSize() uint32 { func (this *Config) GetSendingInFlightSize() uint32 {
size := this.UplinkCapacity * 1024 * 1024 / this.Mtu / (1000 / this.Tti) / 2 size := this.UplinkCapacity.GetValue() * 1024 * 1024 / this.Mtu.GetValue() / (1000 / this.Tti.GetValue()) / 2
if size < 8 { if size < 8 {
size = 8 size = 8
} }
@ -29,11 +71,11 @@ func (this *Config) GetSendingInFlightSize() uint32 {
} }
func (this *Config) GetSendingBufferSize() uint32 { func (this *Config) GetSendingBufferSize() uint32 {
return this.GetSendingInFlightSize() + this.WriteBuffer/this.Mtu return this.GetSendingInFlightSize() + this.WriteBuffer.GetSize()/this.Mtu.GetValue()
} }
func (this *Config) GetReceivingInFlightSize() uint32 { func (this *Config) GetReceivingInFlightSize() uint32 {
size := this.DownlinkCapacity * 1024 * 1024 / this.Mtu / (1000 / this.Tti) / 2 size := this.DownlinkCapacity.GetValue() * 1024 * 1024 / this.Mtu.GetValue() / (1000 / this.Tti.GetValue()) / 2
if size < 8 { if size < 8 {
size = 8 size = 8
} }
@ -41,21 +83,9 @@ func (this *Config) GetReceivingInFlightSize() uint32 {
} }
func (this *Config) GetReceivingBufferSize() uint32 { func (this *Config) GetReceivingBufferSize() uint32 {
return this.GetReceivingInFlightSize() + this.ReadBuffer/this.Mtu return this.GetReceivingInFlightSize() + this.ReadBuffer.GetSize()/this.Mtu.GetValue()
}
func DefaultConfig() Config {
return Config{
Mtu: 1350,
Tti: 50,
UplinkCapacity: 5,
DownlinkCapacity: 20,
Congestion: false,
WriteBuffer: 1 * 1024 * 1024,
ReadBuffer: 1 * 1024 * 1024,
}
} }
var ( var (
effectiveConfig = DefaultConfig() effectiveConfig Config
) )

View File

@ -9,6 +9,12 @@ It is generated from these files:
v2ray.com/core/transport/internet/kcp/config.proto v2ray.com/core/transport/internet/kcp/config.proto
It has these top-level messages: It has these top-level messages:
MTU
TTI
UplinkCapacity
DownlinkCapacity
WriteBuffer
ReadBuffer
Config Config
*/ */
package kcp package kcp
@ -29,21 +35,117 @@ var _ = math.Inf
// proto package needs to be updated. // proto package needs to be updated.
const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package
type MTU struct {
Value uint32 `protobuf:"varint,1,opt,name=value" json:"value,omitempty"`
}
func (m *MTU) Reset() { *m = MTU{} }
func (m *MTU) String() string { return proto.CompactTextString(m) }
func (*MTU) ProtoMessage() {}
func (*MTU) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} }
type TTI struct {
Value uint32 `protobuf:"varint,1,opt,name=value" json:"value,omitempty"`
}
func (m *TTI) Reset() { *m = TTI{} }
func (m *TTI) String() string { return proto.CompactTextString(m) }
func (*TTI) ProtoMessage() {}
func (*TTI) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{1} }
type UplinkCapacity struct {
Value uint32 `protobuf:"varint,1,opt,name=value" json:"value,omitempty"`
}
func (m *UplinkCapacity) Reset() { *m = UplinkCapacity{} }
func (m *UplinkCapacity) String() string { return proto.CompactTextString(m) }
func (*UplinkCapacity) ProtoMessage() {}
func (*UplinkCapacity) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{2} }
type DownlinkCapacity struct {
Value uint32 `protobuf:"varint,1,opt,name=value" json:"value,omitempty"`
}
func (m *DownlinkCapacity) Reset() { *m = DownlinkCapacity{} }
func (m *DownlinkCapacity) String() string { return proto.CompactTextString(m) }
func (*DownlinkCapacity) ProtoMessage() {}
func (*DownlinkCapacity) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{3} }
type WriteBuffer struct {
Size uint32 `protobuf:"varint,1,opt,name=size" json:"size,omitempty"`
}
func (m *WriteBuffer) Reset() { *m = WriteBuffer{} }
func (m *WriteBuffer) String() string { return proto.CompactTextString(m) }
func (*WriteBuffer) ProtoMessage() {}
func (*WriteBuffer) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{4} }
type ReadBuffer struct {
Size uint32 `protobuf:"varint,1,opt,name=size" json:"size,omitempty"`
}
func (m *ReadBuffer) Reset() { *m = ReadBuffer{} }
func (m *ReadBuffer) String() string { return proto.CompactTextString(m) }
func (*ReadBuffer) ProtoMessage() {}
func (*ReadBuffer) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{5} }
type Config struct { type Config struct {
Mtu uint32 `protobuf:"varint,1,opt,name=mtu" json:"mtu,omitempty"` Mtu *MTU `protobuf:"bytes,1,opt,name=mtu" json:"mtu,omitempty"`
Tti uint32 `protobuf:"varint,2,opt,name=tti" json:"tti,omitempty"` Tti *TTI `protobuf:"bytes,2,opt,name=tti" json:"tti,omitempty"`
UplinkCapacity uint32 `protobuf:"varint,3,opt,name=uplink_capacity,json=uplinkCapacity" json:"uplink_capacity,omitempty"` UplinkCapacity *UplinkCapacity `protobuf:"bytes,3,opt,name=uplink_capacity,json=uplinkCapacity" json:"uplink_capacity,omitempty"`
DownlinkCapacity uint32 `protobuf:"varint,4,opt,name=downlink_capacity,json=downlinkCapacity" json:"downlink_capacity,omitempty"` DownlinkCapacity *DownlinkCapacity `protobuf:"bytes,4,opt,name=downlink_capacity,json=downlinkCapacity" json:"downlink_capacity,omitempty"`
Congestion bool `protobuf:"varint,5,opt,name=congestion" json:"congestion,omitempty"` Congestion bool `protobuf:"varint,5,opt,name=congestion" json:"congestion,omitempty"`
WriteBuffer uint32 `protobuf:"varint,6,opt,name=write_buffer,json=writeBuffer" json:"write_buffer,omitempty"` WriteBuffer *WriteBuffer `protobuf:"bytes,6,opt,name=write_buffer,json=writeBuffer" json:"write_buffer,omitempty"`
ReadBuffer uint32 `protobuf:"varint,7,opt,name=read_buffer,json=readBuffer" json:"read_buffer,omitempty"` ReadBuffer *ReadBuffer `protobuf:"bytes,7,opt,name=read_buffer,json=readBuffer" json:"read_buffer,omitempty"`
HeaderConfig *com_v2ray_core_transport_internet.AuthenticatorConfig `protobuf:"bytes,8,opt,name=header_config,json=headerConfig" json:"header_config,omitempty"` HeaderConfig *com_v2ray_core_transport_internet.AuthenticatorConfig `protobuf:"bytes,8,opt,name=header_config,json=headerConfig" json:"header_config,omitempty"`
} }
func (m *Config) Reset() { *m = Config{} } func (m *Config) Reset() { *m = Config{} }
func (m *Config) String() string { return proto.CompactTextString(m) } func (m *Config) String() string { return proto.CompactTextString(m) }
func (*Config) ProtoMessage() {} func (*Config) ProtoMessage() {}
func (*Config) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} } func (*Config) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{6} }
func (m *Config) GetMtu() *MTU {
if m != nil {
return m.Mtu
}
return nil
}
func (m *Config) GetTti() *TTI {
if m != nil {
return m.Tti
}
return nil
}
func (m *Config) GetUplinkCapacity() *UplinkCapacity {
if m != nil {
return m.UplinkCapacity
}
return nil
}
func (m *Config) GetDownlinkCapacity() *DownlinkCapacity {
if m != nil {
return m.DownlinkCapacity
}
return nil
}
func (m *Config) GetWriteBuffer() *WriteBuffer {
if m != nil {
return m.WriteBuffer
}
return nil
}
func (m *Config) GetReadBuffer() *ReadBuffer {
if m != nil {
return m.ReadBuffer
}
return nil
}
func (m *Config) GetHeaderConfig() *com_v2ray_core_transport_internet.AuthenticatorConfig { func (m *Config) GetHeaderConfig() *com_v2ray_core_transport_internet.AuthenticatorConfig {
if m != nil { if m != nil {
@ -53,30 +155,43 @@ func (m *Config) GetHeaderConfig() *com_v2ray_core_transport_internet.Authentica
} }
func init() { func init() {
proto.RegisterType((*MTU)(nil), "com.v2ray.core.transport.internet.kcp.MTU")
proto.RegisterType((*TTI)(nil), "com.v2ray.core.transport.internet.kcp.TTI")
proto.RegisterType((*UplinkCapacity)(nil), "com.v2ray.core.transport.internet.kcp.UplinkCapacity")
proto.RegisterType((*DownlinkCapacity)(nil), "com.v2ray.core.transport.internet.kcp.DownlinkCapacity")
proto.RegisterType((*WriteBuffer)(nil), "com.v2ray.core.transport.internet.kcp.WriteBuffer")
proto.RegisterType((*ReadBuffer)(nil), "com.v2ray.core.transport.internet.kcp.ReadBuffer")
proto.RegisterType((*Config)(nil), "com.v2ray.core.transport.internet.kcp.Config") proto.RegisterType((*Config)(nil), "com.v2ray.core.transport.internet.kcp.Config")
} }
func init() { proto.RegisterFile("v2ray.com/core/transport/internet/kcp/config.proto", fileDescriptor0) } func init() { proto.RegisterFile("v2ray.com/core/transport/internet/kcp/config.proto", fileDescriptor0) }
var fileDescriptor0 = []byte{ var fileDescriptor0 = []byte{
// 290 bytes of a gzipped FileDescriptorProto // 404 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x84, 0x90, 0x41, 0x4f, 0xc2, 0x30, 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x94, 0x93, 0xd1, 0xab, 0xda, 0x30,
0x18, 0x86, 0x33, 0x10, 0x24, 0x05, 0x14, 0x7b, 0x6a, 0x3c, 0x28, 0x9a, 0x18, 0x97, 0x98, 0x74, 0x14, 0xc6, 0x71, 0x55, 0x27, 0xa7, 0xea, 0x5c, 0xd9, 0x43, 0xd9, 0x60, 0x38, 0x61, 0x43, 0xf6,
0xc9, 0x8c, 0xde, 0x85, 0x7f, 0xb0, 0xa3, 0x1e, 0x96, 0xd2, 0x75, 0xd0, 0xcc, 0xb5, 0xcd, 0xc7, 0x90, 0xb2, 0x0e, 0xb7, 0x97, 0xbd, 0x4c, 0xf7, 0xe2, 0x83, 0x2f, 0xa1, 0x65, 0xb0, 0xc1, 0x24,
0x37, 0x09, 0xbf, 0xcf, 0x3f, 0x66, 0xd6, 0x32, 0x82, 0x27, 0x6e, 0xdb, 0xf3, 0x3d, 0xef, 0xdb, 0xa6, 0x51, 0x43, 0x35, 0x29, 0x31, 0x55, 0xdc, 0x9f, 0x7d, 0xff, 0x82, 0x4b, 0x53, 0x7b, 0xad,
0xe4, 0x25, 0xe9, 0x4f, 0x0a, 0x62, 0xcf, 0xa5, 0xad, 0x13, 0x69, 0x41, 0x25, 0x08, 0xc2, 0x6c, 0x82, 0xf7, 0xf6, 0xbe, 0x19, 0x73, 0xbe, 0xdf, 0x49, 0xbf, 0xef, 0x1c, 0xf0, 0xf7, 0xbe, 0x22,
0x9d, 0x05, 0x4c, 0xb4, 0x41, 0x05, 0x46, 0x61, 0x52, 0x49, 0x97, 0x48, 0x6b, 0x4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0x43, 0xbf, 0xe9, 0xeb, 0x5f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x04, 0xdb, 0x8e, 0xc7, 0xe7, 0x01, 0xf4, 0xd2, 0xeb, 0x08, 0x5e, 0x47, 0x27, 0x57, 0xcf, 0x1d, 0xea, 0xa6, 0xc3, 0xf7, 0x8a, 0x1d,
0x00, 0x00, 0xae, 0x53, 0xc1, 0xbd, 0xe8, 0x3a, 0xa7, 0xf7, 0x00, 0x54, 0x8a, 0x15, 0xdb, 0x69, 0x2e, 0x85,
0xdb, 0xe8, 0xd7, 0x86, 0x2d, 0x5c, 0xfa, 0xc7, 0x09, 0xa1, 0x7d, 0xc8, 0x12, 0x9b, 0x2f, 0x4c,
0x20, 0x6e, 0xd3, 0x3c, 0xc0, 0xaf, 0xf8, 0x80, 0x52, 0xd8, 0xd8, 0x3e, 0x94, 0x92, 0xc7, 0x60,
0x2b, 0x46, 0xa2, 0x82, 0xfa, 0xd2, 0x50, 0xbf, 0x54, 0xa4, 0x9e, 0xe7, 0x03, 0x83, 0x3a, 0xcf,
0xca, 0x5f, 0xe8, 0xac, 0x19, 0x89, 0x98, 0x9a, 0xe7, 0xdb, 0xe5, 0xb6, 0x0c, 0xf5, 0x5b, 0x05,
0xea, 0xcf, 0xf2, 0xde, 0xe4, 0xb3, 0x85, 0xdb, 0x39, 0x2c, 0x3f, 0x8d, 0x1b, 0x7f, 0xac, 0x98,
0x26, 0x8b, 0xa6, 0xd9, 0xa9, 0xaf, 0xf7, 0x01, 0x00, 0x00, 0xff, 0xff, 0x29, 0x6b, 0x1b, 0xbd,
0xe7, 0x03, 0x00, 0x00,
} }

View File

@ -5,13 +5,43 @@ option go_package = "kcp";
import "v2ray.com/core/transport/internet/authenticator.proto"; import "v2ray.com/core/transport/internet/authenticator.proto";
// Maximum Transmission Unit, in bytes.
message MTU {
uint32 value = 1;
}
// Transmission Time Interview, in milli-sec.
message TTI {
uint32 value = 1;
}
// Uplink capacity, in MB.
message UplinkCapacity {
uint32 value = 1;
}
// Downlink capacity, in MB.
message DownlinkCapacity {
uint32 value = 1;
}
message WriteBuffer {
// Buffer size in bytes.
uint32 size = 1;
}
message ReadBuffer {
// Buffer size in bytes.
uint32 size = 1;
}
message Config { message Config {
uint32 mtu = 1; MTU mtu = 1;
uint32 tti = 2; TTI tti = 2;
uint32 uplink_capacity = 3; UplinkCapacity uplink_capacity = 3;
uint32 downlink_capacity = 4; DownlinkCapacity downlink_capacity = 4;
bool congestion = 5; bool congestion = 5;
uint32 write_buffer = 6; WriteBuffer write_buffer = 6;
uint32 read_buffer = 7; ReadBuffer read_buffer = 7;
com.v2ray.core.transport.internet.AuthenticatorConfig header_config = 8; com.v2ray.core.transport.internet.AuthenticatorConfig header_config = 8;
} }

View File

@ -31,7 +31,7 @@ func (this *Config) UnmarshalJSON(data []byte) error {
log.Error("KCP|Config: Invalid MTU size: ", mtu) log.Error("KCP|Config: Invalid MTU size: ", mtu)
return common.ErrBadConfiguration return common.ErrBadConfiguration
} }
this.Mtu = mtu this.Mtu = &MTU{Value: *jsonConfig.Mtu}
} }
if jsonConfig.Tti != nil { if jsonConfig.Tti != nil {
tti := *jsonConfig.Tti tti := *jsonConfig.Tti
@ -39,13 +39,13 @@ func (this *Config) UnmarshalJSON(data []byte) error {
log.Error("KCP|Config: Invalid TTI: ", tti) log.Error("KCP|Config: Invalid TTI: ", tti)
return common.ErrBadConfiguration return common.ErrBadConfiguration
} }
this.Tti = tti this.Tti = &TTI{Value: *jsonConfig.Tti}
} }
if jsonConfig.UpCap != nil { if jsonConfig.UpCap != nil {
this.UplinkCapacity = *jsonConfig.UpCap this.UplinkCapacity = &UplinkCapacity{Value: *jsonConfig.UpCap}
} }
if jsonConfig.DownCap != nil { if jsonConfig.DownCap != nil {
this.DownlinkCapacity = *jsonConfig.DownCap this.DownlinkCapacity = &DownlinkCapacity{Value: *jsonConfig.DownCap}
} }
if jsonConfig.Congestion != nil { if jsonConfig.Congestion != nil {
this.Congestion = *jsonConfig.Congestion this.Congestion = *jsonConfig.Congestion
@ -53,17 +53,17 @@ func (this *Config) UnmarshalJSON(data []byte) error {
if jsonConfig.ReadBufferSize != nil { if jsonConfig.ReadBufferSize != nil {
size := *jsonConfig.ReadBufferSize size := *jsonConfig.ReadBufferSize
if size > 0 { if size > 0 {
this.ReadBuffer = size * 1024 * 1024 this.ReadBuffer = &ReadBuffer{Size: size * 1024 * 1024}
} else { } else {
this.ReadBuffer = 512 * 1024 this.ReadBuffer = &ReadBuffer{Size: 512 * 1024}
} }
} }
if jsonConfig.WriteBufferSize != nil { if jsonConfig.WriteBufferSize != nil {
size := *jsonConfig.WriteBufferSize size := *jsonConfig.WriteBufferSize
if size > 0 { if size > 0 {
this.WriteBuffer = size * 1024 * 1024 this.WriteBuffer = &WriteBuffer{Size: size * 1024 * 1024}
} else { } else {
this.WriteBuffer = 512 * 1024 this.WriteBuffer = &WriteBuffer{Size: 512 * 1024}
} }
} }
if len(jsonConfig.HeaderConfig) > 0 { if len(jsonConfig.HeaderConfig) > 0 {

View File

@ -171,9 +171,9 @@ func NewConnection(conv uint16, writerCloser io.WriteCloser, local *net.UDPAddr,
conn.mss = authWriter.Mtu() - DataSegmentOverhead conn.mss = authWriter.Mtu() - DataSegmentOverhead
conn.roundTrip = &RoundTripInfo{ conn.roundTrip = &RoundTripInfo{
rto: 100, rto: 100,
minRtt: effectiveConfig.Tti, minRtt: effectiveConfig.Tti.GetValue(),
} }
conn.interval = effectiveConfig.Tti conn.interval = effectiveConfig.Tti.GetValue()
conn.receivingWorker = NewReceivingWorker(conn) conn.receivingWorker = NewReceivingWorker(conn)
conn.fastresend = 2 conn.fastresend = 2
conn.congestionControl = effectiveConfig.Congestion conn.congestionControl = effectiveConfig.Congestion
@ -366,7 +366,7 @@ func (this *Connection) updateTask() {
for this.State() != StateTerminated { for this.State() != StateTerminated {
this.flush() this.flush()
interval := time.Duration(effectiveConfig.Tti) * time.Millisecond interval := time.Duration(effectiveConfig.Tti.GetValue()) * time.Millisecond
if this.State() == StateTerminating { if this.State() == StateTerminating {
interval = time.Second interval = time.Second
} }

View File

@ -75,5 +75,5 @@ func (this *AuthenticationWriter) Write(payload *alloc.Buffer) error {
func (this *AuthenticationWriter) Release() {} func (this *AuthenticationWriter) Release() {}
func (this *AuthenticationWriter) Mtu() uint32 { func (this *AuthenticationWriter) Mtu() uint32 {
return effectiveConfig.Mtu - uint32(this.Authenticator.Overhead()) return effectiveConfig.Mtu.GetValue() - uint32(this.Authenticator.Overhead())
} }