KCP - A Fast and Reliable ARQ Protocol

go get



GoDoc Build Status Go Report Card Coverage Statusd

A port of KCP in golang


  1. 100% compatible with original skywind3000's C version.
  2. Pure golang implementation of KCP in a single file kcp.go.
  3. Instead of container.List, kcp-go made use of cache friendly slice based internal queue.
  4. Provides a basic session manager, compatible with net.Conn and net.Listener.
  5. Indepedent KCP code and session manager code, you can copy kcp.go to your project without session manager.
  6. Support FEC(Forward Error Correction)
  7. Support packet level encryption with AES


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


  型号名称:   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
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}
ok 0.600s