Documentation ¶
Index ¶
- Constants
- func Ikcp_check(kcp *Ikcpcb, current uint32) uint32
- func Ikcp_flush(kcp *Ikcpcb)
- func Ikcp_input(kcp *Ikcpcb, data []byte, size int) int
- func Ikcp_log(kcp *Ikcpcb, mask int32, head string, args ...interface{})
- func Ikcp_nodelay(kcp *Ikcpcb, nodelay, interval, resend, nc int32) int32
- func Ikcp_peeksize(kcp *Ikcpcb) int32
- func Ikcp_recv(kcp *Ikcpcb, buffer []byte, _len int32) int32
- func Ikcp_release(kcp *Ikcpcb)
- func Ikcp_send(kcp *Ikcpcb, buffer []byte, _len int) int
- func Ikcp_setmtu(kcp *Ikcpcb, mtu int32) int32
- func Ikcp_update(kcp *Ikcpcb, current uint32)
- func Ikcp_update_ack(kcp *Ikcpcb, rtt int32)
- func Ikcp_waitsnd(kcp *Ikcpcb) int32
- func Ikcp_wndsize(kcp *Ikcpcb, sndwnd, rcvwnd int32) int32
- type DelayPacket
- type DelayTunnel
- type IKCPCB
- type IKCPSEG
- type Ikcpcb
- type LatencySimulator
- type Random
Constants ¶
const IKCP_ACK_FAST uint32 = 3
const IKCP_ASK_SEND uint32 = 1 // need to send IKCP_CMD_WASK
const IKCP_ASK_TELL uint32 = 2 // need to send IKCP_CMD_WINS
const IKCP_CMD_ACK uint32 = 82 // cmd: ack
const IKCP_CMD_PUSH uint32 = 81 // cmd: push data
const IKCP_CMD_WASK uint32 = 83 // cmd: window probe (ask)
const IKCP_CMD_WINS uint32 = 84 // cmd: window size (tell)
const IKCP_DEADLINK uint32 = 10
const IKCP_INTERVAL uint32 = 100
const IKCP_LOG_INPUT = 2
const IKCP_LOG_IN_ACK = 32
const IKCP_LOG_IN_DATA = 16
const IKCP_LOG_IN_PROBE = 64
const IKCP_LOG_IN_WIN = 128
const IKCP_LOG_OUTPUT = 1
const IKCP_LOG_OUT_ACK = 512
const IKCP_LOG_OUT_DATA = 256
const IKCP_LOG_OUT_PROBE = 1024
const IKCP_LOG_OUT_WINS = 2048
const IKCP_LOG_RECV = 8
const IKCP_LOG_SEND = 4
const IKCP_MTU_DEF uint32 = 1400
const IKCP_OVERHEAD uint32 = 24
const IKCP_PROBE_INIT uint32 = 7000 // 7 secs to probe window size
const IKCP_PROBE_LIMIT uint32 = 120000 // up to 120 secs to probe window
const IKCP_RTO_DEF uint32 = 200
const IKCP_RTO_MAX uint32 = 60000
const IKCP_RTO_MIN uint32 = 100 // normal min rto
const IKCP_RTO_NDL uint32 = 30 // no delay min rto
===================================================================== KCP BASIC =====================================================================
const IKCP_THRESH_INIT uint32 = 2
const IKCP_THRESH_MIN uint32 = 2
const IKCP_WND_RCV uint32 = 32
const IKCP_WND_SND uint32 = 32
Variables ¶
This section is empty.
Functions ¶
func Ikcp_check ¶
func Ikcp_flush ¶
func Ikcp_flush(kcp *Ikcpcb)
--------------------------------------------------------------------- Ikcp_flush ---------------------------------------------------------------------
func Ikcp_input ¶
--------------------------------------------------------------------- input data ---------------------------------------------------------------------
func Ikcp_nodelay ¶
func Ikcp_peeksize ¶
--------------------------------------------------------------------- send data ---------------------------------------------------------------------
func Ikcp_recv ¶
--------------------------------------------------------------------- recv data ---------------------------------------------------------------------
func Ikcp_release ¶
func Ikcp_release(kcp *Ikcpcb)
--------------------------------------------------------------------- release a new kcpcb ---------------------------------------------------------------------
func Ikcp_send ¶
--------------------------------------------------------------------- send data ---------------------------------------------------------------------
func Ikcp_setmtu ¶
func Ikcp_update ¶
--------------------------------------------------------------------- input update ---------------------------------------------------------------------
func Ikcp_update_ack ¶
--------------------------------------------------------------------- parse ack ---------------------------------------------------------------------
func Ikcp_waitsnd ¶
func Ikcp_wndsize ¶
Types ¶
type DelayPacket ¶
type DelayPacket struct {
// contains filtered or unexported fields
}
func (*DelayPacket) Init ¶
func (p *DelayPacket) Init(size int, src []byte)
type DelayTunnel ¶
type IKCPCB ¶
type IKCPCB struct { Output func(buf []byte, _len int32, kcp *Ikcpcb, user interface{}) int32 // contains filtered or unexported fields }
=====================================================================
KCP - A Better ARQ Protocol Implementation skywind3000 (at) gmail.com, 2010-2011
Features: + Average RTT reduce 30% - 40% vs traditional ARQ like tcp. + Maximum RTT reduce three times vs tcp. + Lightweight, distributed as a single source file.
===================================================================== --------------------------------------------------------------------- IKCPCB ---------------------------------------------------------------------
type IKCPSEG ¶
type IKCPSEG struct {
// contains filtered or unexported fields
}
--------------------------------------------------------------------- manage segment ---------------------------------------------------------------------
type Ikcpcb ¶
type Ikcpcb struct{ IKCPCB }
func Ikcp_create ¶
--------------------------------------------------------------------- create a new kcpcb ---------------------------------------------------------------------
type LatencySimulator ¶
type LatencySimulator struct {
// contains filtered or unexported fields
}
func (*LatencySimulator) Init ¶
func (p *LatencySimulator) Init(lostrate, rttmin, rttmax, nmax int)
lostrate: 往返一周丢包率的百分比,默认 10% rttmin:rtt最小值,默认 60 rttmax:rtt最大值,默认 125 func (p *LatencySimulator)Init(int lostrate = 10, int rttmin = 60, int rttmax = 125, int nmax = 1000):