Categorygithub.com/golangltd/kcp-go
modulepackage
1.0.1
Repository: https://github.com/golangltd/kcp-go.git
Documentation: pkg.go.dev

# README

kcp-go :pisces:

GoDoc Powered MIT licensed Build Status Go Report Card Coverage Statusd

A full-featured reliable UDP communication library.
Claude_Shannon

Features :zap:

  1. Optimized for Real-Time Strategy Game.
  2. Compatible with skywind3000's C version with modifications.
  3. Cache friendly and Memory optimized design in golang.
  4. A session manager has been provided, compatible with net.Conn and net.Listener.
  5. FEC(Forward Error Correction) Support with Reed-Solomon Codes
  6. Packet level encryption support with AES, TEA.

Conventions :zap:

  1. Packet delivery via UDP.
  2. The conversation id conv uint32 in session manager should be a random number initiated by client.
  3. KCP doesn't define session control messages like SYN/FIN/RST in TCP, a real world example is to use some multiplexing protocol over session, such as yamux, see kcptun for example.

Examples :zap:

Client: full demo

kcpconn, err := kcp.DialWithOptions("192.168.0.1:10000", nil, 10, 3)

Server: full demo

lis, err := kcp.ListenWithOptions(":10000", nil, 10, 3)

Performance :zap:

  型号名称:	MacBook Pro
  型号标识符:	MacBookPro12,1
  处理器名称:	Intel Core i5
  处理器速度:	2.7 GHz
  处理器数目:	1
  核总数:	2
  L2 缓存(每个核):	256 KB
  L3 缓存:	3 MB
  内存:	8 GB
$ go test -run Speed
new client 127.0.0.1:61165
total recv: 16777216
time for 16MB rtt with encryption 570.41176ms
&{BytesSent:33554432 BytesReceived:33554432 MaxConn:2 ActiveOpens:1 PassiveOpens:1 CurrEstab:1 InErrs:0 InCsumErrors:0 InSegs:42577 OutSegs:42641 OutBytes:48111336 RetransSegs:92 FastRetransSegs:92 LostSegs:0 RepeatSegs:0 FECRecovered:1 FECErrs:0 FECSegs:8514}
PASS
ok  	github.com/xtaci/kcp-go	0.600s

Links :zap:

  1. https://github.com/xtaci/libkcp -- Official client library for iOS/Android(C++11)
  2. https://github.com/skywind3000/kcp -- A Fast and Reliable ARQ Protocol
  3. https://github.com/klauspost/reedsolomon -- Reed-Solomon Erasure Coding in Go

Donation :dollar:

donate

All donations on this project will be used to support the development of gonet/2.

# Functions

Dial connects to the remote address "raddr" on the network "udp".
DialWithOptions connects to the remote address "raddr" on the network "udp" with packet encryption.
Listen listens for incoming KCP packets addressed to the local address laddr on the network "udp",.
ListenWithOptions listens for incoming KCP packets addressed to the local address laddr on the network "udp" with packet encryption, dataShards, parityShards defines Reed-Solomon Erasure Coding parameters.
NewAESBlockCrypt initates AES BlockCrypt by the given key.
NewKCP create a new kcp control object, 'conv' must equal in two endpoint from the same connection.
NewNoneBlockCrypt initate NoneBlockCrypt by the given key.
NewSegment creates a KCP segment.
NewSimpleXORBlockCrypt initate SimpleXORBlockCrypt by the given key.
NewTEABlockCrypt initate TEA BlockCrypt by the given key.

# Constants

No description provided by the author
need to send IKCP_CMD_WASK.
need to send IKCP_CMD_WINS.
cmd: ack.
cmd: push data.
cmd: window probe (ask).
cmd: window size (tell).
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
7 secs to probe window size.
up to 120 secs to probe window.
No description provided by the author
No description provided by the author
normal min rto.
no delay min rto.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Variables

DefaultSnmp is the global KCP connection statistics collector.

# Structs

No description provided by the author
AESBlockCrypt implements BlockCrypt with AES.
No description provided by the author
KCP defines a single KCP connection.
No description provided by the author
NoneBlockCrypt simple returns the plaintext.
Segment defines a KCP segment.
SimpleXORBlockCrypt implements BlockCrypt with simple xor to a table.
Snmp defines network statistics indicator.
TEABlockCrypt implements BlockCrypt with TEA.
No description provided by the author

# Interfaces

BlockCrypt defines encryption/decryption methods for a given byte slice.

# Type aliases

No description provided by the author
Output is a closure which captures conn and calls conn.Write.