kcp

package
v2.51.1+incompatible Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 25, 2017 License: MIT Imports: 25 Imported by: 0

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

View Source
const (
	DataSegmentOverhead = 18
)

Variables

View Source
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 ListenKCP

func ListenKCP(ctx context.Context, address net.Address, port net.Port, addConn internet.AddConnection) (internet.Listener, error)

func NewSimpleAuthenticator

func NewSimpleAuthenticator() cipher.AEAD

NewSimpleAuthenticator creates a new SimpleAuthenticator

Types

type AckList

type AckList struct {
	// contains filtered or unexported fields
}

func NewAckList

func NewAckList(writer SegmentWriter) *AckList

func (*AckList) Add

func (v *AckList) Add(number uint32, timestamp uint32)

func (*AckList) Clear

func (v *AckList) Clear(una uint32)

func (*AckList) Flush

func (v *AckList) Flush(current uint32, rto uint32)

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 (v *AckSegment) ByteSize() int

func (*AckSegment) Bytes

func (v *AckSegment) Bytes() buf.Supplier

func (*AckSegment) Command

func (v *AckSegment) Command() Command

func (*AckSegment) Conversation

func (v *AckSegment) Conversation() uint16

func (*AckSegment) IsEmpty

func (v *AckSegment) IsEmpty() bool

func (*AckSegment) IsFull

func (v *AckSegment) IsFull() bool

func (*AckSegment) PutNumber

func (v *AckSegment) PutNumber(number uint32)

func (*AckSegment) PutTimestamp

func (v *AckSegment) PutTimestamp(timestamp uint32)

func (*AckSegment) Release

func (v *AckSegment) Release()

type ClientConnection

type ClientConnection struct {
	sync.RWMutex
	net.Conn
	// contains filtered or unexported fields
}

func (*ClientConnection) Close

func (c *ClientConnection) Close() error

func (*ClientConnection) Overhead

func (c *ClientConnection) Overhead() int

func (*ClientConnection) Read

func (*ClientConnection) Read([]byte) (int, error)

func (*ClientConnection) Reset

func (c *ClientConnection) Reset(inputCallback func([]Segment))

func (*ClientConnection) ResetSecurity

func (c *ClientConnection) ResetSecurity(header internet.PacketHeader, security cipher.AEAD)

func (*ClientConnection) Run

func (c *ClientConnection) Run()

func (*ClientConnection) Write

func (c *ClientConnection) Write(b []byte) (int, error)

Write implements io.Writer.

type CmdOnlySegment

type CmdOnlySegment struct {
	Conv         uint16
	Cmd          Command
	Option       SegmentOption
	SendingNext  uint32
	ReceivinNext uint32
	PeerRTO      uint32
}

func NewCmdOnlySegment

func NewCmdOnlySegment() *CmdOnlySegment

func (*CmdOnlySegment) ByteSize

func (v *CmdOnlySegment) ByteSize() int

func (*CmdOnlySegment) Bytes

func (v *CmdOnlySegment) Bytes() buf.Supplier

func (*CmdOnlySegment) Command

func (v *CmdOnlySegment) Command() Command

func (*CmdOnlySegment) Conversation

func (v *CmdOnlySegment) Conversation() uint16

func (*CmdOnlySegment) Release

func (v *CmdOnlySegment) Release()

type Command

type Command byte

Command is a KCP command that indicate the purpose of a Segment.

const (
	// CommandACK indicates a AckSegment.
	CommandACK Command = 0
	// CommandData indicates a DataSegment.
	CommandData Command = 1
	// CommandTerminate indicates that peer terminates the connection.
	CommandTerminate Command = 2
	// CommandPing indicates a ping.
	CommandPing Command = 3
)

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     *v2ray_core_common_serial.TypedMessage `protobuf:"bytes,8,opt,name=header_config,json=headerConfig" json:"header_config,omitempty"`
}

func (*Config) Descriptor

func (*Config) Descriptor() ([]byte, []int)

func (*Config) GetCongestion

func (m *Config) GetCongestion() bool

func (*Config) GetDownlinkCapacity

func (m *Config) GetDownlinkCapacity() *DownlinkCapacity

func (*Config) GetDownlinkCapacityValue

func (v *Config) GetDownlinkCapacityValue() uint32

GetDownlinkCapacityValue returns the value of DownlinkCapacity settings.

func (*Config) GetHeaderConfig

func (m *Config) GetHeaderConfig() *v2ray_core_common_serial.TypedMessage

