qvic

package
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2019 License: LGPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StatusNone       = 0
	StatusConnecting = 1
	StatusConnected  = 2
	StatusClosing    = 3
	StatusClosed     = 4

	DefaultFECBundle = 16 // default packet number every bundle.
	DefaultFECLen    = 3  // default extra packets number every bundle.
	DefaultJitter    = 40
	VPacketDataLen   = 1380

	DefaultWinSize          = 4096 // default window size for QConn.
	DefaultRecvPacketLength = 2048

	ExtraLenPaddingInData = 2
)

Qvic const

View Source
const (
	SlotsNum         = 16384 // maximum number of qconn that QvicMgr can hold.
	DefaultPortStart = 50000
	DefaultPortEnd   = 51023
)
View Source
const (
	// MaxBitLength Max bit length
	MaxBitLength uint = 8

	// MaxBitIndex Max bit index size
	MaxBitIndex uint = 7

	// ShiftOffset Left/Right shift size
	ShiftOffset uint = 3
)
View Source
const (
	// VPacketHeadLen head length in net-package
	VPacketHeadLen  int = 13
	PackTypeControl int = 8
	PackTypeChannel int = 7
	PackTypeData    int = 6
	PackTypeFEC     int = 5
)
View Source
const (
	// MilliInSec milliseconds in one second
	MilliInSec uint64 = 1000
)

Variables

This section is empty.

Functions

This section is empty.

Types

type FECHelper

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

FECHelper helper class for FEC

func (*FECHelper) GetRecoverInfo

func (h *FECHelper) GetRecoverInfo(pS *VBitVec) *VBitVec

GetRecoverInfo get VBitVec that can recover

func (*FECHelper) Init

func (h *FECHelper) Init(_bitLen uint) bool

Init initialize helper.

type FECInfo

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

FECInfo record packages info of a bundle

func NewFECInfo

func NewFECInfo() (f *FECInfo)

NewFECInfo create new FECInfo class

func (*FECInfo) Clear

func (v *FECInfo) Clear()

Clear reset FECInfo

type QConn

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

QConn represents a qvic connection, implements net.Conn interface.

func NewQConn

func NewQConn(mgr *QvicMgr) (*QConn, error)

NewQConn creates QvicMgr object.

func (*QConn) Close

func (qc *QConn) Close() error

Close the qvic connection

func (*QConn) LocalAddr

func (qc *QConn) LocalAddr() net.Addr

LocalAddr returns the local network address.

func (*QConn) Read

func (qc *QConn) Read(b []byte) (readLen int, err error)

func (*QConn) RemoteAddr

func (qc *QConn) RemoteAddr() net.Addr

RemoteAddr returns the remote network address.

func (*QConn) SetDeadline

func (qc *QConn) SetDeadline(t time.Time) error

func (*QConn) SetReadDeadline

func (qc *QConn) SetReadDeadline(t time.Time) error

func (*QConn) SetWriteDeadline

func (qc *QConn) SetWriteDeadline(t time.Time) error

func (*QConn) Write

func (qc *QConn) Write(b []byte) (n int, err error)

type QTimeoutErr

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

QTimeoutErr implements net.Error interface, in order to provide unified interface as tcp does.

func NewQTimeoutError

func NewQTimeoutError(s string) *QTimeoutErr

func (*QTimeoutErr) Error

func (e *QTimeoutErr) Error() string

func (*QTimeoutErr) Temporary

func (e *QTimeoutErr) Temporary() bool

func (*QTimeoutErr) Timeout

func (e *QTimeoutErr) Timeout() bool

type QvicMgr

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

QvicMgr manages qvic module.

func NewQvicMgr

func NewQvicMgr() *QvicMgr

NewQvicMgr creates QvicMgr object.

func (*QvicMgr) Accept

func (mgr *QvicMgr) Accept() (net.Conn, error)

Accept gets connection from qvic module if exists.

func (*QvicMgr) Close

func (mgr *QvicMgr) Close()

Close clean for QvicMgr object.

func (*QvicMgr) DialTimeout

func (mgr *QvicMgr) DialTimeout(network, addr string, timeout time.Duration) (conn net.Conn, err error)

DialTimeout connects to the address on the named network with a timeout config. network parameters must be "tcp" or "qvic" for tcp connection and qvic connection respectively.

