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) (internet.Connection, error)
- func ListenKCP(ctx context.Context, address net.Address, port net.Port, ...) (internet.Listener, error)
- func NewSimpleAuthenticator() cipher.AEAD
- type AckList
- type AckSegment
- func (s *AckSegment) ByteSize() int32
- func (s *AckSegment) Bytes() buf.Supplier
- 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()
- type CmdOnlySegment
- type Command
- type Config
- func (*Config) Descriptor() ([]byte, []int)
- func (m *Config) GetCongestion() bool
- func (m *Config) GetDownlinkCapacity() *DownlinkCapacity
- func (c *Config) GetDownlinkCapacityValue() uint32
- func (m *Config) GetHeaderConfig() *serial.TypedMessage
- func (c *Config) GetMTUValue() uint32
- func (m *Config) GetMtu() *MTU
- func (c *Config) GetPackerHeader() (internet.PacketHeader, error)
- func (m *Config) GetReadBuffer() *ReadBuffer
- func (c *Config) GetReadBufferSize() uint32
- func (c *Config) GetReceivingBufferSize() uint32
- func (c *Config) GetReceivingInFlightSize() uint32
- func (*Config) GetSecurity() (cipher.AEAD, error)
- func (c *Config) GetSendingBufferSize() uint32
- func (c *Config) GetSendingInFlightSize() uint32
- func (c *Config) GetTTIValue() uint32
- func (m *Config) GetTti() *TTI
- func (m *Config) GetUplinkCapacity() *UplinkCapacity
- func (c *Config) GetUplinkCapacityValue() uint32
- func (m *Config) GetWriteBuffer() *WriteBuffer
- func (c *Config) GetWriteBufferSize() uint32
- func (*Config) ProtoMessage()
- func (m *Config) Reset()
- func (m *Config) String() string
- func (m *Config) XXX_DiscardUnknown()
- func (m *Config) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (dst *Config) XXX_Merge(src proto.Message)
- func (m *Config) XXX_Size() int
- func (m *Config) XXX_Unmarshal(b []byte) error
- 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
- func (*ConnectionReuse) Descriptor() ([]byte, []int)
- func (m *ConnectionReuse) GetEnable() bool
- func (*ConnectionReuse) ProtoMessage()
- func (m *ConnectionReuse) Reset()
- func (m *ConnectionReuse) String() string
- func (m *ConnectionReuse) XXX_DiscardUnknown()
- func (m *ConnectionReuse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (dst *ConnectionReuse) XXX_Merge(src proto.Message)
- func (m *ConnectionReuse) XXX_Size() int
- func (m *ConnectionReuse) XXX_Unmarshal(b []byte) error
- type DataSegment
- type DownlinkCapacity
- func (*DownlinkCapacity) Descriptor() ([]byte, []int)
- func (m *DownlinkCapacity) GetValue() uint32
- func (*DownlinkCapacity) ProtoMessage()
- func (m *DownlinkCapacity) Reset()
- func (m *DownlinkCapacity) String() string
- func (m *DownlinkCapacity) XXX_DiscardUnknown()
- func (m *DownlinkCapacity) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (dst *DownlinkCapacity) XXX_Merge(src proto.Message)
- func (m *DownlinkCapacity) XXX_Size() int
- func (m *DownlinkCapacity) XXX_Unmarshal(b []byte) error
- type KCPPacketReader
- type KCPPacketWriter
- type Listener
- type MTU
- func (*MTU) Descriptor() ([]byte, []int)
- func (m *MTU) GetValue() uint32
- func (*MTU) ProtoMessage()
- func (m *MTU) Reset()
- func (m *MTU) String() string
- func (m *MTU) XXX_DiscardUnknown()
- func (m *MTU) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (dst *MTU) XXX_Merge(src proto.Message)
- func (m *MTU) XXX_Size() int
- func (m *MTU) XXX_Unmarshal(b []byte) error
- type PacketReader
- type PacketWriter
- type ReadBuffer
- func (*ReadBuffer) Descriptor() ([]byte, []int)
- func (m *ReadBuffer) GetSize() uint32
- func (*ReadBuffer) ProtoMessage()
- func (m *ReadBuffer) Reset()
- func (m *ReadBuffer) String() string
- func (m *ReadBuffer) XXX_DiscardUnknown()
- func (m *ReadBuffer) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (dst *ReadBuffer) XXX_Merge(src proto.Message)
- func (m *ReadBuffer) XXX_Size() int
- func (m *ReadBuffer) XXX_Unmarshal(b []byte) error
- type ReceivingWindow
- func (w *ReceivingWindow) Advance()
- func (w *ReceivingWindow) HasFirst() bool
- func (w *ReceivingWindow) Position(idx uint32) uint32
- func (w *ReceivingWindow) Remove(idx uint32) *DataSegment
- func (w *ReceivingWindow) RemoveFirst() *DataSegment
- func (w *ReceivingWindow) Set(idx uint32, value *DataSegment) bool
- func (w *ReceivingWindow) Size() uint32
- 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) IsFull() bool
- func (sw *SendingWindow) Len() int
- func (sw *SendingWindow) Push(number uint32) *buf.Buffer
- func (sw *SendingWindow) Release()
- func (sw *SendingWindow) Remove(idx uint32) bool
- func (sw *SendingWindow) Size() uint32
- 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(f buf.Supplier) 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
- func (*TTI) Descriptor() ([]byte, []int)
- func (m *TTI) GetValue() uint32
- func (*TTI) ProtoMessage()
- func (m *TTI) Reset()
- func (m *TTI) String() string
- func (m *TTI) XXX_DiscardUnknown()
- func (m *TTI) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (dst *TTI) XXX_Merge(src proto.Message)
- func (m *TTI) XXX_Size() int
- func (m *TTI) XXX_Unmarshal(b []byte) error
- type Updater
- type UplinkCapacity
- func (*UplinkCapacity) Descriptor() ([]byte, []int)
- func (m *UplinkCapacity) GetValue() uint32
- func (*UplinkCapacity) ProtoMessage()
- func (m *UplinkCapacity) Reset()
- func (m *UplinkCapacity) String() string
- func (m *UplinkCapacity) XXX_DiscardUnknown()
- func (m *UplinkCapacity) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (dst *UplinkCapacity) XXX_Merge(src proto.Message)
- func (m *UplinkCapacity) XXX_Size() int
- func (m *UplinkCapacity) XXX_Unmarshal(b []byte) error
- type WriteBuffer
- func (*WriteBuffer) Descriptor() ([]byte, []int)
- func (m *WriteBuffer) GetSize() uint32
- func (*WriteBuffer) ProtoMessage()
- func (m *WriteBuffer) Reset()
- func (m *WriteBuffer) String() string
- func (m *WriteBuffer) XXX_DiscardUnknown()
- func (m *WriteBuffer) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (dst *WriteBuffer) XXX_Merge(src proto.Message)
- func (m *WriteBuffer) XXX_Size() int
- func (m *WriteBuffer) XXX_Unmarshal(b []byte) error
- type Writer
Constants ¶
const (
DataSegmentOverhead = 18
)
Variables ¶
var ( ErrIOTimeout = newError("Read/Write timeout") ErrClosedListener = newError("Listener closed.") ErrClosedConnection = newError("Connection closed.") )
Functions ¶
func DialKCP ¶
func DialKCP(ctx context.Context, dest net.Destination) (internet.Connection, error)
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) Bytes ¶
func (s *AckSegment) Bytes() buf.Supplier
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()
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) Bytes ¶
func (s *CmdOnlySegment) Bytes() buf.Supplier
func (*CmdOnlySegment) Command ¶
func (s *CmdOnlySegment) Command() Command
func (*CmdOnlySegment) Conversation ¶
func (s *CmdOnlySegment) Conversation() uint16
func (*CmdOnlySegment) Release ¶
func (*CmdOnlySegment) Release()
type Config ¶
type Config struct { Mtu *MTU `protobuf:"bytes,1,opt,name=mtu" json:"mtu,omitempty"` Tti *TTI `protobuf:"bytes,2,opt,name=tti" json:"tti,omitempty"` UplinkCapacity *UplinkCapacity `protobuf:"bytes,3,opt,name=uplink_capacity,json=uplinkCapacity" json:"uplink_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"` WriteBuffer *WriteBuffer `protobuf:"bytes,6,opt,name=write_buffer,json=writeBuffer" json:"write_buffer,omitempty"` ReadBuffer *ReadBuffer `protobuf:"bytes,7,opt,name=read_buffer,json=readBuffer" json:"read_buffer,omitempty"` HeaderConfig *serial.TypedMessage `protobuf:"bytes,8,opt,name=header_config,json=headerConfig" json:"header_config,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` }
func (*Config) Descriptor ¶
func (*Config) GetCongestion ¶
func (*Config) GetDownlinkCapacity ¶
func (m *Config) GetDownlinkCapacity() *DownlinkCapacity
func (*Config) GetDownlinkCapacityValue ¶
GetDownlinkCapacityValue returns the value of DownlinkCapacity settings.
func (*Config) GetHeaderConfig ¶
func (m *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 (m *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) GetSendingBufferSize ¶
func (*Config) GetSendingInFlightSize ¶
func (*Config) GetTTIValue ¶
GetTTIValue returns the value of TTI settings.
func (*Config) GetUplinkCapacity ¶
func (m *Config) GetUplinkCapacity() *UplinkCapacity
func (*Config) GetUplinkCapacityValue ¶
GetUplinkCapacityValue returns the value of UplinkCapacity settings.
func (*Config) GetWriteBuffer ¶
func (m *Config) GetWriteBuffer() *WriteBuffer
func (*Config) GetWriteBufferSize ¶
GetWriteBufferSize returns the size of WriterBuffer in bytes.
func (*Config) ProtoMessage ¶
func (*Config) ProtoMessage()
func (*Config) XXX_DiscardUnknown ¶
func (m *Config) XXX_DiscardUnknown()
func (*Config) XXX_Marshal ¶
func (*Config) XXX_Unmarshal ¶
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" json:"enable,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` }
func (*ConnectionReuse) Descriptor ¶
func (*ConnectionReuse) Descriptor() ([]byte, []int)
func (*ConnectionReuse) GetEnable ¶
func (m *ConnectionReuse) GetEnable() bool
func (*ConnectionReuse) ProtoMessage ¶
func (*ConnectionReuse) ProtoMessage()
func (*ConnectionReuse) Reset ¶
func (m *ConnectionReuse) Reset()
func (*ConnectionReuse) String ¶
func (m *ConnectionReuse) String() string
func (*ConnectionReuse) XXX_DiscardUnknown ¶
func (m *ConnectionReuse) XXX_DiscardUnknown()
func (*ConnectionReuse) XXX_Marshal ¶
func (m *ConnectionReuse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*ConnectionReuse) XXX_Merge ¶
func (dst *ConnectionReuse) XXX_Merge(src proto.Message)
func (*ConnectionReuse) XXX_Size ¶
func (m *ConnectionReuse) XXX_Size() int
func (*ConnectionReuse) XXX_Unmarshal ¶
func (m *ConnectionReuse) XXX_Unmarshal(b []byte) error
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) Bytes ¶
func (s *DataSegment) Bytes() buf.Supplier
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()
type DownlinkCapacity ¶
type DownlinkCapacity struct { Value uint32 `protobuf:"varint,1,opt,name=value" json:"value,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` }
Downlink capacity, in MB.
func (*DownlinkCapacity) Descriptor ¶
func (*DownlinkCapacity) Descriptor() ([]byte, []int)
func (*DownlinkCapacity) GetValue ¶
func (m *DownlinkCapacity) GetValue() uint32
func (*DownlinkCapacity) ProtoMessage ¶
func (*DownlinkCapacity) ProtoMessage()
func (*DownlinkCapacity) Reset ¶
func (m *DownlinkCapacity) Reset()
func (*DownlinkCapacity) String ¶
func (m *DownlinkCapacity) String() string
func (*DownlinkCapacity) XXX_DiscardUnknown ¶
func (m *DownlinkCapacity) XXX_DiscardUnknown()
func (*DownlinkCapacity) XXX_Marshal ¶
func (m *DownlinkCapacity) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*DownlinkCapacity) XXX_Merge ¶
func (dst *DownlinkCapacity) XXX_Merge(src proto.Message)
func (*DownlinkCapacity) XXX_Size ¶
func (m *DownlinkCapacity) XXX_Size() int
func (*DownlinkCapacity) XXX_Unmarshal ¶
func (m *DownlinkCapacity) XXX_Unmarshal(b []byte) error
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) OnReceive ¶
func (l *Listener) OnReceive(payload *buf.Buffer, src net.Destination, originalDest net.Destination)
func (*Listener) Remove ¶
func (l *Listener) Remove(id ConnectionID)
type MTU ¶
type MTU struct { Value uint32 `protobuf:"varint,1,opt,name=value" json:"value,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` }
Maximum Transmission Unit, in bytes.
func (*MTU) Descriptor ¶
func (*MTU) ProtoMessage ¶
func (*MTU) ProtoMessage()
func (*MTU) XXX_DiscardUnknown ¶
func (m *MTU) XXX_DiscardUnknown()
func (*MTU) XXX_Unmarshal ¶
type PacketReader ¶
type PacketWriter ¶
type ReadBuffer ¶
type ReadBuffer struct { // Buffer size in bytes. Size uint32 `protobuf:"varint,1,opt,name=size" json:"size,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` }
func (*ReadBuffer) Descriptor ¶
func (*ReadBuffer) Descriptor() ([]byte, []int)
func (*ReadBuffer) GetSize ¶
func (m *ReadBuffer) GetSize() uint32
func (*ReadBuffer) ProtoMessage ¶
func (*ReadBuffer) ProtoMessage()
func (*ReadBuffer) Reset ¶
func (m *ReadBuffer) Reset()
func (*ReadBuffer) String ¶
func (m *ReadBuffer) String() string
func (*ReadBuffer) XXX_DiscardUnknown ¶
func (m *ReadBuffer) XXX_DiscardUnknown()
func (*ReadBuffer) XXX_Marshal ¶
func (m *ReadBuffer) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*ReadBuffer) XXX_Merge ¶
func (dst *ReadBuffer) XXX_Merge(src proto.Message)
func (*ReadBuffer) XXX_Size ¶
func (m *ReadBuffer) XXX_Size() int
func (*ReadBuffer) XXX_Unmarshal ¶
func (m *ReadBuffer) XXX_Unmarshal(b []byte) error
type ReceivingWindow ¶
type ReceivingWindow struct {
// contains filtered or unexported fields
}
func NewReceivingWindow ¶
func NewReceivingWindow(size uint32) *ReceivingWindow
func (*ReceivingWindow) Advance ¶
func (w *ReceivingWindow) Advance()
func (*ReceivingWindow) HasFirst ¶
func (w *ReceivingWindow) HasFirst() bool
func (*ReceivingWindow) Position ¶
func (w *ReceivingWindow) Position(idx uint32) uint32
func (*ReceivingWindow) Remove ¶
func (w *ReceivingWindow) Remove(idx uint32) *DataSegment
func (*ReceivingWindow) RemoveFirst ¶
func (w *ReceivingWindow) RemoveFirst() *DataSegment
func (*ReceivingWindow) Set ¶
func (w *ReceivingWindow) Set(idx uint32, value *DataSegment) bool
func (*ReceivingWindow) Size ¶
func (w *ReceivingWindow) Size() uint32
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 Bytes() buf.Supplier // 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(size uint32, 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) IsFull ¶
func (sw *SendingWindow) IsFull() bool
func (*SendingWindow) Len ¶
func (sw *SendingWindow) Len() int
func (*SendingWindow) Release ¶
func (sw *SendingWindow) Release()
func (*SendingWindow) Remove ¶
func (sw *SendingWindow) Remove(idx uint32) bool
func (*SendingWindow) Size ¶
func (sw *SendingWindow) Size() uint32
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" json:"value,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` }
Transmission Time Interview, in milli-sec.
func (*TTI) Descriptor ¶
func (*TTI) ProtoMessage ¶
func (*TTI) ProtoMessage()
func (*TTI) XXX_DiscardUnknown ¶
func (m *TTI) XXX_DiscardUnknown()
func (*TTI) XXX_Unmarshal ¶
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" json:"value,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` }
Uplink capacity, in MB.
func (*UplinkCapacity) Descriptor ¶
func (*UplinkCapacity) Descriptor() ([]byte, []int)
func (*UplinkCapacity) GetValue ¶
func (m *UplinkCapacity) GetValue() uint32
func (*UplinkCapacity) ProtoMessage ¶
func (*UplinkCapacity) ProtoMessage()
func (*UplinkCapacity) Reset ¶
func (m *UplinkCapacity) Reset()
func (*UplinkCapacity) String ¶
func (m *UplinkCapacity) String() string
func (*UplinkCapacity) XXX_DiscardUnknown ¶
func (m *UplinkCapacity) XXX_DiscardUnknown()
func (*UplinkCapacity) XXX_Marshal ¶
func (m *UplinkCapacity) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*UplinkCapacity) XXX_Merge ¶
func (dst *UplinkCapacity) XXX_Merge(src proto.Message)
func (*UplinkCapacity) XXX_Size ¶
func (m *UplinkCapacity) XXX_Size() int
func (*UplinkCapacity) XXX_Unmarshal ¶
func (m *UplinkCapacity) XXX_Unmarshal(b []byte) error
type WriteBuffer ¶
type WriteBuffer struct { // Buffer size in bytes. Size uint32 `protobuf:"varint,1,opt,name=size" json:"size,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` }
func (*WriteBuffer) Descriptor ¶
func (*WriteBuffer) Descriptor() ([]byte, []int)
func (*WriteBuffer) GetSize ¶
func (m *WriteBuffer) GetSize() uint32
func (*WriteBuffer) ProtoMessage ¶
func (*WriteBuffer) ProtoMessage()
func (*WriteBuffer) Reset ¶
func (m *WriteBuffer) Reset()
func (*WriteBuffer) String ¶
func (m *WriteBuffer) String() string
func (*WriteBuffer) XXX_DiscardUnknown ¶
func (m *WriteBuffer) XXX_DiscardUnknown()
func (*WriteBuffer) XXX_Marshal ¶
func (m *WriteBuffer) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*WriteBuffer) XXX_Merge ¶
func (dst *WriteBuffer) XXX_Merge(src proto.Message)
func (*WriteBuffer) XXX_Size ¶
func (m *WriteBuffer) XXX_Size() int
func (*WriteBuffer) XXX_Unmarshal ¶
func (m *WriteBuffer) XXX_Unmarshal(b []byte) error