func (*Config) GetMTUValue

func (v *Config) GetMTUValue() uint32

GetMTUValue returns the value of MTU settings.

func (*Config) GetMtu

func (m *Config) GetMtu() *MTU

func (*Config) GetPackerHeader

func (v *Config) GetPackerHeader() (internet.PacketHeader, error)

func (*Config) GetReadBuffer

func (m *Config) GetReadBuffer() *ReadBuffer

func (*Config) GetReadBufferSize

func (v *Config) GetReadBufferSize() uint32

GetReadBufferSize returns the size of ReadBuffer in bytes.

func (*Config) GetReceivingBufferSize

func (v *Config) GetReceivingBufferSize() uint32

func (*Config) GetReceivingInFlightSize

func (v *Config) GetReceivingInFlightSize() uint32

func (*Config) GetSecurity

func (v *Config) GetSecurity() (cipher.AEAD, error)

GetSecurity returns the security settings.

func (*Config) GetSendingBufferSize

func (v *Config) GetSendingBufferSize() uint32

func (*Config) GetSendingInFlightSize

func (v *Config) GetSendingInFlightSize() uint32

func (*Config) GetTTIValue

func (v *Config) GetTTIValue() uint32

GetTTIValue returns the value of TTI settings.

func (*Config) GetTti

func (m *Config) GetTti() *TTI

func (*Config) GetUplinkCapacity

func (m *Config) GetUplinkCapacity() *UplinkCapacity

func (*Config) GetUplinkCapacityValue

func (v *Config) GetUplinkCapacityValue() uint32

GetUplinkCapacityValue returns the value of UplinkCapacity settings.

func (*Config) GetWriteBuffer

func (m *Config) GetWriteBuffer() *WriteBuffer

func (*Config) GetWriteBufferSize

func (v *Config) GetWriteBufferSize() uint32

GetWriteBufferSize returns the size of WriterBuffer in bytes.

func (*Config) ProtoMessage

func (*Config) ProtoMessage()

func (*Config) Reset

func (m *Config) Reset()

func (*Config) String

func (m *Config) String() string

type Congestion

type Congestion struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func (*Congestion) AddBytesConfirmed

func (v *Congestion) AddBytesConfirmed(current uint32, bytesConfirmed uint32)

func (*Congestion) GetBytesLimit

func (v *Congestion) GetBytesLimit() uint32

func (*Congestion) RoundTripTime

func (v *Congestion) RoundTripTime() uint32

func (*Congestion) SetState

func (v *Congestion) SetState(current uint32, state CongestionState)

func (*Congestion) Timeout

func (v *Congestion) Timeout() uint32

func (*Congestion) Update

func (v *Congestion) Update(current uint32)

func (*Congestion) UpdateRTT

func (v *Congestion) UpdateRTT(current uint32, rtt uint32)

type CongestionState

type CongestionState byte
const (
	CongestionStateRTTProbe CongestionState = iota
	CongestionStateBandwidthProbe
	CongestionStateTransfer
)

type Connection

type Connection struct {
	Config *Config
	// contains filtered or unexported fields
}

Connection is a KCP connection over UDP.

func NewConnection

func NewConnection(conv uint16, sysConn SystemConnection, config *Config) *Connection

NewConnection create a new KCP connection between local and remote.

func (*Connection) Close

func (v *Connection) Close() error

Close closes the connection.

func (*Connection) Elapsed

func (v *Connection) Elapsed() uint32

func (*Connection) HandleOption

func (v *Connection) HandleOption(opt SegmentOption)

func (*Connection) Input

func (v *Connection) Input(segments []Segment)

Input when you received a low level packet (eg. UDP packet), call it

func (*Connection) LocalAddr

func (v *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) OnDataInput

func (v *Connection) OnDataInput()

func (*Connection) OnDataOutput

func (v *Connection) OnDataOutput()

func (*Connection) OnPeerClosed

func (v *Connection) OnPeerClosed()

func (*Connection) Ping

func (v *Connection) Ping(current uint32, cmd Command)

func (*Connection) Read

func (v *Connection) Read(b []byte) (int, error)

Read implements the Conn Read method.

func (*Connection) ReadMultiBuffer

func (v *Connection) ReadMultiBuffer() (buf.MultiBuffer, error)

ReadMultiBuffer implements buf.Reader.

func (*Connection) RemoteAddr

