Documentation ¶
Overview ¶
Package kcp - A Fast and Reliable ARQ Protocol
Acknowledgement:
skywind3000@github for inventing the KCP protocol xtaci@github for translating to Golang
Index ¶
- Constants
- Variables
- func DialKCP(ctx context.Context, dest net.Destination, ...) (stat.Connection, error)
- func ListenKCP(ctx context.Context, address net.Address, port net.Port, ...) (internet.Listener, error)
- func NewAEADAESGCMBasedOnSeed(seed string) cipher.AEAD
- func NewSimpleAuthenticator() cipher.AEAD
- type AckList
- type AckSegment
- func (s *AckSegment) ByteSize() int32
- func (*AckSegment) Command() Command
- func (s *AckSegment) Conversation() uint16
- func (s *AckSegment) IsEmpty() bool
- func (s *AckSegment) IsFull() bool
- func (s *AckSegment) PutNumber(number uint32)
- func (s *AckSegment) PutTimestamp(timestamp uint32)
- func (s *AckSegment) Release()
- func (s *AckSegment) Serialize(b []byte)
- type CmdOnlySegment
- type Command
- type Config
- func (*Config) Descriptor() ([]byte, []int)deprecated
- func (x *Config) GetCongestion() bool
- func (x *Config) GetDownlinkCapacity() *DownlinkCapacity
- func (c *Config) GetDownlinkCapacityValue() uint32
- func (x *Config) GetHeaderConfig() *serial.TypedMessage
- func (c *Config) GetMTUValue() uint32
- func (x *Config) GetMtu() *MTU
- func (c *Config) GetPackerHeader() (internet.PacketHeader, error)
- func (x *Config) GetReadBuffer() *ReadBuffer
- func (c *Config) GetReadBufferSize() uint32
- func (c *Config) GetReceivingBufferSize() uint32
- func (c *Config) GetReceivingInFlightSize() uint32
- func (c *Config) GetSecurity() (cipher.AEAD, error)
- func (x *Config) GetSeed() *EncryptionSeed
- func (c *Config) GetSendingBufferSize() uint32
- func (c *Config) GetSendingInFlightSize() uint32
- func (c *Config) GetTTIValue() uint32
- func (x *Config) GetTti() *TTI
- func (x *Config) GetUplinkCapacity() *UplinkCapacity
- func (c *Config) GetUplinkCapacityValue() uint32
- func (x *Config) GetWriteBuffer() *WriteBuffer
- func (c *Config) GetWriteBufferSize() uint32
- func (*Config) ProtoMessage()
- func (x *Config) ProtoReflect() protoreflect.Message
- func (x *Config) Reset()
- func (x *Config) String() string
- type ConnMetadata
- type Connection
- func (c *Connection) Close() error
- func (c *Connection) Elapsed() uint32
- func (c *Connection) HandleOption(opt SegmentOption)
- func (c *Connection) Input(segments []Segment)
- func (c *Connection) LocalAddr() net.Addr
- func (c *Connection) OnPeerClosed()
- func (c *Connection) Ping(current uint32, cmd Command)
- func (c *Connection) Read(b []byte) (int, error)
- func (c *Connection) ReadMultiBuffer() (buf.MultiBuffer, error)
- func (c *Connection) RemoteAddr() net.Addr
- func (c *Connection) SetDeadline(t time.Time) error
- func (c *Connection) SetReadDeadline(t time.Time) error
- func (c *Connection) SetState(state State)
- func (c *Connection) SetWriteDeadline(t time.Time) error
- func (c *Connection) State() State
- func (c *Connection) Terminate()
- func (c *Connection) Write(b []byte) (int, error)
- func (c *Connection) WriteMultiBuffer(mb buf.MultiBuffer) error
- type ConnectionID
- type ConnectionReuse
- type DataSegment
- type DownlinkCapacity
- type EncryptionSeed
- type KCPPacketReader
- type KCPPacketWriter
- type Listener
- type MTU
- type PacketReader
- type PacketWriter
- type ReadBuffer
- type ReceivingWindow
- type ReceivingWorker
- func (*ReceivingWorker) CloseRead()
- func (w *ReceivingWorker) Flush(current uint32)
- func (w *ReceivingWorker) IsDataAvailable() bool
- func (w *ReceivingWorker) NextNumber() uint32
- func (w *ReceivingWorker) ProcessSegment(seg *DataSegment)
- func (w *ReceivingWorker) ProcessSendingNext(number uint32)
- func (w *ReceivingWorker) Read(b []byte) int
- func (w *ReceivingWorker) ReadMultiBuffer() buf.MultiBuffer
- func (w *ReceivingWorker) Release()
- func (w *ReceivingWorker) UpdateNecessary() bool
- func (w *ReceivingWorker) Write(seg Segment) error
- type RetryableWriter
- type RoundTripInfo
- type Segment
- type SegmentOption
- type SegmentWriter
- type SendingWindow
- func (sw *SendingWindow) Clear(una uint32)
- func (sw *SendingWindow) FirstNumber() uint32
- func (sw *SendingWindow) Flush(current uint32, rto uint32, maxInFlightSize uint32)
- func (sw *SendingWindow) HandleFastAck(number uint32, rto uint32)
- func (sw *SendingWindow) IsEmpty() bool
- func (sw *SendingWindow) Len() uint32
- func (sw *SendingWindow) Push(number uint32, b *buf.Buffer)
- func (sw *SendingWindow) Release()
- func (sw *SendingWindow) Remove(number uint32) bool
- func (sw *SendingWindow) Visit(visitor func(seg *DataSegment) bool)
- type SendingWorker
- func (w *SendingWorker) CloseWrite()
- func (w *SendingWorker) FindFirstUnacknowledged()
- func (w *SendingWorker) FirstUnacknowledged() uint32
- func (w *SendingWorker) Flush(current uint32)
- func (w *SendingWorker) IsEmpty() bool
- func (w *SendingWorker) OnPacketLoss(lossRate uint32)
- func (w *SendingWorker) ProcessReceivingNext(nextNumber uint32)
- func (w *SendingWorker) ProcessReceivingNextWithoutLock(nextNumber uint32)
- func (w *SendingWorker) ProcessSegment(current uint32, seg *AckSegment, rto uint32)
- func (w *SendingWorker) Push(b *buf.Buffer) bool
- func (w *SendingWorker) Release()
- func (w *SendingWorker) UpdateNecessary() bool
- func (w *SendingWorker) Write(seg Segment) error
- type SimpleAuthenticator
- type SimpleSegmentWriter
- type State
- type TTI
- type Updater
- type UplinkCapacity
- type WriteBuffer
- type Writer
Constants ¶
const (
DataSegmentOverhead = 18
)
Variables ¶
var ( ErrIOTimeout = errors.New("Read/Write timeout") ErrClosedListener = errors.New("Listener closed.") ErrClosedConnection = errors.New("Connection closed.") )
var File_transport_internet_kcp_config_proto protoreflect.FileDescriptor
Functions ¶
func DialKCP ¶
func DialKCP(ctx context.Context, dest net.Destination, streamSettings *internet.MemoryStreamConfig) (stat.Connection, error)
DialKCP dials a new KCP connections to the specific destination.
func NewSimpleAuthenticator ¶
NewSimpleAuthenticator creates a new SimpleAuthenticator
Types ¶
type AckList ¶
type AckList struct {
// contains filtered or unexported fields
}
func NewAckList ¶
func NewAckList(writer SegmentWriter) *AckList
type AckSegment ¶
type AckSegment struct { Conv uint16 Option SegmentOption ReceivingWindow uint32 ReceivingNext uint32 Timestamp uint32 NumberList []uint32 }
func NewAckSegment ¶
func NewAckSegment() *AckSegment
func (*AckSegment) ByteSize ¶
func (s *AckSegment) ByteSize() int32
func (*AckSegment) Command ¶
func (*AckSegment) Command() Command
func (*AckSegment) Conversation ¶
func (s *AckSegment) Conversation() uint16
func (*AckSegment) IsEmpty ¶
func (s *AckSegment) IsEmpty() bool
func (*AckSegment) IsFull ¶
func (s *AckSegment) IsFull() bool
func (*AckSegment) PutNumber ¶
func (s *AckSegment) PutNumber(number uint32)
func (*AckSegment) PutTimestamp ¶
func (s *AckSegment) PutTimestamp(timestamp uint32)
func (*AckSegment) Release ¶
func (s *AckSegment) Release()
func (*AckSegment) Serialize ¶
func (s *AckSegment) Serialize(b []byte)
type CmdOnlySegment ¶
type CmdOnlySegment struct { Conv uint16 Cmd Command Option SegmentOption SendingNext uint32 ReceivingNext uint32 PeerRTO uint32 }
func NewCmdOnlySegment ¶
func NewCmdOnlySegment() *CmdOnlySegment
func (*CmdOnlySegment) ByteSize ¶
func (*CmdOnlySegment) ByteSize() int32
func (*CmdOnlySegment) Command ¶
func (s *CmdOnlySegment) Command() Command
func (*CmdOnlySegment) Conversation ¶
func (s *CmdOnlySegment) Conversation() uint16
func (*CmdOnlySegment) Release ¶
func (*CmdOnlySegment) Release()
func (*CmdOnlySegment) Serialize ¶
func (s *CmdOnlySegment) Serialize(b []byte)
type Config ¶
type Config struct { Mtu *MTU `protobuf:"bytes,1,opt,name=mtu,proto3" json:"mtu,omitempty"` Tti *TTI `protobuf:"bytes,2,opt,name=tti,proto3" json:"tti,omitempty"` UplinkCapacity *UplinkCapacity `protobuf:"bytes,3,opt,name=uplink_capacity,json=uplinkCapacity,proto3" json:"uplink_capacity,omitempty"` DownlinkCapacity *DownlinkCapacity `protobuf:"bytes,4,opt,name=downlink_capacity,json=downlinkCapacity,proto3" json:"downlink_capacity,omitempty"` Congestion bool `protobuf:"varint,5,opt,name=congestion,proto3" json:"congestion,omitempty"` WriteBuffer *WriteBuffer `protobuf:"bytes,6,opt,name=write_buffer,json=writeBuffer,proto3" json:"write_buffer,omitempty"` ReadBuffer *ReadBuffer `protobuf:"bytes,7,opt,name=read_buffer,json=readBuffer,proto3" json:"read_buffer,omitempty"` HeaderConfig *serial.TypedMessage `protobuf:"bytes,8,opt,name=header_config,json=headerConfig,proto3" json:"header_config,omitempty"` Seed *EncryptionSeed `protobuf:"bytes,10,opt,name=seed,proto3" json:"seed,omitempty"` // contains filtered or unexported fields }
func (*Config) Descriptor
deprecated
func (*Config) GetCongestion ¶
func (*Config) GetDownlinkCapacity ¶
func (x *Config) GetDownlinkCapacity() *DownlinkCapacity
func (*Config) GetDownlinkCapacityValue ¶
GetDownlinkCapacityValue returns the value of DownlinkCapacity settings.
func (*Config) GetHeaderConfig ¶
func (x *Config) GetHeaderConfig() *serial.TypedMessage
func (*Config) GetMTUValue ¶
GetMTUValue returns the value of MTU settings.
func (*Config) GetPackerHeader ¶
func (c *Config) GetPackerHeader() (internet.PacketHeader, error)
func (*Config) GetReadBuffer ¶
func (x *Config) GetReadBuffer() *ReadBuffer
func (*Config) GetReadBufferSize ¶
GetReadBufferSize returns the size of ReadBuffer in bytes.
func (*Config) GetReceivingBufferSize ¶
func (*Config) GetReceivingInFlightSize ¶
func (*Config) GetSecurity ¶
GetSecurity returns the security settings.
func (*Config) GetSeed ¶
func (x *Config) GetSeed() *EncryptionSeed
func (*Config) GetSendingBufferSize ¶
func (*Config) GetSendingInFlightSize ¶
func (*Config) GetTTIValue ¶
GetTTIValue returns the value of TTI settings.
func (*Config) GetUplinkCapacity ¶
func (x *Config) GetUplinkCapacity() *UplinkCapacity
func (*Config) GetUplinkCapacityValue ¶
GetUplinkCapacityValue returns the value of UplinkCapacity settings.
func (*Config) GetWriteBuffer ¶
func (x *Config) GetWriteBuffer() *WriteBuffer
func (*Config) GetWriteBufferSize ¶
GetWriteBufferSize returns the size of WriterBuffer in bytes.
func (*Config) ProtoMessage ¶
func (*Config) ProtoMessage()
func (*Config) ProtoReflect ¶
func (x *Config) ProtoReflect() protoreflect.Message
type ConnMetadata ¶
type Connection ¶
type Connection struct { Config *Config // contains filtered or unexported fields }
Connection is a KCP connection over UDP.
func NewConnection ¶
func NewConnection(meta ConnMetadata, writer PacketWriter, closer io.Closer, config *Config) *Connection
NewConnection create a new KCP connection between local and remote.
func (*Connection) Elapsed ¶
func (c *Connection) Elapsed() uint32
func (*Connection) HandleOption ¶
func (c *Connection) HandleOption(opt SegmentOption)
func (*Connection) Input ¶
func (c *Connection) Input(segments []Segment)
Input when you received a low level packet (eg. UDP packet), call it
func (*Connection) LocalAddr ¶
func (c *Connection) LocalAddr() net.Addr
LocalAddr returns the local network address. The Addr returned is shared by all invocations of LocalAddr, so do not modify it.
func (*Connection) OnPeerClosed ¶
func (c *Connection) OnPeerClosed()
func (*Connection) Ping ¶
func (c *Connection) Ping(current uint32, cmd Command)
func (*Connection) Read ¶
func (c *Connection) Read(b []byte) (int, error)
Read implements the Conn Read method.
func (*Connection) ReadMultiBuffer ¶
func (c *Connection) ReadMultiBuffer() (buf.MultiBuffer, error)
ReadMultiBuffer implements buf.Reader.
func (*Connection) RemoteAddr ¶
func (c *Connection) RemoteAddr() net.Addr
RemoteAddr returns the remote network address. The Addr returned is shared by all invocations of RemoteAddr, so do not modify it.
func (*Connection) SetDeadline ¶
func (c *Connection) SetDeadline(t time.Time) error
SetDeadline sets the deadline associated with the listener. A zero time value disables the deadline.
func (*Connection) SetReadDeadline ¶
func (c *Connection) SetReadDeadline(t time.Time) error
SetReadDeadline implements the Conn SetReadDeadline method.
func (*Connection) SetState ¶
func (c *Connection) SetState(state State)
func (*Connection) SetWriteDeadline ¶
func (c *Connection) SetWriteDeadline(t time.Time) error
SetWriteDeadline implements the Conn SetWriteDeadline method.
func (*Connection) State ¶
func (c *Connection) State() State
func (*Connection) Terminate ¶
func (c *Connection) Terminate()
func (*Connection) Write ¶
func (c *Connection) Write(b []byte) (int, error)
Write implements io.Writer.
func (*Connection) WriteMultiBuffer ¶
func (c *Connection) WriteMultiBuffer(mb buf.MultiBuffer) error
WriteMultiBuffer implements buf.Writer.
type ConnectionReuse ¶
type ConnectionReuse struct { Enable bool `protobuf:"varint,1,opt,name=enable,proto3" json:"enable,omitempty"` // contains filtered or unexported fields }
func (*ConnectionReuse) Descriptor
deprecated
func (*ConnectionReuse) Descriptor() ([]byte, []int)
Deprecated: Use ConnectionReuse.ProtoReflect.Descriptor instead.
func (*ConnectionReuse) GetEnable ¶
func (x *ConnectionReuse) GetEnable() bool
func (*ConnectionReuse) ProtoMessage ¶
func (*ConnectionReuse) ProtoMessage()
func (*ConnectionReuse) ProtoReflect ¶
func (x *ConnectionReuse) ProtoReflect() protoreflect.Message
func (*ConnectionReuse) Reset ¶
func (x *ConnectionReuse) Reset()
func (*ConnectionReuse) String ¶
func (x *ConnectionReuse) String() string
type DataSegment ¶
type DataSegment struct { Conv uint16 Option SegmentOption Timestamp uint32 Number uint32 SendingNext uint32 // contains filtered or unexported fields }
func NewDataSegment ¶
func NewDataSegment() *DataSegment
func (*DataSegment) ByteSize ¶
func (s *DataSegment) ByteSize() int32
func (*DataSegment) Command ¶
func (*DataSegment) Command() Command
func (*DataSegment) Conversation ¶
func (s *DataSegment) Conversation() uint16
func (*DataSegment) Data ¶
func (s *DataSegment) Data() *buf.Buffer
func (*DataSegment) Detach ¶
func (s *DataSegment) Detach() *buf.Buffer
func (*DataSegment) Release ¶
func (s *DataSegment) Release()
func (*DataSegment) Serialize ¶
func (s *DataSegment) Serialize(b []byte)
type DownlinkCapacity ¶
type DownlinkCapacity struct { Value uint32 `protobuf:"varint,1,opt,name=value,proto3" json:"value,omitempty"` // contains filtered or unexported fields }
Downlink capacity, in MB.
func (*DownlinkCapacity) Descriptor
deprecated
func (*DownlinkCapacity) Descriptor() ([]byte, []int)
Deprecated: Use DownlinkCapacity.ProtoReflect.Descriptor instead.
func (*DownlinkCapacity) GetValue ¶
func (x *DownlinkCapacity) GetValue() uint32
func (*DownlinkCapacity) ProtoMessage ¶
func (*DownlinkCapacity) ProtoMessage()
func (*DownlinkCapacity) ProtoReflect ¶
func (x *DownlinkCapacity) ProtoReflect() protoreflect.Message
func (*DownlinkCapacity) Reset ¶
func (x *DownlinkCapacity) Reset()
func (*DownlinkCapacity) String ¶
func (x *DownlinkCapacity) String() string
type EncryptionSeed ¶
type EncryptionSeed struct { Seed string `protobuf:"bytes,1,opt,name=seed,proto3" json:"seed,omitempty"` // contains filtered or unexported fields }
Pre-shared secret between client and server. It is used for traffic obfuscation. Note that if seed is absent in the config, the traffic will still be obfuscated, but by a predefined algorithm.
func (*EncryptionSeed) Descriptor
deprecated
func (*EncryptionSeed) Descriptor() ([]byte, []int)
Deprecated: Use EncryptionSeed.ProtoReflect.Descriptor instead.
func (*EncryptionSeed) GetSeed ¶
func (x *EncryptionSeed) GetSeed() string
func (*EncryptionSeed) ProtoMessage ¶
func (*EncryptionSeed) ProtoMessage()
func (*EncryptionSeed) ProtoReflect ¶
func (x *EncryptionSeed) ProtoReflect() protoreflect.Message
func (*EncryptionSeed) Reset ¶
func (x *EncryptionSeed) Reset()
func (*EncryptionSeed) String ¶
func (x *EncryptionSeed) String() string
type KCPPacketReader ¶
type KCPPacketReader struct { Security cipher.AEAD Header internet.PacketHeader }
func (*KCPPacketReader) Read ¶
func (r *KCPPacketReader) Read(b []byte) []Segment
type KCPPacketWriter ¶
func (*KCPPacketWriter) Overhead ¶
func (w *KCPPacketWriter) Overhead() int
type Listener ¶
Listener defines a server listening for connections
func NewListener ¶
func (*Listener) ActiveConnections ¶
func (*Listener) Addr ¶
Addr returns the listener's network address, The Addr returned is shared by all invocations of Addr, so do not modify it.
func (*Listener) Close ¶
Close stops listening on the UDP address. Already Accepted connections are not closed.
func (*Listener) Remove ¶
func (l *Listener) Remove(id ConnectionID)
type MTU ¶
type MTU struct { Value uint32 `protobuf:"varint,1,opt,name=value,proto3" json:"value,omitempty"` // contains filtered or unexported fields }
Maximum Transmission Unit, in bytes.
func (*MTU) Descriptor
deprecated
func (*MTU) ProtoMessage ¶
func (*MTU) ProtoMessage()
func (*MTU) ProtoReflect ¶
func (x *MTU) ProtoReflect() protoreflect.Message
type PacketReader ¶
type PacketWriter ¶
type ReadBuffer ¶
type ReadBuffer struct { // Buffer size in bytes. Size uint32 `protobuf:"varint,1,opt,name=size,proto3" json:"size,omitempty"` // contains filtered or unexported fields }
func (*ReadBuffer) Descriptor
deprecated
func (*ReadBuffer) Descriptor() ([]byte, []int)
Deprecated: Use ReadBuffer.ProtoReflect.Descriptor instead.
func (*ReadBuffer) GetSize ¶
func (x *ReadBuffer) GetSize() uint32
func (*ReadBuffer) ProtoMessage ¶
func (*ReadBuffer) ProtoMessage()
func (*ReadBuffer) ProtoReflect ¶
func (x *ReadBuffer) ProtoReflect() protoreflect.Message
func (*ReadBuffer) Reset ¶
func (x *ReadBuffer) Reset()
func (*ReadBuffer) String ¶
func (x *ReadBuffer) String() string
type ReceivingWindow ¶
type ReceivingWindow struct {
// contains filtered or unexported fields
}
func NewReceivingWindow ¶
func NewReceivingWindow() *ReceivingWindow
func (*ReceivingWindow) Has ¶
func (w *ReceivingWindow) Has(id uint32) bool
func (*ReceivingWindow) Remove ¶
func (w *ReceivingWindow) Remove(id uint32) *DataSegment
func (*ReceivingWindow) Set ¶
func (w *ReceivingWindow) Set(id uint32, value *DataSegment) bool
type ReceivingWorker ¶
func NewReceivingWorker ¶
func NewReceivingWorker(kcp *Connection) *ReceivingWorker
func (*ReceivingWorker) CloseRead ¶
func (*ReceivingWorker) CloseRead()
func (*ReceivingWorker) Flush ¶
func (w *ReceivingWorker) Flush(current uint32)
func (*ReceivingWorker) IsDataAvailable ¶
func (w *ReceivingWorker) IsDataAvailable() bool
func (*ReceivingWorker) NextNumber ¶
func (w *ReceivingWorker) NextNumber() uint32
func (*ReceivingWorker) ProcessSegment ¶
func (w *ReceivingWorker) ProcessSegment(seg *DataSegment)
func (*ReceivingWorker) ProcessSendingNext ¶
func (w *ReceivingWorker) ProcessSendingNext(number uint32)
func (*ReceivingWorker) Read ¶
func (w *ReceivingWorker) Read(b []byte) int
func (*ReceivingWorker) ReadMultiBuffer ¶
func (w *ReceivingWorker) ReadMultiBuffer() buf.MultiBuffer
func (*ReceivingWorker) Release ¶
func (w *ReceivingWorker) Release()
func (*ReceivingWorker) UpdateNecessary ¶
func (w *ReceivingWorker) UpdateNecessary() bool
func (*ReceivingWorker) Write ¶
func (w *ReceivingWorker) Write(seg Segment) error
type RetryableWriter ¶
type RetryableWriter struct {
// contains filtered or unexported fields
}
func (*RetryableWriter) Write ¶
func (w *RetryableWriter) Write(seg Segment) error
type RoundTripInfo ¶
func (*RoundTripInfo) SmoothedTime ¶
func (info *RoundTripInfo) SmoothedTime() uint32
func (*RoundTripInfo) Timeout ¶
func (info *RoundTripInfo) Timeout() uint32
func (*RoundTripInfo) Update ¶
func (info *RoundTripInfo) Update(rtt uint32, current uint32)
func (*RoundTripInfo) UpdatePeerRTO ¶
func (info *RoundTripInfo) UpdatePeerRTO(rto uint32, current uint32)
type Segment ¶
type Segment interface { Release() Conversation() uint16 Command() Command ByteSize() int32 Serialize([]byte) // contains filtered or unexported methods }
func ReadSegment ¶
type SegmentWriter ¶
func NewRetryableWriter ¶
func NewRetryableWriter(writer SegmentWriter) SegmentWriter
func NewSegmentWriter ¶
func NewSegmentWriter(writer io.Writer) SegmentWriter
type SendingWindow ¶
type SendingWindow struct {
// contains filtered or unexported fields
}
func NewSendingWindow ¶
func NewSendingWindow(writer SegmentWriter, onPacketLoss func(uint32)) *SendingWindow
func (*SendingWindow) Clear ¶
func (sw *SendingWindow) Clear(una uint32)
func (*SendingWindow) FirstNumber ¶
func (sw *SendingWindow) FirstNumber() uint32
func (*SendingWindow) Flush ¶
func (sw *SendingWindow) Flush(current uint32, rto uint32, maxInFlightSize uint32)
func (*SendingWindow) HandleFastAck ¶
func (sw *SendingWindow) HandleFastAck(number uint32, rto uint32)
func (*SendingWindow) IsEmpty ¶
func (sw *SendingWindow) IsEmpty() bool
func (*SendingWindow) Len ¶
func (sw *SendingWindow) Len() uint32
func (*SendingWindow) Release ¶
func (sw *SendingWindow) Release()
func (*SendingWindow) Remove ¶
func (sw *SendingWindow) Remove(number uint32) bool
func (*SendingWindow) Visit ¶
func (sw *SendingWindow) Visit(visitor func(seg *DataSegment) bool)
type SendingWorker ¶
func NewSendingWorker ¶
func NewSendingWorker(kcp *Connection) *SendingWorker
func (*SendingWorker) CloseWrite ¶
func (w *SendingWorker) CloseWrite()
func (*SendingWorker) FindFirstUnacknowledged ¶
func (w *SendingWorker) FindFirstUnacknowledged()
func (*SendingWorker) FirstUnacknowledged ¶
func (w *SendingWorker) FirstUnacknowledged() uint32
func (*SendingWorker) Flush ¶
func (w *SendingWorker) Flush(current uint32)
func (*SendingWorker) IsEmpty ¶
func (w *SendingWorker) IsEmpty() bool
func (*SendingWorker) OnPacketLoss ¶
func (w *SendingWorker) OnPacketLoss(lossRate uint32)
func (*SendingWorker) ProcessReceivingNext ¶
func (w *SendingWorker) ProcessReceivingNext(nextNumber uint32)
func (*SendingWorker) ProcessReceivingNextWithoutLock ¶
func (w *SendingWorker) ProcessReceivingNextWithoutLock(nextNumber uint32)
func (*SendingWorker) ProcessSegment ¶
func (w *SendingWorker) ProcessSegment(current uint32, seg *AckSegment, rto uint32)
func (*SendingWorker) Release ¶
func (w *SendingWorker) Release()
func (*SendingWorker) UpdateNecessary ¶
func (w *SendingWorker) UpdateNecessary() bool
func (*SendingWorker) Write ¶
func (w *SendingWorker) Write(seg Segment) error
type SimpleAuthenticator ¶
type SimpleAuthenticator struct{}
SimpleAuthenticator is a legacy AEAD used for KCP encryption.
func (*SimpleAuthenticator) NonceSize ¶
func (*SimpleAuthenticator) NonceSize() int
NonceSize implements cipher.AEAD.NonceSize().
func (*SimpleAuthenticator) Open ¶
func (a *SimpleAuthenticator) Open(dst, nonce, cipherText, extra []byte) ([]byte, error)
Open implements cipher.AEAD.Open().
func (*SimpleAuthenticator) Overhead ¶
func (*SimpleAuthenticator) Overhead() int
Overhead implements cipher.AEAD.NonceSize().
func (*SimpleAuthenticator) Seal ¶
func (a *SimpleAuthenticator) Seal(dst, nonce, plain, extra []byte) []byte
Seal implements cipher.AEAD.Seal().
type SimpleSegmentWriter ¶
func (*SimpleSegmentWriter) Write ¶
func (w *SimpleSegmentWriter) Write(seg Segment) error
type State ¶
type State int32
State of the connection
const ( StateActive State = 0 // Connection is active StateReadyToClose State = 1 // Connection is closed locally StatePeerClosed State = 2 // Connection is closed on remote StateTerminating State = 3 // Connection is ready to be destroyed locally StatePeerTerminating State = 4 // Connection is ready to be destroyed on remote StateTerminated State = 5 // Connection is destroyed. )
type TTI ¶
type TTI struct { Value uint32 `protobuf:"varint,1,opt,name=value,proto3" json:"value,omitempty"` // contains filtered or unexported fields }
Transmission Time Interview, in milli-sec.
func (*TTI) Descriptor
deprecated
func (*TTI) ProtoMessage ¶
func (*TTI) ProtoMessage()
func (*TTI) ProtoReflect ¶
func (x *TTI) ProtoReflect() protoreflect.Message
type Updater ¶
type Updater struct {
// contains filtered or unexported fields
}
func NewUpdater ¶
func (*Updater) SetInterval ¶
type UplinkCapacity ¶
type UplinkCapacity struct { Value uint32 `protobuf:"varint,1,opt,name=value,proto3" json:"value,omitempty"` // contains filtered or unexported fields }
Uplink capacity, in MB.
func (*UplinkCapacity) Descriptor
deprecated
func (*UplinkCapacity) Descriptor() ([]byte, []int)
Deprecated: Use UplinkCapacity.ProtoReflect.Descriptor instead.
func (*UplinkCapacity) GetValue ¶
func (x *UplinkCapacity) GetValue() uint32
func (*UplinkCapacity) ProtoMessage ¶
func (*UplinkCapacity) ProtoMessage()
func (*UplinkCapacity) ProtoReflect ¶
func (x *UplinkCapacity) ProtoReflect() protoreflect.Message
func (*UplinkCapacity) Reset ¶
func (x *UplinkCapacity) Reset()
func (*UplinkCapacity) String ¶
func (x *UplinkCapacity) String() string
type WriteBuffer ¶
type WriteBuffer struct { // Buffer size in bytes. Size uint32 `protobuf:"varint,1,opt,name=size,proto3" json:"size,omitempty"` // contains filtered or unexported fields }
func (*WriteBuffer) Descriptor
deprecated
func (*WriteBuffer) Descriptor() ([]byte, []int)
Deprecated: Use WriteBuffer.ProtoReflect.Descriptor instead.
func (*WriteBuffer) GetSize ¶
func (x *WriteBuffer) GetSize() uint32
func (*WriteBuffer) ProtoMessage ¶
func (*WriteBuffer) ProtoMessage()
func (*WriteBuffer) ProtoReflect ¶
func (x *WriteBuffer) ProtoReflect() protoreflect.Message
func (*WriteBuffer) Reset ¶
func (x *WriteBuffer) Reset()
func (*WriteBuffer) String ¶
func (x *WriteBuffer) String() string