Documentation ¶
Index ¶
- Constants
- Variables
- func CompareSeq(seq1, seq2 uint32) int
- func NextSeq(seq uint32, step int64) uint32
- func SeqInBetween(startSeq, endSeq, targetSeq uint32) bool
- type Config
- type Connection
- func (conn *Connection) ReceiveAck(sequenceID uint32, isSentByMe bool)
- func (conn *Connection) RetransmissionTimeout() time.Duration
- func (conn *Connection) SendAck(sequenceID uint32)
- func (conn *Connection) SendAckQueueLen() int
- func (conn *Connection) SendWindowUsed() uint32
- func (conn *Connection) Start()
- type GenericError
- type SendWithFunc
- type SeqHeap
- type Session
- func (session *Session) Accept() error
- func (session *Session) Close() error
- func (session *Session) Dial(ctx context.Context) error
- func (session *Session) GetBytesRead() uint64
- func (session *Session) GetConnWindowSize() uint32
- func (session *Session) GetContext() context.Context
- func (session *Session) GetDataToSend(sequenceID uint32) []byte
- func (session *Session) IsClosed() bool
- func (session *Session) IsClosedByRemote() bool
- func (session *Session) IsEstablished() bool
- func (session *Session) IsStream() bool
- func (session *Session) LocalAddr() net.Addr
- func (session *Session) Read(b []byte) (_ int, e error)
- func (session *Session) ReceiveWith(localClientID, remoteClientID string, buf []byte) error
- func (session *Session) RecvWindowUsed() uint32
- func (session *Session) RemoteAddr() net.Addr
- func (session *Session) SendWindowUsed() uint32
- func (session *Session) SetDeadline(t time.Time) error
- func (session *Session) SetLinger(t int32)
- func (session *Session) SetReadDeadline(t time.Time) error
- func (session *Session) SetWriteDeadline(t time.Time) error
- func (session *Session) Write(b []byte) (_ int, e error)
Constants ¶
View Source
const (
MinSequenceID = 1
)
Variables ¶
View Source
var ( ErrSessionClosed = NewGenericError("session closed", false, false) ErrSessionEstablished = NewGenericError("session is already established", false, false) ErrSessionNotEstablished = NewGenericError("session not established yet", false, true) ErrReadDeadlineExceeded = NewGenericError("read deadline exceeded", true, true) ErrWriteDeadlineExceeded = NewGenericError("write deadline exceeded", true, true) ErrBufferSizeTooSmall = NewGenericError("read buffer size is less than data length in non-stream mode", false, true) ErrDataSizeTooLarge = NewGenericError("data size is greater than session mtu", false, true) ErrInvalidPacket = NewGenericError("invalid packet", false, true) ErrRecvWindowFull = NewGenericError("receive window full", false, true) ErrNotHandshake = NewGenericError("first packet is not handshake packet", false, true) ErrConnClosed = NewGenericError("connection closed", false, false) ErrConnNotFound = NewGenericError("connection not found", false, false) )
View Source
var DefaultConfig = Config{ NonStream: false, SessionWindowSize: 4 << 20, MTU: 1024, MinConnectionWindowSize: 1, MaxAckSeqListSize: 32, FlushInterval: 10, Linger: 1000, InitialRetransmissionTimeout: 5000, MaxRetransmissionTimeout: 10000, SendAckInterval: 50, CheckTimeoutInterval: 50, CheckBytesReadInterval: 100, SendBytesReadThreshold: 200, Verbose: false, }
Functions ¶
func CompareSeq ¶
func SeqInBetween ¶
Types ¶
type Config ¶
type Config struct { NonStream bool SessionWindowSize int32 // in bytes MTU int32 // in bytes MinConnectionWindowSize int32 // in packets MaxAckSeqListSize int32 FlushInterval int32 // in millisecond Linger int32 // in millisecond InitialRetransmissionTimeout int32 // in millisecond MaxRetransmissionTimeout int32 // in millisecond SendAckInterval int32 // in millisecond CheckTimeoutInterval int32 // in millisecond CheckBytesReadInterval int32 // in millisecond SendBytesReadThreshold int32 // in millisecond Verbose bool }
func MergeConfig ¶
type Connection ¶
func NewConnection ¶
func NewConnection(session *Session, localClientID, remoteClientID string, initialWindowSize float64) (*Connection, error)
func (*Connection) ReceiveAck ¶
func (conn *Connection) ReceiveAck(sequenceID uint32, isSentByMe bool)
func (*Connection) RetransmissionTimeout ¶
func (conn *Connection) RetransmissionTimeout() time.Duration
func (*Connection) SendAck ¶
func (conn *Connection) SendAck(sequenceID uint32)
func (*Connection) SendAckQueueLen ¶
func (conn *Connection) SendAckQueueLen() int
func (*Connection) SendWindowUsed ¶
func (conn *Connection) SendWindowUsed() uint32
func (*Connection) Start ¶
func (conn *Connection) Start()
type GenericError ¶
type GenericError struct {
// contains filtered or unexported fields
}
func NewGenericError ¶
func NewGenericError(err string, timeout, temporary bool) *GenericError
func (GenericError) Error ¶
func (e GenericError) Error() string
func (GenericError) Temporary ¶
func (e GenericError) Temporary() bool
func (GenericError) Timeout ¶
func (e GenericError) Timeout() bool
type SendWithFunc ¶
type Session ¶
func NewSession ¶
func (*Session) GetBytesRead ¶
func (*Session) GetConnWindowSize ¶
func (*Session) GetContext ¶ added in v1.0.6
func (*Session) GetDataToSend ¶
func (*Session) IsClosedByRemote ¶ added in v1.0.6
func (*Session) IsEstablished ¶
func (*Session) ReceiveWith ¶
func (*Session) RecvWindowUsed ¶
func (*Session) RemoteAddr ¶
func (*Session) SendWindowUsed ¶
Click to show internal directories.
Click to hide internal directories.