KCP makes no system calls, and that is the whole interface
:zap: KCP - A Fast and Reliable ARQ Protocol
At a glance
- What is it?
- KCP is an ARQ reliability protocol written as two C files that you drive yourself: you hand it a clock, an output callback and the packets your transport delivers, and it makes no system calls at all. It trades ten to twenty percent of bandwidth for thirty to forty percent lower average latency than TCP, and the fast mode is four integers.
- Who is it for?
- KCP fits an engineer who has a transport that loses packets and a workload where latency matters more than throughput, such as interactive traffic, a tunnel or a control channel, and who is content to own the timer. It does not fit bulk transfer, because the latency is bought with bandwidth and the file says so in the first paragraph.
- Can I use it commercially?
- Yes. MIT is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
- Is it still maintained?
- Yes. The repository last received commits 145 days ago.
- What is it written in?
- Mainly C, according to GitHub's language statistics.
Answers come from the project's GitHub data, last synced on November 15, 2026, and from our analysis. They are not legal advice.
Star history
- skywind3000/kcp16,958 ★ · +45
| Repository | 2026-09-21 | 2026-11-15 |
|---|---|---|
| skywind3000/kcp | 16.9k | 17k |
45 Stars in the last 55 days, measured from the daily GitHub snapshot. Compare with other projects
Editorial analysis
No socket, no clock, no system call
The first paragraph is the design in three sentences. KCP is a protocol that trades ten to twenty percent of wasted bandwidth for a thirty to forty percent reduction in average latency and up to three times lower maximum latency compared with TCP. It is a pure algorithm implementation: it does not handle the receiving and sending of the layer below it, such as UDP, so the user defines how lower-layer packets are sent and hands that definition to KCP as a callback. And the clock is passed in from outside as well, with not one system call inside the library. The consequence is that the integration cost is three things: an output callback, a periodic update call with a millisecond timestamp, and an input function you feed received packets into. The cost of that purity is the clock, because a wrong timestamp produces wrong retransmission timers and the library has no way to tell you.
The fast mode is four integers, and the default is deliberately slow
The protocol ships in a standard ARQ mode, and the file is clear that the speed comes from switches you have to turn on. The mode call takes four numbers:
int ikcp_nodelay(ikcpcb *kcp, int nodelay, int interval, int resend, int nc)The first turns the no-delay mode on or off, the second is the internal working interval in milliseconds with ten and twenty given as examples, the third is the fast retransmit mode, off by default and settable to two so that two spanning acknowledgements trigger a retransmit directly, and the fourth switches flow control off, which is off by default in the sense that the default does not disable it. The two documented configurations are the whole spread: a normal one with no delay disabled, a forty millisecond interval and flow control on, and what the file calls the fastest, with the interval at ten, fast retransmit at two and flow control disabled. The fastest setting is the one to read twice, because it is not only faster.
Five mechanisms, each one a deliberate difference from TCP
The technical section lists six changes, the sixth being the flow control covered below, and explains what each buys. The retransmission timeout in TCP is doubled on each loss, so three consecutive losses multiply it by eight, while KCP in fast mode multiplies by one and a half, which the file reports as experimentally the better value. Retransmission is selective rather than cumulative, so a loss resends the lost packet instead of everything after it. Fast retransmit is inferred from the acknowledgement pattern: receiving acknowledgements for one, three, four and five tells it that two was skipped once, and then twice, at which point it resends without waiting for a timeout. Acknowledgement delay is configurable, where TCP delays acknowledgements to fill the pipe and that inflates the round-trip estimate used for loss detection. And every packet other than a standalone acknowledgement carries the information a TCP-style cumulative acknowledgement would carry, in addition to its own sequence number, so no choice between the two models has to be made.
Switching flow control off is the fastest setting and it costs fairness
This is the candid part of the file. In normal mode the send window is determined the way TCP determines it, by four things: the size of the send buffer, the receiver's remaining receive buffer, backoff on loss, and slow start. The file then says that when timeliness matters and the data is small, you can configure the protocol to skip the last two of those and use only the first two to control the send rate, trading some fairness and some bandwidth efficiency for the result that transmission stays smooth even with BitTorrent running. That sentence tells you the intended use and the intended cost at the same time. If your traffic shares a link with a bulk transfer, the fastest configuration is the right one and the politeness is what you are giving up. If it does not, you are giving up throughput for nothing.
The window counts packets and the minimum RTO is a struct field
Two configuration details describe the shape of the API more than the feature list does. The window call sets the maximum send and receive windows, and the default is 32, which the file compares to the TCP send and receive buffers with the difference that the unit is packets rather than bytes. The minimum retransmission timeout is set by assigning to a field on the structure, as the file shows:
kcp->rx_minrto = 10;The default is 100 milliseconds, and 30 in fast mode, and the file explains why the value matters even when the computed timeout is smaller: a computed 40 milliseconds still cannot detect a loss until the minimum allows it. So one setting is a function call and the other is a struct poke, and a mistyped or ignored minimum is invisible. The maximum transmission unit is the third of this family, and here the library is explicit that it does not probe it, defaulting to 1400 bytes and letting you set it, because it affects how packets are merged and fragmented.
Two files, a protocol document, and an install path owned by someone else
The integration story is the claim the file leads with: the whole protocol is two source files, a header and a C file, so you can copy them into an existing project and write a couple of lines to use it, which is the pitch for anyone who has a peer-to-peer stack or a UDP-based protocol without a reliable transport. The repository is correspondingly small, with those two files, a protocol description document, a test program, a CMake build file and a benchmark image. The install route, though, is a package manager: the vcpkg sequence of cloning, bootstrapping, integrating and installing, and the file says the port is kept current by a member of the vendor's own team and by community contributors, and asks you to report a stale version on that package manager's own repository. So the version of the library you get is maintained one project away.
About thirty ports is the real adoption story
The list of open source cases at the end of the file is mostly ports. There are implementations for Java, two for the .NET ecosystem and several more for it, a Kotlin multiplatform one targeting the JVM and four operating systems, a Rust one and an async runtime integration, a Lua extension, a Node interface, a Perl one, a C# translation described line by line, and a complete UDP networking library built on it. Among the non-port entries are a port-forwarding tunnel, a Go tunnel, a proxy that integrated the protocol for UDP transport with no packet signature, a high-performance network framework and a reverse proxy for exposing internal services. The pattern is the point. The reach of this protocol is in other languages, which makes the C original the specification and makes interoperability a property of whichever port your peer happens to run.
Editorial conclusion
KCP fits an engineer who has a transport that loses packets and a workload where latency matters more than throughput, such as interactive traffic, a tunnel or a control channel, and who is content to own the timer. It does not fit bulk transfer, because the latency is bought with bandwidth and the file says so in the first paragraph. Before you use it, read the four numbers in the mode call, because the documented fastest configuration switches flow control off entirely, and that is a decision about fairness rather than a preset. Then set the window and the minimum RTO yourself, because the defaults are conservative and one of them is a struct field you assign rather than a function you call. And plan for the ports: with many implementations listed, interoperability is a property of the port rather than of this repository, so pin one and test against it.
Frequently asked questions
What is the KCP protocol?
KCP is a reliable ARQ protocol implemented as a pure algorithm in two C files, with no system calls of its own. It trades ten to twenty percent of wasted bandwidth for a thirty to forty percent reduction in average latency against TCP, and it does not touch the transport: you supply the clock, an output callback and the packets you receive.
How do I install KCP?
The documented route is a package manager: clone the vendor's C++ package manager repository, change into it, bootstrap it, integrate the install and then install KCP. The file notes that the KCP port there is kept current by a member of the vendor's team and by community contributors, and asks for an issue or pull request on that repository if the version is stale. The library is also just two source files you can copy into an existing project.
How do I send and receive data with KCP?
Four steps. Create the object with a session number that both peers must agree on plus a user pointer, set an output callback that receives a buffer and a length, call the update function in a loop with the current time in milliseconds, and feed received lower-layer packets into the input function. Sending and receiving then go through the send and receive calls.
What are the parameters in the KCP nodelay call?
Four integers: whether to enable no-delay mode, the internal working interval in milliseconds, the fast retransmit mode which is off by default and can be set to two so two spanning acknowledgements retransmit directly, and whether to disable flow control, which is enabled by default. The file gives a normal configuration and a fastest one as examples.
Does KCP detect the maximum transmission unit itself?
No, because the library is a pure algorithm that makes no system calls. The default is 1400 bytes and you set it yourself, and the value affects how packets are merged and fragmented. Two neighbouring settings are the same shape: the window default is 32 measured in packets rather than bytes, and the minimum retransmission timeout is a field you assign on the structure.
Official sources
Add this badge to your README
If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.
[](https://hysenlabs.com/projects/skywind3000-kcp)Star history chart for your README
[](https://hysenlabs.com/projects/skywind3000-kcp)Was this useful?