func (v *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 (v *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 (v *Connection) SetReadDeadline(t time.Time) error

SetReadDeadline implements the Conn SetReadDeadline method.

func (*Connection) SetState

func (v *Connection) SetState(state State)

func (*Connection) SetWriteDeadline

func (v *Connection) SetWriteDeadline(t time.Time) error

SetWriteDeadline implements the Conn SetWriteDeadline method.

func (*Connection) State

func (v *Connection) State() State

func (*Connection) Terminate

func (v *Connection) Terminate()

func (*Connection) Write

func (v *Connection) Write(b []byte) (int, error)

Write implements the Conn Write method.

type ConnectionID

type ConnectionID struct {
	Remote net.Address
	Port   net.Port
	Conv   uint16
}

type ConnectionReuse

type ConnectionReuse struct {
	Enable bool `protobuf:"varint,1,opt,name=enable" json:"enable,omitempty"`
}

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

type DataSegment

type DataSegment struct {
	Conv        uint16
	Option      SegmentOption
	Timestamp   uint32
	Number      uint32
	SendingNext uint32
	Data        *buf.Buffer
	// contains filtered or unexported fields
}

func NewDataSegment

func NewDataSegment() *DataSegment

func (*DataSegment) ByteSize

func (v *DataSegment) ByteSize() int

func (*DataSegment) Bytes

func (v *DataSegment) Bytes() buf.Supplier

func (*DataSegment) Command

func (v *DataSegment) Command() Command

func (*DataSegment) Conversation

func (v *DataSegment) Conversation() uint16

func (*DataSegment) Release

func (v *DataSegment) Release()

func (*DataSegment) SetData

func (v *DataSegment) SetData(data []byte)

type DownlinkCapacity

type DownlinkCapacity struct {
	Value uint32 `protobuf:"varint,1,opt,name=value" json:"value,omitempty"`
}

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

type KCPPacketReader

type KCPPacketReader struct {
	Security cipher.AEAD
	Header   internet.PacketHeader
}

func (*KCPPacketReader) Read

func (r *KCPPacketReader) Read(b []byte) []Segment

type KCPPacketWriter

type KCPPacketWriter struct {
	Header   internet.PacketHeader
	Security cipher.AEAD
	Writer   io.Writer
	// contains filtered or unexported fields
}

func (*KCPPacketWriter) Overhead

func (w *KCPPacketWriter) Overhead() int

func (*KCPPacketWriter) Write

func (w *KCPPacketWriter) Write(b []byte) (int, error)

type Listener

type Listener struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Listener defines a server listening for connections

func NewListener

func NewListener(ctx context.Context, address net.Address, port net.Port, addConn internet.AddConnection) (*Listener, error)

func (*Listener) ActiveConnections

func (v *Listener) ActiveConnections() int

func (*Listener) Addr

func (v *Listener) Addr() net.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

func (v *Listener) Close() error

Close stops listening on the UDP address. Already Accepted connections are not closed.

func (*Listener) OnReceive

func (v *Listener) OnReceive(payload *buf.Buffer, src net.Destination, originalDest net.Destination)

func (*Listener) Remove

func (v *Listener) Remove(id ConnectionID)

type MTU

type MTU struct {
	Value uint32 `protobuf:"varint,1,opt,name=value" json:"value,omitempty"`
}

Maximum Transmission Unit, in bytes.

func (*MTU) Descriptor

func (*MTU) Descriptor() ([]byte, []int)

func (*MTU) GetValue

func (m *MTU) GetValue() uint32

func (*MTU) ProtoMessage

func (*MTU) ProtoMessage()

func (*MTU) Reset

func (m *MTU) Reset()

func (*MTU) String

func (m *MTU) String() string

type PacketReader

type PacketReader interface {
	Read([]byte) []Segment
}

type PacketWriter

type PacketWriter interface {
	Overhead() int
	io.Writer
}

type Queue

type Queue struct {
	// contains filtered or unexported fields
}

func (*Queue) Max

func (v *Queue) Max() uint32

func (*Queue) Min

func (v *Queue) Min() uint32

func (*Queue) Push

func (v *Queue) Push(value uint32)

type ReadBuffer

type ReadBuffer struct {
	// Buffer size in bytes.
	Size uint32 `protobuf:"varint,1,opt,name=size" json:"size,omitempty"`
}

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

type ReceivingWindow

type ReceivingWindow struct {
	// contains filtered or unexported fields
}

func NewReceivingWindow

func NewReceivingWindow(size uint32) *ReceivingWindow

func (*ReceivingWindow) Advance

func (v *ReceivingWindow) Advance()

func (*ReceivingWindow) HasFirst

func (w *ReceivingWindow) HasFirst() bool

func (*ReceivingWindow) Position

func (v *ReceivingWindow) Position(idx uint32) uint32

func (*ReceivingWindow) Remove

func (v *ReceivingWindow) Remove(idx uint32) *DataSegment

func (*ReceivingWindow) RemoveFirst

func (v *ReceivingWindow) RemoveFirst() *DataSegment

func (*ReceivingWindow) Set

func (v *ReceivingWindow) Set(idx uint32, value *DataSegment) bool

func (*ReceivingWindow) Size

func (v *ReceivingWindow) Size() uint32

type ReceivingWorker

type ReceivingWorker struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewReceivingWorker

func NewReceivingWorker(kcp *Connection) *ReceivingWorker

func (*ReceivingWorker) CloseRead

func (v *ReceivingWorker) CloseRead()

func (*ReceivingWorker) Flush

func (v *ReceivingWorker) Flush(current uint32)

func (*ReceivingWorker) IsDataAvailable

func (w *ReceivingWorker) IsDataAvailable() bool

func (*ReceivingWorker) NextNumber

func (w *ReceivingWorker) NextNumber() uint32

func (*ReceivingWorker) ProcessSegment

func (v *ReceivingWorker) ProcessSegment(seg *DataSegment)

func (*ReceivingWorker) ProcessSendingNext

func (v *ReceivingWorker) ProcessSendingNext(number uint32)

func (*ReceivingWorker) Read

func (v *ReceivingWorker) Read(b []byte) int

func (*ReceivingWorker) ReadMultiBuffer

func (v *ReceivingWorker) ReadMultiBuffer() buf.MultiBuffer

func (*ReceivingWorker) Release

func (v *ReceivingWorker) Release()

func (*ReceivingWorker) UpdateNecessary

func (v *ReceivingWorker) UpdateNecessary() bool

func (*ReceivingWorker) Write

func (v *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

type RoundTripInfo struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func (*RoundTripInfo) SmoothedTime

func (v *RoundTripInfo) SmoothedTime() uint32

func (*RoundTripInfo) Timeout

func (v *RoundTripInfo) Timeout() uint32

func (*RoundTripInfo) Update

func (v *RoundTripInfo) Update(rtt uint32, current uint32)

func (*RoundTripInfo) UpdatePeerRTO

func (v *RoundTripInfo) UpdatePeerRTO(rto uint32, current uint32)

type Segment

type Segment interface {
	Release()
	Conversation() uint16
	Command() Command
	ByteSize() int
	Bytes() buf.Supplier
}

func ReadSegment

func ReadSegment(buf []byte) (Segment, []byte)

type SegmentOption

type SegmentOption byte
const (
	SegmentOptionClose SegmentOption = 1
)

type SegmentWriter

type SegmentWriter interface {
	Write(seg Segment) error
}

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 (v *SendingWindow) Clear(una uint32)

func (*SendingWindow) FirstNumber

func (v *SendingWindow) FirstNumber() uint32

func (*SendingWindow) Flush

func (v *SendingWindow) Flush(current uint32, rto uint32, maxInFlightSize uint32)

func (*SendingWindow) HandleFastAck

func (v *SendingWindow) HandleFastAck(number uint32, rto uint32)

func (*SendingWindow) IsEmpty

func (v *SendingWindow) IsEmpty() bool

func (*SendingWindow) IsFull

func (v *SendingWindow) IsFull() bool

func (*SendingWindow) Len

func (v *SendingWindow) Len() int

func (*SendingWindow) Push

func (v *SendingWindow) Push(number uint32, data []byte)

func (*SendingWindow) Release

func (v *SendingWindow) Release()

func (*SendingWindow) Remove

func (v *SendingWindow) Remove(idx uint32) bool

func (*SendingWindow) Size

func (v *SendingWindow) Size() uint32

func (*SendingWindow) Visit

func (v *SendingWindow) Visit(visitor func(seg *DataSegment) bool)

type SendingWorker

type SendingWorker struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewSendingWorker

func NewSendingWorker(kcp *Connection) *SendingWorker

func (*SendingWorker) CloseWrite

func (v *SendingWorker) CloseWrite()

func (*SendingWorker) FindFirstUnacknowledged

func (v *SendingWorker) FindFirstUnacknowledged()

Private: Visible for testing.

func (*SendingWorker) FirstUnacknowledged

func (w *SendingWorker) FirstUnacknowledged() uint32

func (*SendingWorker) Flush

func (v *SendingWorker) Flush(current uint32)

func (*SendingWorker) IsEmpty

func (v *SendingWorker) IsEmpty() bool

func (*SendingWorker) OnPacketLoss

func (v *SendingWorker) OnPacketLoss(lossRate uint32)

func (*SendingWorker) ProcessReceivingNext

func (v *SendingWorker) ProcessReceivingNext(nextNumber uint32)

func (*SendingWorker) ProcessReceivingNextWithoutLock

func (v *SendingWorker) ProcessReceivingNextWithoutLock(nextNumber uint32)

func (*SendingWorker) ProcessSegment

func (v *SendingWorker) ProcessSegment(current uint32, seg *AckSegment, rto uint32)

func (*SendingWorker) Push

func (v *SendingWorker) Push(b []byte) int

func (*SendingWorker) Release

func (v *SendingWorker) Release()

func (*SendingWorker) UpdateNecessary

func (v *SendingWorker) UpdateNecessary() bool

func (*SendingWorker) Write

func (v *SendingWorker) Write(seg Segment) error

Private: Visible for testing.

type ServerConnection

type ServerConnection struct {
	// contains filtered or unexported fields
}

func (*ServerConnection) Close

func (c *ServerConnection) Close() error

func (*ServerConnection) LocalAddr

func (c *ServerConnection) LocalAddr() net.Addr

func (*ServerConnection) Overhead

func (c *ServerConnection) Overhead() int

func (*ServerConnection) Read

func (*ServerConnection) Read([]byte) (int, error)

func (*ServerConnection) RemoteAddr

func (c *ServerConnection) RemoteAddr() net.Addr

func (*ServerConnection) Reset

func (*ServerConnection) Reset(input func([]Segment))

func (*ServerConnection) SetDeadline

func (*ServerConnection) SetDeadline(time.Time) error

func (*ServerConnection) SetReadDeadline

func (*ServerConnection) SetReadDeadline(time.Time) error

func (*ServerConnection) SetWriteDeadline

func (*ServerConnection) SetWriteDeadline(time.Time) error

func (*ServerConnection) Write

func (c *ServerConnection) Write(b []byte) (int, 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

type SimpleSegmentWriter struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func (*SimpleSegmentWriter) Write

func (w *SimpleSegmentWriter) Write(seg Segment) error

type State

type State int32
const (
	StateActive          State = 0
	StateReadyToClose    State = 1
	StatePeerClosed      State = 2
	StateTerminating     State = 3
	StatePeerTerminating State = 4
	StateTerminated      State = 5
)

func (State) Is

func (s State) Is(states ...State) bool

type SystemConnection

type SystemConnection interface {
	net.Conn
	Reset(func([]Segment))
	Overhead() int
}

type TTI

type TTI struct {
	Value uint32 `protobuf:"varint,1,opt,name=value" json:"value,omitempty"`
}

Transmission Time Interview, in milli-sec.

func (*TTI) Descriptor

func (*TTI) Descriptor() ([]byte, []int)

func (*TTI) GetValue

func (m *TTI) GetValue() uint32

func (*TTI) ProtoMessage

func (*TTI) ProtoMessage()

func (*TTI) Reset

func (m *TTI) Reset()

func (*TTI) String

func (m *TTI) String() string

type Updater

type Updater struct {
	// contains filtered or unexported fields
}

func NewUpdater

func NewUpdater(interval uint32, shouldContinue predicate.Predicate, shouldTerminate predicate.Predicate, updateFunc func()) *Updater

func (*Updater) Interval

func (u *Updater) Interval() time.Duration

func (*Updater) Run

func (v *Updater) Run()

func (*Updater) SetInterval

func (u *Updater) SetInterval(d time.Duration)

func (*Updater) WakeUp

func (v *Updater) WakeUp()

type UplinkCapacity

type UplinkCapacity struct {
	Value uint32 `protobuf:"varint,1,opt,name=value" json:"value,omitempty"`
}

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

type WriteBuffer

type WriteBuffer struct {
	// Buffer size in bytes.
	Size uint32 `protobuf:"varint,1,opt,name=size" json:"size,omitempty"`
}

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

type Writer

type Writer struct {
	// contains filtered or unexported fields
}

func (*Writer) Close

func (v *Writer) Close() error

func (*Writer) Write

func (v *Writer) Write(payload []byte) (int, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL