fatedier/kcp-go — 4★ trên GitHub (Go). A Production-Grade Reliable-UDP Library for golang
Tóm tắt dựng từ metadata GitHub của chính dự án — chưa có bài review TopGit. Trang sẽ tự động cập nhật khi bài review đầy đủ được xuất bản.
VÌ SAO CHƯA CÓ REVIEW
TopGit viết bài đầy đủ cho repo có nhiều sao nhất và được yêu cầu nhiều nhất. Trang này là snapshot trong thời gian chờ — xem README gốc ở tab READ ME.
kcp-go is a Production-Grade Reliable-UDP library for golang.
This library intents to provide a smooth, resilient, ordered, error-checked and anonymous delivery of streams over UDP packets, it has been battle-tested with opensource project kcptun. Millions of devices(from low-end MIPS routers to high-end servers) have deployed kcp-go powered program in a variety of forms like online games, live broadcasting, file synchronization and network acceleration.
Lastest Release
Features
Designed for Latency-sensitive scenarios.
Cache friendly and Memory optimized design, offers extremely High Performance core.
Handles >5K concurrent connections on a single commodity server.
Compatible with net.Conn and net.Listener, a drop-in replacement for net.TCPConn.
FEC(Forward Error Correction) Support with Reed-Solomon Codes
Packet level encryption support with AES, TEA, 3DES, Blowfish, Cast5, Salsa20, etc. in CFB mode, which generates completely anonymous packet.
Only A fixed number of goroutines will be created for the entire server application, costs in context switch between goroutines have been taken into consideration.
Compatible with skywind3000's C version with various improvements.
Documentation
For complete documentation, see the associated Godoc.
Specification
+-----------------+
| SESSION |
+-----------------+
| KCP(ARQ) |
+-----------------+
| FEC(OPTIONAL) |
+-----------------+
| CRYPTO(OPTIONAL)|
+-----------------+
| UDP(PACKET) |
+-----------------+
| IP |
+-----------------+
| LINK |
+-----------------+
| PHY |
+-----------------+
(LAYER MODEL OF KCP-GO)
Model Name: MacBook Pro
Model Identifier: MacBookPro14,1
Processor Name: Intel Core i5
Processor Speed: 3.1 GHz
Number of Processors: 1
Total Number of Cores: 2
L2 Cache (per Core): 256 KB
L3 Cache: 4 MB
Memory: 8 GB
List structure introduces heavy cache misses compared to slice which owns better locality, 5000 connections with 32 window size and 20ms interval will cost 6us/0.03%(cpu) using slice, and 8.7ms/43.5%(cpu) for list for each kcp.flush().
Timing accuracy vs. syscall clock_gettime
Timing is critical to RTT estimator, inaccurate timing leads to false retransmissions in KCP, but calling time.Now() costs 42 cycles(10.5ns on 4GHz CPU, 15.6ns on my MacBook Pro 2.7GHz).
In kcp-go, after each kcp.output() function call, current clock time will be updated upon return, and for a single kcp.flush() operation, current time will be queried from system once. For most of the time, 5000 connections costs 5000 * 15.6ns = 78us(a fixed cost while no packet needs to be sent), as for 10MB/s data transfering with 1400 MTU, kcp.output() will be called around 7500 times and costs 117us for time.Now() in every second.
Connection Termination
Control messages like SYN/FIN/RST in TCP are not defined in KCP, you need some keepalive/heartbeat mechanism in the application-level. A real world example is to use some multiplexing protocol over session, such as smux(with embedded keepalive mechanism), see kcptun for example.
FAQ
Q: I'm handling >5K connections on my server, the CPU utilization is so high.
A: A standalone agent or gate server for running kcp-go is suggested, not only for CPU utilization, but also important to the precision of RTT measurements(timing) which indirectly affects retransmission. By increasing update interval with SetNoDelay like conn.SetNoDelay(1, 40, 1, 1) will dramatically reduce system load, but lower the performance.
Who is using this?
https://github.com/xtaci/kcptun -- A Secure Tunnel Based On KCP over UDP.
https://github.com/getlantern/lantern -- Lantern delivers fast access to the open Internet.
https://github.com/smallnest/rpcx -- A RPC service framework based on net/rpc like alibaba Dubbo and weibo Motan.
https://github.com/gonet2/agent -- A gateway for games with stream multiplexing.
https://github.com/syncthing/syncthing -- Open Source Continuous File Synchronization.
Links
https://github.com/xtaci/libkcp -- FEC enhanced KCP session library for iOS/Android in C++
https://github.com/skywind3000/kcp -- A Fast and Reliable ARQ Protocol
https://github.com/klauspost/reedsolomon -- Reed-Solomon Erasure Coding in Go
Trang TopGit này là một snapshot — tab "Readme" hiển thị nguyên văn README của repo (đã bỏ link, giữ ảnh). Repo GitHub ở github.com/fatedier/kcp-go là nguồn chính thức.
fatedier/kcp-go có bao nhiêu sao?
fatedier/kcp-go có 4 sao GitHub — tải lại trang để xem số mới nhất, hoặc xem trực tiếp github.com/fatedier/kcp-go. TopGit phản chiếu số sao của GitHub nhưng không cam kết đến từng phút.
fatedier/kcp-go có phải mã nguồn mở không?
Có — fatedier/kcp-go phát hành theo license MIT, nghĩa là mã nguồn mở để đọc, fork và (tùy license) tái sử dụng. Mã: github.com/fatedier/kcp-go.
fatedier/kcp-go có website riêng không?
TopGit chưa ghi nhận URL trang chủ cho fatedier/kcp-go. Phần README ở tab phía trên thường có link demo, hoặc xem mô tả GitHub của repo.
fatedier/kcp-go là gì?
fatedier/kcp-go (fatedier/kcp-go) là dự án Go trên GitHub. Theo mô tả gốc: A Production-Grade Reliable-UDP Library for golang
Đọc đầy đủ README ở tab phía trên.
Muốn nghe thêm một ý kiến về kcp-go?
Hỏi một AI đọc được trang này — một cú bấm là có ngay nhận định về kcp-go.