func (*QvicMgr) Listen

func (mgr *QvicMgr) Listen(tcpAddress string, qvicAddress string) (err error)

Listen binds ports and starts listenning for both tcp and qvic.

type ReceiverMgr

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

ReceiverMgr manages QConn's receiver logic.

func NewReceiverMgr

func NewReceiverMgr(qc *QConn) *ReceiverMgr

NewReceiverMgr creates ReceiverMgr object.

type SenderMgr

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

SenderMgr manages QConn's sender logic.

func NewSenderMgr

func NewSenderMgr(qc *QConn) *SenderMgr

NewSenderMgr creates SenderMgr object.

type SpeedMeter

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

SpeedMeter computes bandwidth

func NewSpeedMeter

func NewSpeedMeter(step uint64, items uint) (s *SpeedMeter)

NewSpeedMeter creates SpeedMeter. step should be ms. for example: step=100 items=10; step=50 items=20. step * items = a period.

func (*SpeedMeter) Feed

func (s *SpeedMeter) Feed(num uint)

Feed called when bytes received from network

func (*SpeedMeter) GetRate

func (s *SpeedMeter) GetRate() uint

GetRate gets rate

type TokenBucket

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

TokenBucket for bucket limit rate

func (*TokenBucket) AdjustBW

func (t *TokenBucket) AdjustBW(bytesPerSecond int64)

AdjustBW adjusts bandwidth anytime

func (*TokenBucket) Consume

func (t *TokenBucket) Consume(tokens int64)

Consume consumes some buckets

func (*TokenBucket) GetCurLooseTokens

func (t *TokenBucket) GetCurLooseTokens() int64

GetCurLooseTokens gets valid tokens, minus reserved

func (*TokenBucket) GetCurTokens

func (t *TokenBucket) GetCurTokens() int64

GetCurTokens gets valid tokens

func (*TokenBucket) Init

func (t *TokenBucket) Init(bytesPerSecond int64)

Init initializes TokenBucket with bytesPerSecond and factor

func (*TokenBucket) PeriodicFeed

func (t *TokenBucket) PeriodicFeed()

PeriodicFeed called periodically, for example 30ms

type VBitVec

type VBitVec struct {
	BitLen uint

	ExtFlag byte // flag for extra package
	// contains filtered or unexported fields
}

VBitVec bitmap friendly for FEC helper

func (*VBitVec) Attatch

func (v *VBitVec) Attatch(p []byte, _bitLen uint, flag byte)

Attatch initializes bitmap with memory block

func (*VBitVec) BitXor

func (v *VBitVec) BitXor(c1 *VBitVec, c2 *VBitVec)

BitXor initializes bitmap with c1 ^ c2

func (*VBitVec) BitXor1

func (v *VBitVec) BitXor1(c1 *VBitVec)

BitXor1 calculates the xor value with c1

func (*VBitVec) Detach

func (v *VBitVec) Detach()

Detach clears VBitVec

func (*VBitVec) GetBit

func (v *VBitVec) GetBit(idx uint) bool

GetBit gets bit in pos

func (*VBitVec) GetBitmapString

func (v *VBitVec) GetBitmapString() (str string)

GetBitmapString gets bitmap string

func (*VBitVec) GetFlagBit

func (v *VBitVec) GetFlagBit(idx uint) bool

GetFlagBit gets bit in pos of extflag

func (*VBitVec) Init

func (v *VBitVec) Init(_bitLen uint) bool

Init initializes VBitVec with bitLen

func (*VBitVec) InitPattern

func (v *VBitVec) InitPattern(flag byte, len uint)

InitPattern initializes bitmap with pattern

func (*VBitVec) SetBit

func (v *VBitVec) SetBit(idx uint, val bool)

SetBit sets value by bit index

type VPacket

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

VPacket package for QVIC

func (*VPacket) MarshalData

func (v *VPacket) MarshalData()

MarshalData pack data to dataNet

func (*VPacket) ParseData

func (v *VPacket) ParseData(packData []byte)

ParseData parse data from dataNet. packData contains udp-package recved from net

type VPacketItem

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

VPacketItem package info for RecverMgr

Jump to

Keyboard shortcuts

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